On-device medical search for nurses and midwives in Zanzibar — offline RAG with Gemma 4 on Android
# MAM-AI
On-device medical search for nurses and midwives in Zanzibar
Demo video · Live web demo · Eval Report · Latency Report
---
Android app that answers clinical questions offline using on-device RAG — Gemma 4 E4B (LiteRT-LM) for generation, EmbeddingGemma-300M for embeddings, SQLite for vector search. English only. No internet needed after the initial ~3.8 GB model download.
**🏥 Try the live web demo** — a faithful, browser-based mirror of the on-device app (same Gemma 4 + G1 prompt + EmbeddingGemma RAG, served via llama.cpp). Demonstration only — not medical advice; don't read latency from it. (demo source)
## Architecture
```
┌─────────────────────────────────────────────────┐
│ Flutter UI (Dart) │
│ intro_page.dart · search_page.dart │
├──────────────┬──────────────────────────────────┤
│ MethodChannel│ EventChannel (streaming) │
├──────────────┴──────────────────────────────────┤
│ Android Native (Kotlin) │
│ MainActivity.kt · RagStream.kt │
│ ┌────────────────────────────────────────────┐ │
│ │ RagPipeline.kt │ │
│ │ ┌──────────┐ ┌──────────┐ ┌────────────┐ │ │
│ │ │ Gemma 4 │ │ Embedding│ │ SQLite │ │ │
│ │ │ LiteRT-LM│ │ Gemma │ │ VectorStore│ │ │
│ │ └──────────┘ └──────────┘ └────────────┘ │ │
│ └────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────┘
```
Query → EmbeddingGemma embeds → SQLite retrieves top-3 guideline chunks → prompt assembled → LiteRT-LM streams response → Flutter renders markdown.
## Build & Run
Requires a real Android device (LiteRT-LM needs hardware acceleration, not emulators).
```bash
cd app
flutter pub get
flutter run # debug on connected device
flutter build apk # release APK
adb logcat -s mam-ai # timing, memory, inference logs
```
## Install
MAM-AI ships as a signed Android APK (it is **not** on …