CoolFace
Modelpublic

muthuk1/saheli-gemma4-e4b-medical

sourceHugging Faceapache-2.0updated 5mo agoView on Hugging Face
1likes
Model Card

๐Ÿฅ SAHELI v2 โ€” Gemma 4 E4B Medical Fine-Tune

Smart Adaptive Health Engine for Local Intelligence

A LoRA fine-tune of Google Gemma 4 E4B-it with 7 technical novelties for clinical decision support in low-resource settings.

7 Novel Features

#NoveltyDescriptionBased On
1Transparent Reasoningenable_thinking=True shows step-by-step clinical reasoning chainsArgMed-Agents (arxiv:2403.06294)
2FHIR Function CallingNative tool use generates HL7 FHIR R4 records with ICD-10 codesMedAgentBench (arxiv:2501.14654)
3Semantic RAGGTE-small + FAISS vector search over 11 WHO guideline areasMIRAGE (arxiv:2402.13178)
4Multi-Agent Triage3-tier severity routing adapts response depth to case complexityMDAgents (NeurIPS 2024, arxiv:2404.15155)
5MultimodalSingle model handles text + images + audio (no separate pipelines)Gemma 4 native
6Medical BenchmarksEvaluated on MedQA, MedMCQA, PubMedQA, AfriMed-QA v2โ€”
7Edge DeploymentGGUF Q4KM for Ollama/llama.cpp on $150 Android phoneโ€”

Model Details

PropertyValue
Base Modelgoogle/gemma-4-E4B-it (8B params, 4.5B effective)
MethodQLoRA (4-bit NF4) via Unsloth + TRL SFT
LoRA Rank16, Alpha 16
Target Modulesq/k/v/oproj, gate/up/downproj
Training Epochs3
Learning Rate2e-4 (cosine)
Max Seq Length2048
OptimizerAdamW 8-bit

Training Data

DatasetSizePurpose
FreedomIntelligence/medical-o1-reasoning-SFT~31MBChain-of-thought clinical reasoning
lavita/medical-qa-datasets148MBBroad medical QA dialogues

Architecture

Patient Input (Voice / Photo / Text)
     |
[Complexity Triage] โ†’ LOW / MODERATE / HIGH
     |
[Gemma 4 E4B + Thinking Mode] โ†’ Clinical reasoning
     |
[Semantic RAG: GTE-small + FAISS] โ†’ WHO guidelines
     |
[Function Calling: FHIR Tools] โ†’ Structured records
     |
Answer + Reasoning Chain + FHIR JSON + Triage Level

Files

FileDescription
train_saheli.pyComplete fine-tuning script (Unsloth + TRL)
app_v2.pyEnhanced Gradio app with all 7 novelties
eval_benchmarks.pyMedical benchmark evaluation (MedQA/MedMCQA/PubMedQA/AfriMed-QA)
ModelfileOllama deployment config
setup.shOne-command setup
KAGGLE_WRITEUP.mdHackathon submission writeup

Quick Start

python
from transformers import AutoProcessor, AutoModelForCausalLM

model = AutoModelForCausalLM.from_pretrained("google/gemma-4-E4B-it", dtype="auto", device_map="auto")
processor = AutoProcessor.from_pretrained("google/gemma-4-E4B-it")

messages = [
    {"role": "system", "content": "You are SAHELI, a medical AI for community health workers."},
    {"role": "user", "content": "2-year-old, cough 3 days, breathing fast 52/min, temp 38.5C"}
]

# With thinking mode
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=True)
inputs = processor(text=text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=1024, temperature=1.0, top_p=0.95, top_k=64)
response = processor.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=False)
parsed = processor.parse_response(response)
print("Thinking:", parsed.get("thinking", ""))
print("Answer:", parsed.get("answer", ""))

Links

ResourceURL
Live DemoHF Spaces
ModelHuggingFace
Base ModelGemma 4 E4B-it

Hackathon Tracks

Main Track | Health & Sciences | Digital Equity | Safety & Trust | Unsloth | Ollama | llama.cpp

License

Apache 2.0 (following base model)