Offline RAG that never leaves the phone
We built retrieval-augmented generation that never leaves the handset — local embeddings, an encrypted vector index and a local model. Here is what that costs and how we proved it stays offline.
Most "private AI" features are private in the sense that a privacy policy says so. The documents still get uploaded, embedded by a hosted model and stored in somebody's vector database. We wanted the version where that is structurally impossible: the user's own files are indexed and answered from on the phone, and the network is not involved at all.
This is how DigitMind Private Brain works inside DigitMind AI on Android, what it costs in device resources, and how we checked that the offline claim is true rather than aspirational.
The pipeline
Everything below happens on the handset:
question
→ on-device embedding engine
→ 768-dimensional vector, normalized to its leading 256 dimensions
→ exact local vector search over the encrypted index
→ the matching source passages
→ on-device model, streaming tokens
→ answer with references back to the user's own sourcesThere is no remote fallback in local mode. No hosted embedding request, no automatic upload of private content, and no "we'll just call the cloud if the device struggles" shortcut. If a step cannot run on the device, it fails visibly instead of silently leaving.
Choosing a runtime, not a hype cycle
The interesting constraint is that a RAG pipeline needs two models: an embedding model for indexing and retrieval, and a generative model for the answer. Maintaining two runtimes, two tokenizers and two sets of device quirks is where this kind of feature usually dies.
We compared three options before writing integration code:
- LiteRT-LM exposes both an embedding engine and a generation engine in one stack, loads the artifacts we need and is Apache-2.0. One integration, one set of device behaviours.
- ONNX Runtime is a maintained MIT-licensed embedding alternative, but it would need separately compatible model conversion and tokenization plus a second runtime for generation.
- llama.cpp is a maintained MIT-licensed option in GGUF, at the cost of owning a JNI/NDK integration and evaluating model formats ourselves.
We selected LiteRT-LM 0.19.0 and verified the exact artifact rather than trusting the coordinates: we downloaded the AAR, recorded its SHA-256, checked the manifest minimum SDK, the shipped ABIs, the Kotlin metadata version and the bytecode level. That last one mattered — the AAR carries Java 21 classes, which is why the build needs JDK 21 or newer even though the app itself still targets Java 17 bytecode.
Model downloads are pinned the same way. The trust root is a catalogue compiled into the signed APK, not a URL fetched at runtime, and every entry pins an immutable revision with an expected byte count and SHA-256. The installer streams the download, verifies size and digest before anything is handed to native code, and activates atomically — a cancelled or corrupted download never replaces an installed file.
The index is derived data, and it says so
A local vector index is a cache of the user's documents, and caches go stale in ways that are invisible until an answer cites something that no longer exists. Ours is versioned and encrypted in its own vault slot with its own key, and it is bound to four things:
- the vault identity, so another account cannot read it,
- a fingerprint of the source content,
- the prompt profile used when embedding,
- the exact SHA of the embedding model.
Change any of them — edit a document, exclude it, sign in as someone else, swap the encoder — and the index is invalidated rather than quietly reused. A corrupt derived index is rebuilt from the sources. The sources themselves are never overwritten as a recovery shortcut, because they are the only copy the user has.
Device reality
The honest part of on-device AI is the resource budget. Ours is explicit:
- roughly 512 MiB of available memory is required before the embedding engine opens, and roughly 2.5 GiB before generation,
- the ABI is checked first, because a model that cannot load is a better error than a crash,
- the two engines are opened sequentially and closed after use rather than kept resident,
- cancellation propagates into native generation, so leaving the screen actually stops the work,
- a vault holds up to 25 sources, 256 KiB per source and 512 indexed chunks.
Those memory numbers are conservative guards, not measured peak-RSS guarantees. They exist so that a mid-range phone refuses clearly instead of being killed by the system halfway through an answer.
Proving it is offline
A claim like "this never touches the network" is testable, so we test it rather than assert it. The device test APK is built without the INTERNET permission and runs the production source files, not stand-in algorithms. If any part of the pipeline reached for the network, it could not succeed.
On a connected Samsung SM-A325F running API 33, real embedding inference retrieved the correct source for English, Russian and Kazakh fixture queries, and the encrypted vault, account isolation, draft recovery and index invalidation after a deletion all behaved. On an ARM64 emulator, the same permission-less APK ran real generation end to end and produced an answer with the expected citation.
That is functional evidence, not a performance or thermal certification, and we describe it that way internally too.
Grounding, and what a citation actually proves
Generation refuses to answer from empty evidence, and output with a missing or out-of-range citation number is withheld rather than shown. Citation links open the user's local source.
It is worth being precise about what this buys: it verifies that references exist and point somewhere real. It does not verify factual entailment between the passage and the sentence citing it. Treating retrieved documents as untrusted input — including against prompt injection hidden inside a user's own files — is a separate problem, and grounding quality remains a release gate rather than a solved item.
Where it stands
Private Brain is implemented on Android and validated on a physical device: encrypted import, real on-device embeddings, a persistent encrypted vector index, model downloads, and local answers with citations. It has not been released to Google Play yet.
We would rather describe it that way than ship a page claiming a finished feature. The engineering is real; the release gate is grounding quality, and that is not a date you can promise.
