Onira: on-device self-hypnosis scripts from a 2B model on Android
- Hardware
- Test phones: 6 GB Galaxy S20 FE and Pixel 7 (7.6 GB RAM)
- Models & engines
- Runtime: llama.cpp over a JNI bridge on Android
Model: hypnos-e2b-enfres, a Gemma 4 E2B fine-tune pruned to English, French and Spanish, Q4_K_M GGUF - Key gotcha
- Turning mmap off makes the weights 1.7 GB of memory the kernel can never reclaim.
What they built
Charles-Antoine Fournel describes how Onira writes a self-hypnosis session on the phone with a 2-billion-parameter model. On a phone that can run it, nothing typed or generated leaves the device and the app works in airplane mode.
The first version ran stock Gemma 4 E2B through LiteRT-LM on the CPU, which copied the weights into anonymous memory: on a Pixel 7 it filled zram and was killed in the background, and on a 6 GB Galaxy S20 FE it was killed mid-load three runs out of three.
Switching to llama.cpp with a memory-mapped Q4_K_M GGUF, over a small JNI bridge, made it fit. The fine-tuned model, hypnos-e2b-enfres, is published under Apache-2.0 on Hugging Face.
Setup
- Runtime: llama.cpp over a JNI bridge on Android
- Model: hypnos-e2b-enfres, a Gemma 4 E2B fine-tune pruned to English, French and Spanish, Q4_K_M GGUF
- Test phones: 6 GB Galaxy S20 FE and Pixel 7 (7.6 GB RAM)
- Sampling: temperature 1.0, top-k 64, top-p 0.95, no repetition penalty
How it works
- mmap stays on and the large per-layer embedding table is read lazily, so the kernel can drop and reload weight pages.
- Weight repacking is only switched on from 7 GB of RAM; threads are set to the performance cores minus one.
- The session is an ordered list of blocks: a pre-written induction, then generated deepening, metaphor, suggestions and anchoring, then a pre-written return. Block N+1 generates while block N is read aloud.
- Each block is a single-turn prompt with the KV cache cleared, keeping context at 2,048 tokens.
- Listener restrictions (such as no breathing cues) are enforced by banning tokens with a logit bias in the llama.cpp sampler, and a deterministic check runs on what the listener types before generation.
Results & numbers
- On the Galaxy S20 FE: about 1.6 GB resident while generating (0.31 GB anonymous), and 111 MB once the model is unloaded.
- 3.8-5.0 words per second depending on repacking, with a body block about every 100 seconds, faster than narration.
- Token bans gave zero violations on a 120-prompt held-out set, versus breaking the rules in roughly 10-40% of restricted prompts with prompt rules alone.
- Single-turn blocks produced 0.9 duplicated sentences against 6.3 for an accumulated conversation in a simulated four-block session.
Gotchas
- Turning mmap off makes the weights 1.7 GB of memory the kernel can never reclaim.
- More threads were slower: 8 threads ran at a third of the speed of 3.
- Without an explicit allocator purge, about 1.2 GB of freed model memory stayed in the process after unloading.
- Lower sampling temperatures made repetition loops more frequent, not less.
- Sizing scripts by word count produced 90-minute sessions for some listeners; the plan is now built from a target duration.
- Banned token ids belong to the model's vocabulary, so the list must be regenerated whenever the model file changes.
“Speed turned out to be the easy part.”— Charles-Antoine Fournel
Similar setups
Verso: Gemma 4 on an Android phone writes the back of old family photos without inventing names
Fahad Irshad built Verso, an Android app with no internet permission where Gemma 4 E2B writes a title and caption for an old photo from your answers, and asks a question instead of guessing when a fact is missing.
Link Séance: a local Gemma 3 writes grounded epitaphs for the dead links in your bookmarks
Abdul AmberNeel built a command-line tool that checks every link in a bookmarks file, finds the last living Wayback Machine snapshot of dead ones, and has a local Gemma 3 write a two-sentence epitaph only from what the archive kept.
Memoria: local Whisper and Gemma 3 4B turn a family voice memo into a keepsake
Jeffrey Turov built Memoria, an oral-history archivist that transcribes a family voice memo with Whisper and has Gemma 3 4B in llama.cpp pull out people, places, themes, verified quotes and follow-up questions, all on a local CPU.
Offline chat on desktop or Android via Termux with Prefrontal
A privacy-first chat UI that works with Ollama on desktop or llama.cpp anywhere, including Android through Termux. No telemetry, no subscriptions.