Downloads · 30 days
256
15% of all-time downloads
Kerassy/Qwen3.5-4B-Medical-Reasoning
Qwen3.5-4B-Medical-Reasoning is a text generation model from Kerassy. Use it when you need the model to write or continue text. The card lists the license as apache-2.0.
Qwen3.5-4B-Medical-Reasoning is a fine-tuned 4-billion parameter model optimized for complex clinical reasoning and medical question-answering. By leveraging chain-of-thought (CoT) fine-tuning on medical reasoning tra…
Downloads · 30 days
256
15% of all-time downloads
All-time downloads
1.7K
Public
Parameters
4.7B
26.7 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors9.3 GB · 54%
How the weights are stored.
BF164.7B · 100%
From the Hugging Face model README
Qwen3.5-4B-Medical-Reasoning is a fine-tuned 4-billion parameter model optimized for complex clinical reasoning and medical question-answering. By leveraging chain-of-thought (CoT) fine-tuning on medical reasoning traces, the model generates explicit step-by-step diagnostic reasoning inside <think> tags prior to delivering a final medical conclusion.
<think>...</think> tags for explainable medical reasoning.<think>\n</think>).Evaluated on the full 1,273-question test set of GBaker/MedQA-USMLE-4-options using single-pass greedy decoding on an NVIDIA A100 GPU:
| Metric | Score / Result |
|---|---|
| Overall Accuracy | 68.34% (870 / 1,273) |
| Successfully Parsed Answers | 97.72% (1,244 / 1,273) |
| Average Inference Time | 5.95 seconds / question |
| Total Evaluation Time | 2.10 hours |
max_tokens=1024): 2.0%Qwen/Qwen3.5-4BFreedomIntelligence/medical-o1-reasoning-SFT (Subset: -EM, Split: Train)<|im_start|>, <|im_end|>)import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
MODEL_ID = "Kerassy/Qwen3.5-4B-Medical-Reasoning"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
torch_dtype=torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16,
device_map="auto"
)
system_prompt = "You are a clinical expert. Think step-by-step inside <think> tags before providing your final medical answer."
user_prompt = "A 45-year-old male presents with sudden chest pain, diaphoresis, and radiation to the left jaw. What is the most likely diagnosis?"
prompt = (
f"<|im_start|>system\n{system_prompt}<|im_end|>\n"
f"<|im_start|>user\n{user_prompt}<|im_end|>\n"
f"<|im_start|>assistant\n"
)
inputs = tokenizer([prompt], return_tensors="pt").to("cuda")
outputs = model.generate(
**inputs,
max_tokens=1024,
use_cache=True,
temperature=0.7,
top_p=0.9,
eos_token_id=tokenizer.eos_token_id
)
decoded = tokenizer.batch_decode(outputs, skip_special_tokens=False)[0]
response = decoded.split("<|im_start|>assistant\n")[-1].replace("<|im_end|>", "").strip()
print(response)
To bypass the reasoning phase and generate a direct response, pre-fill the assistant turn with closed empty <think>\n</think> tags:
prompt_direct = (
f"<|im_start|>system\nYou are a succinct medical assistant.<|im_end|>\n"
f"<|im_start|>user\n{user_prompt}<|im_end|>\n"
f"<|im_start|>assistant\n<think>\n</think>\n"
)
inputs_direct = tokenizer([prompt_direct], return_tensors="pt").to("cuda")
outputs_direct = model.generate(
**inputs_direct,
max_tokens=1024,
eos_token_id=tokenizer.eos_token_id
)
decoded_direct = tokenizer.batch_decode(outputs_direct, skip_special_tokens=False)[0]
response_direct = decoded_direct.split("<think>\n</think>\n")[-1].replace("<|im_end|>", "").strip()
print(response_direct)
Intended Use
IMPORTANT: This model is built for research and evaluation purposes only. It is not a certified medical device and should never be used for direct patient diagnosis, treatment advice, or real-world clinical decision-making. Always consult a qualified medical professional for health-related decisions.