Downloads · 30 days
14
25% of all-time downloads
naazimsnh02/Shifa-4B-SFT
Shifa-4B-SFT is a text generation model from naazimsnh02. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
Shifa-4B is a 4-billion parameter medical reasoning model built on Qwen3.5-4B. It is fine-tuned to reason step-by-step through medical questions using chain-of-thought inside <think...</think blocks, then deliver a cl…
Downloads · 30 days
14
25% of all-time downloads
All-time downloads
57
Public
Parameters
4.7B
9.3 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors9.3 GB · 100%
How the weights are stored.
BF164.7B · 100%
From the Hugging Face model README
Shifa-4B is a 4-billion parameter medical reasoning model built on Qwen3.5-4B. It is fine-tuned to reason step-by-step through medical questions using chain-of-thought inside <think>...</think> blocks, then deliver a clear final answer.
This is the merged full-weight model (LoRA adapters baked in, fp16) — ready for direct inference with no adapter loading required. The vision encoder is preserved from the base model, so Shifa-4B can process both text and image inputs.
For the lightweight LoRA adapter only, see naazimsnh02/Shifa-4B-SFT-SFT-LoRA.
| Benchmark | Shifa-4B | MedGemma-4B-IT | Delta |
|---|---|---|---|
| MedQA (USMLE, 4-opt) | 0.702 | 0.691 | +0.011 |
| MedMCQA | 0.508 | 0.598 | -0.090 |
| PubMedQA | 0.374 | 0.682 | -0.308 |
MedGemma targets are from the google/medgemma-4b-it model card. Evaluated on 500 samples per benchmark using greedy decoding.
from transformers import AutoModelForCausalLM, AutoProcessor
import torch
model = AutoModelForCausalLM.from_pretrained(
"naazimsnh02/Shifa-4B-SFT",
torch_dtype=torch.bfloat16,
device_map="auto",
)
processor = AutoProcessor.from_pretrained("naazimsnh02/Shifa-4B-SFT")
messages = [
{"role": "user", "content": "A 55-year-old woman with diabetes presents with a painless foot ulcer. Describe the pathophysiology and management approach."},
]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
tokenizer = processor.tokenizer
inputs = tokenizer([text], return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=1024, do_sample=False)
print(tokenizer.decode(output[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
from transformers import AutoModelForCausalLM, AutoProcessor
from PIL import Image
import torch
model = AutoModelForCausalLM.from_pretrained(
"naazimsnh02/Shifa-4B-SFT",
torch_dtype=torch.bfloat16,
device_map="auto",
)
processor = AutoProcessor.from_pretrained("naazimsnh02/Shifa-4B-SFT")
image = Image.open("chest_xray.png")
messages = [
{"role": "user", "content": [
{"type": "image", "image": image},
{"type": "text", "text": "What findings do you observe in this chest X-ray?"},
]},
]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], images=[image], return_tensors="pt", padding=True).to(model.device)
output = model.generate(**inputs, max_new_tokens=512, do_sample=False)
print(processor.batch_decode(output[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0])
~395K examples blended from three medical reasoning datasets plus a general-instruction mix:
| Source | Samples | Description |
|---|---|---|
| FreedomIntelligence/medical-o1-reasoning-SFT | ~20K | HuatuoGPT-o1 gold chain-of-thought traces |
| OpenMed/Medical-Reasoning-SFT-GPT-OSS-120B | 200K | High-effort reasoning from GPT-OSS-120B |
| Intelligent-Internet/II-Medical-Reasoning-SFT | 150K | Sampled for scale and diversity |
| HuggingFaceH4/ultrachat_200k | ~28K (7%) | General instruction mix to prevent catastrophic forgetting |
<think> reasoning chains followed by a final answer. Response-only loss masking ensures the model learns from assistant turns only.| Parameter | Value |
|---|---|
| Method | QLoRA (4-bit NF4) → merged to fp16 |
| LoRA rank (r) | 32, alpha = 64 |
| Target modules | All attention + MLP (language layers only) |
| Batch size | 4 × 4 gradient accumulation (effective 16) |
| Learning rate | 1e-4 (cosine schedule) |
| Max sequence length | 4096 |
| Training steps | 10,000 (~2 epochs) |
| Optimizer | AdamW 8-bit |
| Final training loss | ~0.59 |
| Training time | ~21.7 hours on 1× A100-SXM4-80GB |
Shifa-4B inherits Qwen3.5-4B's full architecture:
<think> / </think> tokens for chain-of-thought reasoningIf you use Shifa-4B in your research, please cite the base model and training datasets:
@misc{shifa4b2026,
title={Shifa-4B: Medical Reasoning Model},
author={Naazim},
year={2026},
url={https://huggingface.co/naazimsnh02/Shifa-4B}
}
Apache 2.0 — same as the base model (Qwen3.5-4B).