-
-
Exactly what was sent to the cloud: no names, no hospital, no email
-
Three fictional interviews veiled on device by Gemini Nano — the log shows where each step ran
-
One private key for the whole study: the ward manager is the same placeholder in every interview
-
Themes across participants with prevalence bars and quotes tagged by participant
-
The cross-interview report exactly as the cloud saw it: placeholders only
-
One click restores the real names — on this device only
-
Veiled team link (Firestore): teammates see placeholders; only the key holder can reveal names
Inspiration
Qualitative interviews are some of the most sensitive data people handle: nurses describing unsafe shifts, employees reporting a manager, patients talking about their care. A single study can hold dozens of real names, workplaces and phone numbers. Cloud LLMs are excellent at finding themes across interviews, but consent forms, ethics approvals and GDPR usually forbid pasting raw transcripts into them. So researchers, HR teams and journalists still code transcripts by hand — or strip names manually and hope they caught them all.
We wanted the cloud's reasoning power across a whole study, without the cloud ever learning who anyone is.
What it does
Veil splits one research workflow between two models and keeps the boundary between them airtight:
- Veil (on device). Add several interviews to a study (P1, P2, P3…). Gemini Nano in Chrome — via Firebase AI Logic in
ONLY_ON_DEVICEmode with a JSON response schema — finds every name, organisation, place, contact detail and ID. Veil replaces them with placeholders like[PERSON_2], using one private key for the whole study: the ward manager is the same[PERSON_2]in all three interviews, and first or last names used alone get the same token. - Two safety nets. A regex pass catches emails, phone numbers and long IDs. Because small models are non-deterministic (in our own tests Gemini Nano occasionally missed a name), an on-device check flags capitalised names still visible after veiling. Sending is blocked until each is veiled or dismissed, and the outgoing payload is checked for every original in the key.
- Analyse (cloud). Gemini in
ONLY_IN_CLOUDmode, protected by App Check, receives only veiled text and participant codes and returns a cross-interview report: themes with how many participants raised them, quotes tagged by participant, one line per participant, where participants disagree, and follow-up questions. - Reveal (on device). One click switches the report between “as the cloud saw it” and “names restored on this device”. Export a Markdown report or a CSV codebook for qualitative-analysis tools.
- Share with the team (Firestore). Veil stores only the veiled report. Teammates with the link see placeholders; the researcher, whose key never left their laptop, can reveal names on their own device. Firestore rules allow create/get only — no listing, editing or deleting.
Veil installs as an app (PWA) and veils offline. If the on-device model isn't available, raw text is never sent anywhere: the user adds identifiers by hand and confirms a review first. “Exactly what was sent to the cloud” shows the payload interview by interview.
How we built it
- Firebase AI Logic (web SDK) with deliberately separated models: an on-device detector (
InferenceMode.ONLY_ON_DEVICE,onDeviceParams.promptOptions.responseConstraint= JSON schema) and cloud analysts (InferenceMode.ONLY_IN_CLOUD,responseSchemabuilt withSchema.object).initializeDeviceModel()runs on the user's click to start the Gemini Nano download, andinferenceSourceis logged so users can see where every step ran. - One key per study: pure TypeScript functions keep placeholders stable as the key grows across interviews and chunks; chunking keeps each prompt inside Gemini Nano's input limit.
- Cloud Firestore + security rules for veiled team reports; App Check on every cloud call; Firebase Hosting with an offline service worker.
- React + TypeScript + Vite.
- Property-based tests (fast-check) for the core guarantees:
unmask(mask(x)) == x, masked text leaks none of the originals, tokens stay stable chunk by chunk and interview by interview, private notes never reach the payload, and participant codes returned by the cloud are sanitised.
Challenges we ran into
- Chrome reported the Prompt API as “unavailable” until we passed the expected input/output languages to
availability(). We now show a precise status (not enabled / downloadable / downloading / ready). - Small models sometimes return names that aren't in the text — we keep only spans that literally occur in the chunk.
- People are mentioned by first name after the first introduction; mapping name parts to the same token fixed leaks like “Gary said it was policy” while still restoring the full name.
- While recording an early demo, Gemini Nano missed one name on one run and it would have reached the cloud. That's why the deterministic second safety net exists — with tests.
- The cloud model occasionally invented participant codes (e.g. “P6” in a 3-person study). Veil now sanitises codes against the real participant list.
- Deciding what happens when on-device AI is missing: silently falling back to the cloud would defeat the point, so Veil fails closed.
Accomplishments that we're proud of
- A real privacy guarantee rather than a policy: the only model that sees raw words runs locally, and sending is blocked if any known identifier is still present.
- Cross-interview insight from the cloud, with real names restored locally — hybrid inference that makes cloud AI usable for data it could never see before.
- Team sharing where the server holds nothing identifying, and only the key holder's device can reveal names.
What we learned
Hybrid inference is most powerful when each model does the job it's best placed to do: the small local model handles the narrow, sensitive task (spotting identifiers); the large cloud model reasons across the whole study — and the boundary between them is where privacy is enforced and tested.
What's next for Veil
- Korean and other languages for on-device detection.
- Audio input: transcribe interviews on device, then veil.
- Encrypted key backup the researcher controls (passkey), for moving between devices.
- Codebook round-trips with NVivo / ATLAS.ti.
Built With
- chrome-prompt-api
- cloud-firestore
- fast-check
- firebase-ai-logic
- firebase-app-check
- firebase-hosting
- gemini
- gemini-nano
- pwa
- react
- typescript
- vite
- vitest