-
-
Web: the start, the sample read both ways (on a device and in the cloud), and the results without and with the paystub.
-
iOS on a real iPhone 17 Pro: what could leave, read both ways (on this iPhone now and in the cloud), and what the paystub changed.
-
An ordinary Chrome with App Check enforced: both read now, 12 of 12; the record shows the silhouette sent, response 200.
-
A live cloud reading in Safari on an iPhone, its record in plain words, and the send step before an explanation leaves.
Inspiration
About one in five workers who qualify for the Earned Income Tax Credit does not claim it, according to the IRS, and programs such as CalFresh are missed the same way, often by the households that need them most. The fastest way to an exact answer is a document: a paystub shows the real income. But a paystub is also the most personal thing a person can hand to an app: name, employer, pay, dates. We wanted the help of a cloud model without the cloud ever seeing the document, and we wanted every AI answer checked before a person relies on it.
What it does
Silhouette tells a household in California, in about a minute, which of seven public programs it may qualify for (federal EITC, CalEITC, Young Child Tax Credit, CalFresh, LifeLine, CARE, FERA), and then sharpens the answer with a paystub or a Form W-2.
- Rules decide, models point. A deterministic rule engine on the device decides eligibility from official sources (189 hand-worked results reproduced). Models never decide; they only read documents, explain and answer questions.
- The document is read as a silhouette. Every number, date and unknown word is replaced on the device by a placeholder (
N12,D3,W4). The model answers by pointing ("gross pay is N12"), and the device puts the real value back. - What the paystub changed, in money. The results show the programs without and with the paystub (for the sample household: may qualify 3 → 5, with an amount 0 → 3) and the yearly amounts: about $4,369 a year, plus up to $2,016.
- Everything that leaves is shown. "Leaving your device" says in plain words what left (the silhouette as chips) and what stayed, with the exact request one tap away.
How we built it: hybrid inference, verified rather than trusted
Every model task runs through Firebase AI Logic, placed by one shared routing table (shared/routing.json) that the web and iOS apps both implement.
- The device reads first. On the web, Chrome's built-in model through
PREFER_ON_DEVICEwith a strictresponseConstraint; on iOS, Apple's on-device Foundation Model through Firebase AI Logic, with the SDK'sHybridModel(Apple's model first, Gemini second) for explanations and questions. - Deterministic code verifies the answer. Net pay not above gross, a year to date that fits the pay dates, an amount that is money and not an ID or ZIP code. A value that feeds no result is shown only when a check confirms it. Code only rejects; it never picks a value.
- The cloud is asked only when the checks fail (or there is no on-device model), and it receives only the silhouette:
ONLY_IN_CLOUD,responseSchema,gemini-3.5-flash-lite. - App Check is enforced for Firebase AI Logic: reCAPTCHA Enterprise with limited-use tokens on the web (started only when a request is about to go to the cloud), App Attest on iOS.
- Every answer carries its badge ("On this device" or "Cloud") and the routing reason. Remote Config holds the prompt versions and routing thresholds.
For judges, one press reads both ways, live: the sample is read on the device (or from the on-device model's recording when the browser has none), then its silhouette is read now in the cloud, and the review compares the two answers value by value ("Same value from both: 11 of 11").
Stack: React, TypeScript and Vite on Firebase Hosting; native SwiftUI on iOS; one versioned contract (shared/) with conformance fixtures both apps must pass.
Challenges we ran into
- Small models point at the wrong thing. On 24 real-length paystubs it had never seen, the iPhone's on-device model was wrong on its first answer 22 times (an employee ID or a ZIP code as gross pay). The checks stopped all 22 before anything was shown, and the cloud read the silhouette instead; one of the cloud's answers was wrong (1 of 24). In Chrome, 12 of 24 first answers were wrong; a wrong yearly-income value reached the person in 0 of 24. We publish these figures as they are.
- A 4,096-token window. Apple's guided generation writes every allowed id of the response constraint into the prompt; a long paystub's request reached 9,600 tokens. The app now measures each request and, when it would not fit, carries a compact schema while the strict constraint still decides the answer.
- Proving it was held out. Our evaluation sets were written separately, frozen with every file's SHA-256, and committed before the app read them; the commits show the order.
Accomplishments that we're proud of
- A cloud model helps read a paystub without ever receiving a value from it: no name, date or amount appeared in any of 39 request bodies of the cloud evaluation.
- A wrong first answer from the on-device model never reaches the screen unchecked.
- The same contract and fixtures drive a web app and a native iOS app, with recorded runs on a real iPhone 17 Pro.
What we learned
Hybrid is not only "device if available, else cloud". The most useful split was by trust: let the device try, verify with code, and send the cloud only what it needs to point at.
What's next
More states and documents (Form W-2 on the iPhone first), and a pilot with benefits navigators.
