Downloads · 30 days
9
8% of all-time downloads
AhmedSSoliman/octomed-7b-digital-twin-v1
octomed-7b-digital-twin-v1 is a text generation model from AhmedSSoliman. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
A medical reasoning AI fine-tuned with GRPO (Group Relative Policy Optimization) for transparent clinical decision support. This model extends OctoMed's multimodal medical capabilities with enhanced reasoning chains.
Downloads · 30 days
9
8% of all-time downloads
All-time downloads
107
Public
Repo size
392 MB
Likes
1
Public
Click a slice to open those files.
.safetensors381 MB · 96%
From the Hugging Face model README
A medical reasoning AI fine-tuned with GRPO (Group Relative Policy Optimization) for transparent clinical decision support. This model extends OctoMed's multimodal medical capabilities with enhanced reasoning chains.
OctoMed-7B Digital Twin v1 is a 7-billion parameter medical language model fine-tuned using reinforcement learning from human feedback (RLHF). Built on top of OctoMed-7B, a state-of-the-art multimodal medical model, this variant specializes in:
<think>...</think> tags to show step-by-step clinical reasoning| Component | Specification |
|---|---|
| Base Model | OctoMed/OctoMed-7B |
| Parameters | 7B (base) + 32M (LoRA adapters) |
| Context Length | 4096 tokens |
| Quantization | 4-bit NF4 |
| LoRA Rank | 32 |
| Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Training Method | GRPO (Group Relative Policy Optimization) |
Training Steps: 200 (100 warmup steps)
Batch Size: 4 per device
Gradient Accumulation: 4 steps (effective batch = 16)
Learning Rate: 5e-5 with cosine scheduler
Optimizer: AdamW (8-bit)
Mixed Precision: BF16
Dataset: FreedomIntelligence/medical-o1-reasoning-SFT (500 examples)
The model was trained using two complementary reward signals:
Format Reward (40% final weight):
<think> reasoning tagsSemantic Reward (60% final weight):
Reward weights were adaptively adjusted during training from 90%/10% to 40%/60% to balance format adherence with semantic accuracy.
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
"OctoMed/OctoMed-7B",
load_in_4bit=True,
device_map="auto"
)
# Load LoRA adapters
model = PeftModel.from_pretrained(base_model, "AhmedSSoliman/octomed-7b-digital-twin-v1")
tokenizer = AutoTokenizer.from_pretrained("AhmedSSoliman/octomed-7b-digital-twin-v1")
# Generate response
question = "What are the early signs of sepsis and how should it be managed?"
messages = [
{"role": "system", "content": "You are a medical AI assistant. Think through your reasoning step-by-step using <think> tags before providing your final answer."},
{"role": "user", "content": question}
]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")
outputs = model.generate(inputs, max_new_tokens=512, temperature=0.7, do_sample=True)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
from unsloth import FastLanguageModel
# Load model with Unsloth optimizations
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="AhmedSSoliman/octomed-7b-digital-twin-v1",
max_seq_length=4096,
dtype=None, # Auto-detect best dtype
load_in_4bit=True,
fast_inference=False # Python 3.13+ compatibility
)
# Enable inference mode for 2x faster generation
FastLanguageModel.for_inference(model)
# Generate response
messages = [
{"role": "user", "content": "Explain the pathophysiology of type 2 diabetes."}
]
inputs = tokenizer.apply_chat_template(messages, tokenize=True, return_tensors="pt").to("cuda")
outputs = model.generate(
input_ids=inputs,
max_new_tokens=512,
temperature=0.7,
top_p=0.9,
do_sample=True
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Model Response:
<think>
A 45-year-old patient with hypertension presenting with chest pain requires immediate evaluation for cardiac causes. Key considerations:
1. Cardiac causes (most urgent):
- Acute coronary syndrome (ACS)
- Myocardial infarction
- Unstable angina
2. Risk factors present:
- Age (45, middle-aged male risk)
- Known hypertension (damages vessels)
3. Differential diagnosis:
- Costochondritis (musculoskeletal)
- GERD (gastrointestinal)
- Pulmonary embolism (respiratory)
Given hypertension history, cardiac workup is priority.
</think>
Chest pain in a 45-year-old with hypertension requires urgent evaluation for acute coronary syndrome. Immediate steps include:
1. **Emergency Assessment**: Call emergency services (911) if severe
2. **ECG**: Within 10 minutes of presentation
3. **Cardiac Biomarkers**: Troponin levels
4. **Risk Stratification**: HEART score or similar
Hypertension is a major risk factor for coronary artery disease. Do not delay seeking medical attention—chest pain in this context could indicate a heart attack requiring immediate intervention.
| Configuration | VRAM Required | Speed |
|---|---|---|
| 4-bit (Recommended) | ~14 GB | Fast |
| 8-bit | ~28 GB | Medium |
| FP16 | ~56 GB | Slow |
Recommended Setup:
THIS MODEL IS FOR RESEARCH AND EDUCATIONAL PURPOSES ONLY. IT IS NOT A SUBSTITUTE FOR PROFESSIONAL MEDICAL ADVICE, DIAGNOSIS, OR TREATMENT.
<think> tags may sometimes contain verbose or redundant reasoningThe model was evaluated on clinical reasoning tasks with the following metrics:
Note: Formal clinical validation has not been performed.
If you use this model in your research, please cite:
@misc{octomed-7b-digital-twin-v1,
author = {Ahmed S. Soliman},
title = {OctoMed-7B Digital Twin v1: GRPO-Enhanced Medical Reasoning},
year = {2025},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/AhmedSSoliman/octomed-7b-digital-twin-v1}},
note = {Fine-tuned with Group Relative Policy Optimization for transparent clinical reasoning}
}
Also cite the base OctoMed model:
@misc{octomed2025,
title={OctoMed: Multimodal Medical AI},
author={OctoMed Team},
year={2025},
publisher={HuggingFace},
howpublished={\url{https://huggingface.co/OctoMed/OctoMed-7B}}
}
This model inherits the Apache 2.0 license from OctoMed-7B. Use responsibly and in compliance with medical AI regulations in your jurisdiction.
For questions or issues, please contact:
Developed: December 2025
Framework: Unsloth + TRL + Transformers
Training Method: GRPO (Group Relative Policy Optimization)