uaritm/medgemma-4b-cardiology-gguf
MedGemma-4B Cardiology (GGUF)
uaritm — Domain-Finetuned Clinical LLM for Cardiology Based on Google MedGemma-4B-IT
Model Description
MedGemma-4B-Cardiology is a domain-adapted medical language model built on google/medgemma-4b-it and fine-tuned via supervised instruction tuning (SFT) on anonymized cardiology clinical data:
- discharge summaries
- history of illness
- surgical procedures
- treatment pathways
- physician recommendations
The model is optimized for:
- generating clinically grounded cardiology recommendations
- structuring and summarizing medical documentation
- rewriting clinical narratives
- assisting in cardiology decision support
GGUF format ensures compatibility with:
- llama.cpp
- Ollama
- LM Studio
- GPT4All
- koboldcpp
Architecture
- Base model: Google MedGemma-4B-IT
- Parameters: ~4B
- Fine-tuning: LoRA + SFT
- Precision: Q4KM / Q5KM GGUF
- Context window: up to 4096 tokens
Repository Contents
medgemma-4b-cardiology.Q4KM.gguf medgemma-4b-cardiology.Q5KM.gguf tokenizer.json README.md
Usage Examples
llama.cpp
./main -m medgemma-4b-cardiology.Q4KM.gguf \ -p "You are a cardiologist. Based on the clinical details, generate treatment recommendations."
Ollama
Create a file named Modelfile:
FROM ./medgemma-4b-cardiology.Q4KM.gguf TEMPLATE "<startofturn>user\n{{ .Prompt }}\n<endofturn>\n<startofturn>assistant" PARAMETER temperature 0.3
Then run:
ollama create medcardio -f Modelfile ollama run medcardio
Python (llama-cpp-python)
from llama_cpp import Llama
llm = Llama( modelpath="medgemma-4b-cardiology.Q4KM.gguf", nctx=4096, ngpulayers=35, )
prompt = "You are a cardiologist. Patient: 67-year-old male with stable angina. Provide evidence-based recommendations."
output = llm(prompt, max_tokens=400) print(output["choices"][0]["text"])
Prompt Format (MedGemma Chat Template)
The model expects chat-structured input:
<startofturn>user [Your instruction or clinical text] <endofturn> <startofturn>assistant
Example:
<startofturn>user You are a cardiologist. Generate recommendations for: Sex: Male Age: 67 Length of stay: 10 days [discharge summary...] <endofturn> <startofturn>assistant
Fine-Tuning Details
Training dataset included >12,000 cardiology-specific instruction-response pairs:
{ "prompt": "...", "response": "..." }
Converted into Gemma-style messages:
{ "messages": [ {"role": "user", "content": "..."}, {"role": "assistant", "content": "..."} ] }
Training setup:
- LoRA r=16, alpha=32
- BF16 training
- max_length: 2048–4096
- learning rate sweep: 5e-5 → 3e-4
- warmup_ratio: 0.03–0.10
- gradient checkpointing: enabled
- optimizer and scheduler from TRL SFTTrainer
Disclaimer
This model is NOT a medical device and must not be used for autonomous diagnosis or treatment decisions. Outputs require interpretation and verification by certified medical professionals. Intended solely for research and decision-support augmentation.
Limitations
- Optimized for cardiology and cardiac surgery
- Reduced accuracy outside these domains
- No vision capabilities (text-only MedGemma IT)
- May generate incomplete or generalized recommendations
Citing & Authors
If you use this model in your research, please cite:
@misc{Ostashko2025MedGemmaCardiology, title = {MedGemma-4B-Cardiology: A Domain-Finetuned Clinical LLM for Cardiology}, author = {Uaritm}, year = {2025}, url = {ai.esemi.org} }
Project homepage: https://ai.esemi.org
HuggingFace
If you found this model useful — please give a star on HuggingFace:
https://huggingface.co/uaritm/medgemma-4b-cardiology-gguf
