Jun 2, 2026
What's new in NativeLM v0.5.0: open, highlight, zoom, OCR, better retrieval
v0.4 made on-device document chat work. v0.5 makes it usable — tap a citation to open the source at the exact page with the passage highlighted, pinch to zoom, chat with scans, and get sharper answers. Plus the bugs we fixed along the way.
NativeLM v0.4 proved you could run document RAG entirely on a phone. v0.5 is about making it something you’d actually use every day: you can now open the source behind an answer, see exactly which passage it came from, zoom in to read it, chat with scanned documents, and the retrieval is sharper. Still fully local — no upload, no account, no telemetry.
Here’s everything in the release, and the bugs that came with it.
Open the source behind an answer
Grounded answers have always shown Sources chips. Now they’re tappable: tap one and NativeLM opens the cited PDF at the exact page, using Android’s built-in PdfRenderer — no third-party PDF dependency.
The catch was durability. The Android document picker hands back a content:// URI that’s only valid for the import session, so a citation tapped days later would point at nothing. We now copy imported files into app-private storage at import time, and a citation resolves against that durable copy. (It never leaves the sandbox — the no-upload promise holds.)
See the exact passage — highlighted in place

A citation doesn’t just open the right page; it highlights the cited passage on the page. We re-parse the page with PDFBox, take each glyph’s position, find the cited text, union the matched glyphs into per-line rectangles, and paint them onto the rendered bitmap — so the highlight lines up pixel-for-pixel with the text, at any zoom. Rotated or scanned pages (which have no glyph geometry) fall back to a “cited passage” callout, so it’s never worse than before.
Pinch to zoom
The viewer is now a proper reader: pinch-to-zoom (1×–5×), pan, and double-tap to toggle fit. Dense, fine-print pages — exactly the kind you need to verify a citation on — are finally legible.
Citations that persist
Reopen a saved grounded chat and the source chips are still there. Citations are now stored with the message, so your sources survive across sessions instead of vanishing when you leave the chat.
Chat with scans and photos
NativeLM now reads scanned PDFs and images with on-device OCR (ML Kit’s bundled model — the image never leaves the phone). A PDF page with no text layer is rendered and OCR’d automatically, so mixed digital/scanned PDFs just work. This is the big one for confidential, scan-heavy documents — there’s a full write-up here.
Sharper retrieval
Answers now use hybrid retrieval — semantic vector search blended with BM25 keyword matching via Reciprocal Rank Fusion — so exact terms (names, codenames, IDs) get found even when the small on-device embedder ranks them poorly. (Also covered in the OCR post, since OCR is what surfaced the gap.)
The bugs we fixed
Shipping all this turned up the usual crop of real-device-only landmines:
- A release-only crash from citation persistence. Adding a column to the messages table, the app crash-looped — but only in release, only on chats saved before the column existed. ObjectBox doesn’t apply Kotlin default values to a newly-added property on pre-existing rows, so old rows read back
nullinstead of"", tripping a non-null check. Fix: make the column nullable and treat null as empty. Unit tests passed throughout — only a migrated database hit it. - A blank screen on back-press. Backing out of the PDF viewer double-popped the navigation stack (clearing the view target re-triggered a guard), landing on a blank screen. Fixed by snapshotting the target for the screen’s lifetime.
- R8 stripping OCR. Like the MediaPipe logger trap from v0.4, ML Kit needed ProGuard keep rules so on-device OCR survives minification in the release build.
- OCR that worked but didn’t retrieve. A freshly-OCR’d chunk was correct but ranked below a thousand unrelated chunks under the coarse 100-dim embedder — which is exactly what motivated hybrid retrieval above.
Every one of these only showed up on a real device in a real (minified, persisted, multi-document) state — which is why each feature in this release was verified on-device, not just unit-tested.
Try it
NativeLM v0.5.0 is live — open source, AGPL-3.0, no telemetry, no account, no upload.
- Source: the litertlm-kmp repository.
- Grab the signed APK and try it on your own documents.