Medical Digital Twin v1 πŸ«€

A fine-tuned medical AI assistant trained using GRPO (Group Relative Policy Optimization) on Google's MedGemma-4b.

Model Description

This model acts as a Medical Digital Twin - simulating physiological reasoning processes before providing medical responses. It's designed to bridge the gap between patient data and clinical decision-making.

Key Features

  • 🧠 Structured Reasoning: Shows clinical thinking process using <think> tags
  • πŸ‘₯ Dual Mode: Empathetic patient communication + technical physician support
  • 🎯 Accuracy-Focused: Trained with semantic similarity rewards
  • ⚑ Efficient: 4-bit quantization, LoRA fine-tuning

Training Details

  • Base Model: google/medgemma-4b-it (4B parameters)
  • Method: GRPO (Reinforcement Learning from Human Feedback)
  • LoRA Rank: 32
  • Training Steps: 200
  • Dataset: 500 medical Q&A examples with reasoning chains
  • Reward Functions:
    1. Format reward (encourages structured reasoning)
    2. Semantic reward (measures answer accuracy)

Usage

from unsloth import FastLanguageModel

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="AhmedSSoliman/medgemma-4b-digital-twin-v1",
    max_seq_length=2048,
    dtype=None,
    load_in_4bit=True,
)
FastLanguageModel.for_inference(model)

# Chat format
messages = [
    {"role": "system", "content": [{"type": "text", "text": "You are a Medical Digital Twin AI."}]},
    {"role": "user", "content": [{"type": "text", "text": "I have chest pain radiating to my left arm."}]}
]

inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to("cuda")
outputs = model.generate(inputs, max_new_tokens=1024, temperature=0.6)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Example Output

Input: "I have chest pain radiating to my left arm."

Output:

<think>
This presentation is concerning for acute coronary syndrome (ACS). Classic signs:
- Chest pain with left arm radiation (angina pattern)
- Requires immediate evaluation for myocardial infarction
- Time-sensitive condition requiring emergency protocols
</think>

⚠️ URGENT: These symptoms suggest a possible heart attack. You need immediate medical attention:

1. Call 911 or go to the nearest emergency room NOW
2. Do not drive yourself - have someone drive you or call ambulance
3. If you have aspirin, chew one 325mg tablet while waiting
4. Stay calm and avoid physical exertion

This is a medical emergency requiring immediate professional evaluation with ECG and cardiac biomarkers.

Limitations

⚠️ Critical Disclaimers:

  • This model is for research and educational purposes only
  • NOT a substitute for professional medical advice
  • NOT validated for clinical use
  • Should NOT be used for diagnosis or treatment decisions
  • Always consult qualified healthcare providers

Evaluation Metrics

On medical reasoning test suite:

  • Keyword Coverage: ~75% semantic match
  • Reasoning Usage: 100% of responses show thinking process
  • Safety Referrals: 85% appropriately recommend professional care

Citation

@misc{medgemma-digital-twin-2024,
  author = {AhmedSSoliman},
  title = {Medical Digital Twin v1},
  year = {2025},
  publisher = {Hugging Face},
  howpublished = {\url{https://huggingface.co/AhmedSSoliman/medgemma-4b-digital-twin-v1}}
}

License

This model inherits the MedGemma Terms of Use. Please review these terms before use.


For code and training scripts, visit: GitHub Repository

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for AhmedSSoliman/medgemma-4b-digital-twin-v1

Adapter
(39)
this model

Dataset used to train AhmedSSoliman/medgemma-4b-digital-twin-v1