« All posts

NilaMind: A Fully On-Device 1.5B LLM for Mental Health Support

NilaMind runs Qwen2.5-1.5B via llama.cpp fully offline on Android, with crisis safety enforced by a deterministic, model-independent gate.

NilaMind is an open-source Android app built on the premise that mental-health conversations should never leave the phone. It runs Qwen2.5-1.5B-Instruct, quantized to Q4_K_M, through a natively compiled ARM64 build of llama.cpp bridged via JNI into a React/Capacitor front end. After a one-time, SHA-256-verified model download, the app works entirely offline.

The key engineering decision isn't the model — it's the safety layer, which is deterministic and model-independent. Crisis detection never relies on the LLM's judgment. A regex/keyword scanner and a small MiniLM-based ONNX classifier jointly screen every input and output, and a separate anti-sycophancy rule explicitly blocks the model from validating manic grandiosity or impulsive statements. Any triggered rule replaces the model's reply with a safe fallback, regardless of what was generated.

Voice input is transcribed on-device with Vosk WASM, data is encrypted at rest with AES-256-GCM in IndexedDB, and identity uses a no-account BIP39 recovery phrase instead of cloud accounts. The Apache 2.0-licensed project ships with roughly 2,550 tests across 230+ files.

For engineers, NilaMind is a concrete, inspectable example of separating safety-critical logic from an LLM entirely — enforcing crisis handling through deterministic, auditable rules rather than trusting model behavior in a privacy-sensitive domain.