SFT
Collection
Supervised fine-tuning
•
11 items
•
Updated
•
1
MedCase-R1 is a fine-tuned version of Qwen3-1.7B designed to enhance clinical and medical reasoning capabilities. The model was trained on 13,000 complex medical cases from the zou-lab/MedCaseReasoning dataset, which includes real-world diagnostic questions requiring step-by-step reasoning, differential diagnosis, and treatment selection. The objective is to create a compact yet competent medical assistant capable of reasoning over clinical scenarios, supporting both research and non-commercial medical education.
This model is intended for:
Use the code below to get started with the model.
from huggingface_hub import login
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
login(token="")
tokenizer = AutoTokenizer.from_pretrained("unsloth/Qwen3-1.7B",)
base_model = AutoModelForCausalLM.from_pretrained(
"unsloth/Qwen3-1.7B",
device_map={"": 0}, token=""
)
model = PeftModel.from_pretrained(base_model,"khazarai/MedCase-R1")
question = """
A 23-year-old man presented with a 1-month history of epigastric pain, nausea, postprandial vomiting, anorexia, generalized malaise, and an 11-kg weight loss. He had no prior gastrointestinal disease, abdominal surgeries, or hospitalizations, and was not on medications. On examination, vital signs were stable, and abdominal examination revealed only mild epigastric tenderness without organomegaly or peritoneal signs.
Laboratory tests showed normal hemoglobin, hematocrit, white-cell count, and liver and kidney function. HIV serology was negative. Syphilis serologies were positive (VDRL and Treponema pallidum reagents).
Upper endoscopy revealed diminished gastric expandability and diffuse mucosal lesions from the cardia to the pylorus. The gastric mucosa appeared thickened, friable, nodular, and had multiple ulcerations. Gastric biopsies demonstrated a dense inflammatory infiltrate rich in plasma cells.
"""
messages = [
{"role" : "user", "content" : question}
]
text = tokenizer.apply_chat_template(
messages,
tokenize = False,
add_generation_prompt = True,
enable_thinking = True,
)
from transformers import TextStreamer
_ = model.generate(
**tokenizer(text, return_tensors = "pt").to("cuda"),
max_new_tokens = 1800,
temperature = 0.6,
top_p = 0.95,
top_k = 20,
streamer = TextStreamer(tokenizer, skip_prompt = True),
)
For pipeline:
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
tokenizer = AutoTokenizer.from_pretrained("unsloth/Qwen3-1.7B")
base_model = AutoModelForCausalLM.from_pretrained("unsloth/Qwen3-1.7B")
model = PeftModel.from_pretrained(base_model, "khazarai/MedCase-R1")
question = """
A 23-year-old man presented with a 1-month history of epigastric pain, nausea, postprandial vomiting, anorexia, generalized malaise, and an 11-kg weight loss. He had no prior gastrointestinal disease, abdominal surgeries, or hospitalizations, and was not on medications. On examination, vital signs were stable, and abdominal examination revealed only mild epigastric tenderness without organomegaly or peritoneal signs.
Laboratory tests showed normal hemoglobin, hematocrit, white-cell count, and liver and kidney function. HIV serology was negative. Syphilis serologies were positive (VDRL and Treponema pallidum reagents).
Upper endoscopy revealed diminished gastric expandability and diffuse mucosal lesions from the cardia to the pylorus. The gastric mucosa appeared thickened, friable, nodular, and had multiple ulcerations. Gastric biopsies demonstrated a dense inflammatory infiltrate rich in plasma cells.
"""
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
messages = [
{"role": "user", "content": question}
]
pipe(messages)