Shifa-4B

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 Results (Stage-1 SFT)

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.

Quickstart

Text-only

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))

With Images (multimodal)

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])

Training Details

Data

~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

Approach

  • Stage-1: Supervised Fine-Tuning — QLoRA on language layers only (vision tower frozen), training the model to produce <think> reasoning chains followed by a final answer. Response-only loss masking ensures the model learns from assistant turns only.
  • Stage-2: GRPO (planned) — Reinforcement learning with verifiable MCQ rewards on MedQA + MedMCQA to strengthen overall medical reasoning accuracy. The final GRPO model will be published at naazimsnh02/Shifa-4B.

Hyperparameters

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

Framework

  • Unsloth 2026.6.7
  • TRL 0.22.2 (SFTTrainer)
  • Transformers 5.12.1
  • PyTorch 2.8.0+cu128

Architecture

Shifa-4B inherits Qwen3.5-4B's full architecture:

  • Language model: 4B parameter decoder-only transformer
  • Vision encoder: Preserved and frozen from base model (supports image inputs)
  • Hybrid thinking: Native <think> / </think> tokens for chain-of-thought reasoning

Limitations

  • Not intended for clinical use or medical decision-making. This is a research model.
  • Performance on PubMedQA (literature-based reasoning) is limited and under investigation.
  • Vision capabilities are inherited from the base model — the vision encoder was not fine-tuned for medical imaging.
  • The model inherits biases and limitations from its base model and training data.
  • Benchmark scores are from 500-sample evaluations; full-set evaluations may differ.

Citation

If 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}
}

License

Apache 2.0 — same as the base model (Qwen3.5-4B).

Downloads last month
4
Safetensors
Model size
5B params
Tensor type
BF16
·
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for naazimsnh02/Shifa-4B-SFT

Finetuned
Qwen/Qwen3.5-4B
Finetuned
(461)
this model

Datasets used to train naazimsnh02/Shifa-4B-SFT

Collection including naazimsnh02/Shifa-4B-SFT

Evaluation results