🌟 Inspiration India carries the world's highest antimicrobial resistance (AMR) burden — nearly 300,000 people die every year from antibiotic-resistant infections. The crisis is worst in rural clinics, where there is no pharmacist, no internet connectivity, and no clinical guidance at the point of care. Doctors are forced to prescribe antibiotics based on intuition, fueling further resistance. As a pharmaceutical scientist working in India, this gap between evidence-based antibiotic stewardship and ground-level healthcare reality was deeply personal. The Kaggle Gemma 4 Good Hackathon presented the perfect opportunity to build a solution that is both clinically meaningful and technically ambitious.

💡 What it does AMS-Gemma4 is a fully offline clinical decision support tool for antibiotic stewardship, designed specifically for rural Indian hospitals. A healthcare provider enters patient details — age, weight, serum creatinine, infection site, and culture report — and the system:

Calculates Creatinine Clearance (CrCl) using the Cockcroft-Gault formula to assess renal function

Applies a Safety Gate that automatically rejects contraindicated antibiotics (e.g., Nitrofurantoin is blocked when CrCl < 60 mL/min)

Classifies antibiotics using WHO AWaRe 2023 tiers (Access / Watch / Reserve)

Looks up India-specific resistance patterns from ICMR data — not generic global statistics

Outputs clinical reasoning in both English and Tamil, making it accessible to local healthcare workers

Supports upload of culture report photos using Gemma 4's multimodal capability

All patient data stays on-device. No internet. No cloud. Just a clinician, a laptop, and reliable AI guidance.

🔧 How we built it Model: Gemma 4 E2B, run locally via Ollama on an 8GB MacBook M1

Native Function Calling: Before Gemma generates any reasoning, Python functions are called to compute hard clinical facts:

calculate_crcl() — Cockcroft-Gault renal function calculator

check_aware_tier() — WHO AWaRe 2023 antibiotic classification

lookup_resistance() — ICMR India-specific resistance lookup

Stack:

app.py — Gradio-based web UI (runs at localhost:7860)

inference.py — Gemma 4 E2B inference pipeline via Ollama

function_calling_v2.py — native function calling orchestration

functions.py — clinical calculation library

prompts.py — master prompt engineering (English + Tamil)

cases.json — validated clinical test cases

Multilingual output was achieved through prompt engineering using Gemma 4's 140+ language support, producing structured Tamil clinical reports.

🚧 Challenges we ran into Offline constraint was real: Making Gemma 4 E2B run reliably on 8GB RAM with consistent output quality required careful prompt design and temperature tuning.

Safety gate logic: Ensuring the model never overrides a Python-computed contraindication — even when Gemma's reasoning suggested otherwise — required strict prompt guardrails.

Tamil clinical output: Medical terminology in Tamil has no standard — we had to engineer prompts that produced clinically coherent Tamil text without hallucinated terms.

AWaRe miscategorization: Early versions occasionally misclassified Watch-tier antibiotics; this was resolved by grounding classification entirely in the Python check_aware_tier() function before prompting.

Function calling orchestration: Ensuring Gemma 4 correctly triggers and uses the output of all three functions in the right sequence took multiple prompt iterations.

🏆 Accomplishments that we're proud of ✅ 4/4 clinical test cases passed — including ESBL Klebsiella, MRSA, and renal-impaired UTI scenarios

✅ Safety gate is 100% reliable — Nitrofurantoin correctly rejected in all renal-impaired cases

✅ First offline AMS tool with Tamil output — a genuine first for rural Tamil Nadu healthcare

✅ Runs on a basic 8GB laptop — truly accessible hardware, not just a demo on a GPU cluster

✅ Full chain-of-thought reasoning — clinicians can see why a drug was chosen or rejected, building trust in AI-assisted decisions

✅ Live demo deployed on Hugging Face Spaces for hackathon judges

📚 What we learned Gemma 4's native function calling is a game-changer for safety-critical medical AI — it allows hard clinical facts to be computed in Python and passed to the model, preventing hallucination of dosage or renal thresholds.

Prompt engineering for multilingual clinical output is non-trivial — structure and formatting matter as much as translation.

Edge deployment (Ollama + Gemma 4 E2B) is genuinely viable for healthcare AI in resource-constrained settings.

Clinical validation with real test cases is essential — "it looks right" is not good enough in medicine.

🚀 What's next for AMS-Gemma4: Offline Antibiotic Stewardship AI Expand language support — add Telugu, Hindi, and Kannada for broader rural coverage across India

Integrate full ICMR antibiogram database — move from sample resistance data to the complete national dataset

Voice input — allow doctors to dictate patient details hands-free in clinical settings

Pediatric dosing module — extend CrCl and dosing calculations for pediatric patients

Pilot deployment — partner with a rural PHC (Primary Health Centre) in Tamil Nadu for real-world validation

Offline culture report OCR — process printed lab reports without manual data entry

Drug interaction checker — flag dangerous combinations before finalizing a prescription

Built With

Share this project:

Updates