What Google's AMIE does in the cloud — offline, in Tamil, on a ₹8,000 phone.
HuggingFace model: philip11/xphil-gemma-4-E4B
pip install torch transformers unsloth bitsandbytes accelerate sentencepiece pillow
python inference/xphil_inference.pyWith a medical image:
python inference/xphil_inference.py --image knee_xray.jpg --question "What is wrong with this knee?"ollama run philip11/xphil-gemma-4-E4BOr with GGUF from HuggingFace:
# Download GGUF
huggingface-cli download philip11/xphil-gemma-4-E4B gguf/xphil-e4b-Q4_K_M.gguf
# Create Ollama model
ollama create xphil -f deploy/Modelfile
ollama run xphil "My mother has memory problems. She now has fever. What should I do?"train/ # QDoRA fine-tuning scripts (Unsloth, Gemma 4 E4B)
inference/ # Minimal inference example
eval/ # Evaluation harness (MedQA, PubMedQA, ARC, safety, Tamil)
deploy/ # GGUF export, LiteRT convert, HF upload, Modelfile
No LLM imagined any training data.
Standard medical LLMs train on LLM-generated patient-doctor dialogues — hallucination is baked into the training data itself. xphil uses Truth-Grounded Reality Distillation:
- L1: Real measured humans (cognitive decline, radiology, ICU, speech, mental health)
- L2: Deterministic Python extracts structured capability JSON — zero LLM
- L3: Teacher LLM translates the JSON — cannot invent. Every claim traces to a field.
Result: ECE < 0.12 becomes trainable (confidence_range is a field). Hallucination is structurally blocked at Gate 2, not just statistically reduced.
Base: unsloth/gemma-4-E4B-it
Method: QDoRA (QLoRA + DoRA + PiSSA init)
Steps: 900 | Loss: 0.758 | Hardware: NVIDIA H200 139.8GB | Time: 96 min
Params: 41,222,144 trainable (0.51% of 8.04B)
See train/train_e4b_h200.py for the exact training config.
- Unsloth: QDoRA fine-tune, adapter published
- llama.cpp / Ollama: GGUF Q4_K_M (5GB) published
- Health & Sciences: Dementia + knee OA + chest X-ray clinical reasoning
- Digital Equity: Madurai Tamil, ₹8K phone, ₹0 cost, offline
Apache 2.0 — see LICENSE. Base model Gemma 4 subject to Gemma Terms of Use.