I put an LLM on the phone and gave it no numbers
Rekhon3 min read
There is a language model inside the app, and it has never been given a figure to compute.
Compiled from the repository’s decision records and changelog rather than written as a first-person account. The reasoning is the project’s; the summarising is editorial. The record itself is linked at the end.
Rekhon's assistant answers in sentences, and for most of the project those sentences came from TemplateLlmEngine: ten fixed forms from strings.xml, every slot filled from a figure an engine computed. The pipeline around it already ran plan, tools, verbalise, guardrail. The verbalise step was a when over ten templates where a model was meant to be. ADR-0079, dated 10 October 2026, records the model arriving.
It writes the words, never the numbers
OnDeviceLlmEngine implements the same one-method LlmEngine interface the templates do, so nothing above it changed. It receives the intent and the tool figures, nothing else, and the figures arrive already rendered, Indian grouping and all (₹1,23,456.78), by a pure function a test checks character by character. The model has nothing to compute.
Its reply then passes two checks in order. DraftSanitiser refuses any digit that is not inside a value the prompt supplied, and the guardrail engine does what it always did. A rounded figure is refused as firmly as an invented one: ₹61,000 is a different claim from ₹61,427.00.
Which runtime, which weights
The weights run on MediaPipe's LLM Inference API (tasks-genai 0.10.35, Apache-2.0). LiteRT-LM is Google's successor, but it was pre-1.0, and the Apache-2.0 model in its format came only from third-party mirrors. llama.cpp is the most open option and publishes no Android artifact, which would have meant an NDK build and a JNI layer across four ABIs for a solo project to own.
MediaPipe won on one point: the Apache-2.0 weights are published in its format by the people who built the runtime, so nothing has to be converted or trusted on the way. The bet is hedged behind an internal LlmRuntime interface, so moving to LiteRT-LM is one new class and one catalog line.
The model is Qwen2.5-0.5B-Instruct, 521 MB, Apache-2.0. A Gemma-class model of the same size would run as well, but it comes with Google's own terms, and in an AGPL-3.0 repository that promises privacy the licence page is the first thing anyone reads. Apache-2.0 weights can be forked and shipped with no further permission.
Installed by a person, not downloaded
521 MB cannot go in an APK (Play's limit is 200 MB), and the app makes no network call on a core path, so it does not download the weights either. A script on a connected machine downloads the file, verifies it and pushes it into app-private storage. LlmModelStore then refuses anything with the wrong length or digest, because a half-downloaded model fails inside the native library in ways no Kotlin can explain.
The presence of a verified file is the opt-in.
The templates stay the default
SelectingLlmEngine uses the model only with verified weights, an English-language device and no recent run of failures. The template sentences are translated into Hindi, Kannada and Tamil; the model is English-tuned, so on a Hindi phone the deterministic engine is the better answer. After three failures the process stops asking, and LlmEngine.id names the model that wrote each reply, template or on-device.
The record lists the costs plainly. The native library took the universal release APK from 62 MB to 171 MB, measured, though an arm64 phone downloads about 27 MB more. The model is not bit-reproducible, which is why both checks run on everything it writes. And most phones will never have the weights, which is why the templates were never removed.