How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("image-text-to-text", model="Shayan0179/Medix-R1")
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("Shayan0179/Medix-R1", device_map="auto")
Quick Links

MediX-R1 (reproduction), 4B and 8B

Two Qwen3-VL checkpoints trained with reinforcement learning following the MediX-R1 recipe. They are our reproduction of MediX-R1, the "MediX-R1-4B" and "MediX-R1-8B" rows of the main results table in our paper. Each model is in its own folder.

Folder Base model VQA QA Macro Micro
MediX-R1-4B Qwen/Qwen3-VL-4B-Instruct 49.2 70.5 63.0 53.8
MediX-R1-8B Qwen/Qwen3-VL-8B-Instruct 49.3 74.4 65.5 56.0

Accuracy (%) over 6 medical VQA and 11 medical text QA benchmarks, greedy decoding, answers scored by three LLM judges. The README in each folder has the training recipe, the prompt format and the per-benchmark results.

Usage

import torch
from huggingface_hub import snapshot_download
from transformers import AutoProcessor, Qwen3VLForConditionalGeneration

name = "MediX-R1-8B"   # or "MediX-R1-4B"
path = snapshot_download("Shayan0179/Medix-R1", allow_patterns=f"{name}/*") + f"/{name}"
model = Qwen3VLForConditionalGeneration.from_pretrained(path, dtype=torch.bfloat16, device_map="auto")
processor = AutoProcessor.from_pretrained(path)

PROMPT = open(f"{path}/prompt.txt").read()   # the training instructions, ending with "Question: \n"
messages = [{"role": "user", "content": [
    {"type": "text", "text": PROMPT},
    {"type": "image", "image": "chest_xray.png"},
    {"type": "text", "text": "Is there a pleural effusion?"},
]}]
inputs = processor.apply_chat_template(messages, tokenize=True, add_generation_prompt=True,
                                       return_dict=True, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=2048, do_sample=False)
print(processor.batch_decode(out[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0])

The model answers with a modality tag, then its reasoning in <thinking>...</thinking>, then the final answer in <answer>...</answer>.

License

Apache 2.0, following the base models.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Shayan0179/Medix-R1

Finetuned
(556)
this model

Dataset used to train Shayan0179/Medix-R1