Firebase AI Logic hybrid inference · Gemini Nano in Chrome 139+
Every hybrid app hardcodes a guess. Tandem measures it.
Tandem tests your tasks on Gemini Nano and in the cloud, compiles a routing policy with the evidence attached, and routes every request by it. Sensitive data stays on the device.
192 measured tasks · 24 evidence-backed rules · a receipt for every routing decision
Requirements
every modern browserCloud lane
Works in any browser, right now. Firebase AI Logic sends prompts to gemini-3.5-flash-lite behind App Check. No setup, no extensions, no flags.
On-device lane
Needs Chrome 139+ on a desktop with Gemini Nano enabled (chrome://flags/#optimization-guide-on-device-model → Enabled). Without it the cloud lane runs alone and every screen says why the on-device lane is idle.
No Gemini Nano? A labelled reference run from the author's laptop fills every chart and rule. The app never pretends.
The probe races your tasks on both models
1 · probeThe same synthetic tasks run on Gemini Nano with ONLY_ON_DEVICE and in the cloud with ONLY_IN_CLOUD. Deterministic validators score every answer. Below: one real pair, captured on the author's laptop.
- First token
- 1.4 s
- Tokens a second
- 7.9
- Answer
- 7.1 s
- Create a study schedule; allocate specific times. - Practice with past papers; identify weak areas. - Use active recall; test yourself frequently instead of passively reading.
validators passedinferenceSource: on_device
- First token
- 826 ms
- Tokens a second
- 502.6
- Answer
- 921 ms
- Review your notes daily instead of cramming the night before. - Practice with past exam papers to build test-taking confidence. - Take short breaks every hour to maintain high focus levels.
validators passedinferenceSource: in_cloud
Every routing rule carries its evidence
3 · policyTandem compiles the probe into 24 rules, one per task type and input length. A rule goes local-first only when four checks pass, and the thresholds were fixed before any data existed. The result ships as a certificate, through Remote Config.
Cloud-firstSummarise · short
- At least 8 distinct tasks12
- On-device pass rate, 95% lower bound ≥ 75%76%
- Within 5 points of the cloud100% vs 100%
- On-device p95 latency ≤ 8 s21.5 s
Local p95 latency 21512 ms exceeds the 8000 ms budget.
Two reasons to use the cloud, recorded apart
Availability fallback
The local model cannot run: not downloaded, an unsupported browser, a crashed model process. Firebase AI Logic already does this.
availabilityFallback: true availabilityReason: "on-device model downloadable" route: CLOUD · servedBy: in_cloud
Quality escalation
The local model ran, but its answer failed a check: broken JSON, a missing fact, too long, or a refusal. Tandem adds this.
qualityEscalation: { happened: true, reason: "schema" }
local attempt: kept for review
route: CLOUD · servedBy: in_cloudHeld-out results on one laptop
the honest findingThe policy was compiled from calibration tasks only, then replayed on 93 held-out tasks measured on both models. Intel Iris Xe, 16 GB, Chrome 158.
On this laptop's integrated GPU, Gemini Nano is slower than the cloud for every task type. At the interactive 8-second budget the policy keeps nothing on-device. That is the honest finding, and the reason Tandem exists.
With a 30-second budget for background work, 86% stays on-device at 100% quality. The budget is the developer's choice; Tandem shows what each choice costs.
94%
of 93 held-out tasks passed on Gemini Nano alone
98%
passed in the cloud with gemini-3.5-flash-lite
10.3 s
median on-device answer, against 1.3 s in the cloud
86%
kept on-device with a 30-second budget for background work
Tandem Guard keeps identifiers on the device
privacy is a routing constraintBefore any request leaves, Guard finds Indian identifiers, even written in Tamil digits, spaced out, split across lines or hidden in base64. Sensitive notes stay local or leave redacted, and only with consent. In Guard Lab it catches 261 of 263 disguised identifiers.
What the note says
Bhai mera PAN B Q K P S 4 8 2 1 L hai, aur Aadhaar ४७१२ ०९३८ ५६१८.
What leaves, with consent
Bhai mera PAN PAN_1 hai, aur Aadhaar AADHAAR_1.
What was built
Spark plan · no server code- Five packages
- tandem-guard, tandem-ai, tandem-bench, tandem-policy and tandem-router, each independently tested. Code
- 192 calibration runs
- 8 task types × 12 synthetic tasks × 2 lanes, scored by deterministic validators; 93 held-out tasks replayed for validation. Frontier
- Wilson 95% intervals
- Every rule carries a lower bound on pass rate, not a point estimate. Thresholds fixed before any data. Certificate
- SHA-256 receipt chain
- Every routing decision produces a receipt chained to the one before it. Tamper with one and the chain breaks. Verify
- Live policy swap
- The policy ships through Remote Config with
onConfigUpdate; open apps change routes without a reload.
Questions from judges and developers
Do I need Gemini Nano to try it?
No. Every screen works without it, the on-device lane says why it is idle, and a labelled reference run from the author's laptop fills the charts.
Is anything simulated?
No. Every stamp shows the inferenceSource Firebase AI Logic reports, and every figure on this page comes from a result file in the repository.
What leaves my device?
Nothing for on-device answers. For cloud answers, the receipt shows the exact payload and the bytes sent. Receipts hold metadata only, never content.
How does a rule become local-first?
Four checks on the probe data: at least 8 tasks, a 95% lower bound of 75% on-device, within 5 points of the cloud, and a p95 answer time inside your latency budget.
Can I use the router in my own app?
Yes. The router is a TypeScript package over Firebase AI Logic: create it with your Firebase app and policy, call run with a task and input, and read the receipt.
Which Firebase products does it use?
AI Logic hybrid inference, App Check with reCAPTCHA v3, anonymous Authentication, Firestore and Remote Config, which ships the policy to open apps in real time.