Instructions to use Shayan0179/Medix-R1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Shayan0179/Medix-R1 with Transformers:
# 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") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Shayan0179/Medix-R1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Shayan0179/Medix-R1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Shayan0179/Medix-R1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Shayan0179/Medix-R1
- SGLang
How to use Shayan0179/Medix-R1 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Shayan0179/Medix-R1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Shayan0179/Medix-R1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Shayan0179/Medix-R1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Shayan0179/Medix-R1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Shayan0179/Medix-R1 with Docker Model Runner:
docker model run hf.co/Shayan0179/Medix-R1
Download README.md from Shayan0179/Medix-R1: direct link, hf CLI and curl.
- Browser
- Download file 2.3 kB
-
https://huggingface.co/Shayan0179/Medix-R1/resolve/main/README.md
- Command line
-
hf download hf://Shayan0179/Medix-R1/README.md
-
curl -L -o README.md https://huggingface.co/Shayan0179/Medix-R1/resolve/main/README.md
license: apache-2.0
base_model:
- Qwen/Qwen3-VL-4B-Instruct
- Qwen/Qwen3-VL-8B-Instruct
library_name: transformers
pipeline_tag: image-text-to-text
tags:
- medical
- vision-language
- reinforcement-learning
- qwen3-vl
datasets:
- MBZUAI/medix-rl-data
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.