Instructions to use haguman/discharge-navigator-medgemma with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use haguman/discharge-navigator-medgemma with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="haguman/discharge-navigator-medgemma")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("haguman/discharge-navigator-medgemma", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use haguman/discharge-navigator-medgemma with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "haguman/discharge-navigator-medgemma" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "haguman/discharge-navigator-medgemma", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/haguman/discharge-navigator-medgemma
- SGLang
How to use haguman/discharge-navigator-medgemma with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "haguman/discharge-navigator-medgemma" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "haguman/discharge-navigator-medgemma", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "haguman/discharge-navigator-medgemma" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "haguman/discharge-navigator-medgemma", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use haguman/discharge-navigator-medgemma with Docker Model Runner:
docker model run hf.co/haguman/discharge-navigator-medgemma
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}
}