Discharge Navigator β MedGemma 4B Application
Model Description
Discharge Navigator is a prompt-engineering application built on google/medgemma-4b-it, Google's HAI-DEF (Health AI Developer Foundations) model for clinical text understanding.
This is not a fine-tuned model. No custom weights are provided. This repository documents the prompt engineering methodology, evaluation results, and schema validation pipeline that transform MedGemma 4B into a clinical discharge note extraction system.
Base Model Lineage
| Component | Details |
|---|---|
| Base model | google/medgemma-4b-it |
| Quantized variant | williamljx/medgemma-4b-it-Q4_K_M-GGUF (for edge/CPU) |
| Parameters | 4B |
| Precision | bfloat16 (GPU) / Q4_K_M GGUF (CPU) |
| Fine-tuning | None β prompt engineering only |
Intended Use
Extract structured discharge packets from clinical notes, producing:
- Diagnoses with candidate ICD-10 codes and confidence levels
- Medications with dosing details (dose, route, frequency)
- Follow-up instructions with urgency levels
- Red flags requiring immediate attention
- Missing information gaps with severity ratings
- Evidence spans grounding each claim to exact source text
Not a medical device. All outputs require clinician review before clinical use.
Prompt Engineering Approach
Dual-Variant Strategy
The system uses two prompt variants with a retry escalation strategy:
| Attempt | Variant | Temperature | Strategy |
|---|---|---|---|
| 1 | A (contract-style) | 0.0 | Detailed role + rules + schema |
| 2 | A (contract-style) | 0.1 | Slight randomness for diversity |
| 3 | B (strict fallback) | 0.0 | Minimal prompt, brevity-focused |
Key Prompt Design Principles
- Schema-first extraction β prompt specifies exact JSON structure with all field names, types, and allowed enum values
- Evidence grounding mandate β every extraction must include
evidence_spansthat are exact substrings of the source note (max 20 words, max 5 per item) - Confidence calibration β three-level confidence (low/medium/high) with explicit instructions to use "low" when uncertain
- Negative instructions β "DO NOT GUESS. If it is not in the note, do not include it."
Schema Validation Gate
All model outputs pass through a Pydantic v2 schema (DischargePacket) that enforces:
- Required fields: diagnoses, medications, followups, red_flags, patient_summary, missing_info
- Enum constraints: confidence (low/medium/high), urgency (routine/soon/urgent)
- Evidence span caps: max 5 spans per item, max 20 words per span (adaptive token budget)
- Type coercion for common LLM output quirks (null strings, missing lists)
Invalid outputs are rejected and retried. No malformed data reaches consumers.
Evaluation Results
Evaluated on 50 clinical notes from MTSamples (CC0 license), CPU-only inference.
| Metric | Value | Status |
|---|---|---|
| Parse rate (valid JSON) | 92% (46/50) | PASS |
| Median latency (CPU) | 34s | PASS |
| Diagnosis grounding | 94.4% | PASS |
| Medication grounding | 94.5% | PASS |
| Overall grounding | 87.5% | PASS |
| Follow-up grounding | 76.1% | IMPROVING |
Failure Analysis
4/50 notes failed structured parsing:
- 3 token limit truncation (output exceeded 4096 tokens)
- 1 missing required field (
missing_infoomitted)
All failures were caught by the schema validation gate before reaching consumers.
Inference Backends
| Backend | Environment | Model ID | Size |
|---|---|---|---|
| HuggingFace Transformers | Kaggle T4 GPU | google/medgemma-4b-it | ~8 GB (bf16) |
| Ollama (GGUF) | Local CPU / Edge | williamljx/medgemma-4b-it-Q4_K_M-GGUF | 2.5 GB |
The GGUF quantization enables fully offline, air-gapped deployment on consumer hardware β no GPU, no internet required.
India Context
Designed for resource-constrained healthcare settings:
- 48M hospitalizations/year in India
- 1:11,000 doctor-to-patient ratio in rural areas
- Zero internet dependency enables rural deployment
- CPU-only inference runs on standard hospital workstations
Links
Citation
@misc{discharge-navigator-2026,
title={Discharge Navigator: Offline Clinical Discharge Note Extraction with MedGemma},
year={2026},
url={https://github.com/LegenDairy93/discharge-navigator}
}