Image-Text-to-Text
Transformers
Safetensors
qwen3_5
medical
multimodal
grounding
visual-grounding
multi-image
reasoning
chain-of-thought
radiology
mri
ct
conversational
Instructions to use adidukrembzuai/MedChain-R1-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use adidukrembzuai/MedChain-R1-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="adidukrembzuai/MedChain-R1-4B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("adidukrembzuai/MedChain-R1-4B") model = AutoModelForMultimodalLM.from_pretrained("adidukrembzuai/MedChain-R1-4B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use adidukrembzuai/MedChain-R1-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "adidukrembzuai/MedChain-R1-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "adidukrembzuai/MedChain-R1-4B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/adidukrembzuai/MedChain-R1-4B
- SGLang
How to use adidukrembzuai/MedChain-R1-4B 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 "adidukrembzuai/MedChain-R1-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "adidukrembzuai/MedChain-R1-4B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "adidukrembzuai/MedChain-R1-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "adidukrembzuai/MedChain-R1-4B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use adidukrembzuai/MedChain-R1-4B with Docker Model Runner:
docker model run hf.co/adidukrembzuai/MedChain-R1-4B
Overview: Figure 1 from arXiv:2611.00041v1, with caption
Browse files- README.md +6 -0
- overview.png +2 -2
README.md
CHANGED
|
@@ -29,6 +29,12 @@ tags:
|
|
| 29 |
<img src="overview.png" alt="MedChain-R1 overview" width="900"/>
|
| 30 |
</p>
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
**MedChain-R1-4B** is a 4B vision-language model for **sequential medical image grounding**: given a short sequence of
|
| 33 |
medical images and a clinical question, it first writes an image-grounded rationale in `<think>…</think>` and then
|
| 34 |
returns one bounding box `<answer>(x1,y1),(x2,y2)</answer>` in pixel coordinates. It is built on
|
|
|
|
| 29 |
<img src="overview.png" alt="MedChain-R1 overview" width="900"/>
|
| 30 |
</p>
|
| 31 |
|
| 32 |
+
*Figure 1 of the paper: **Sequential medical grounding with reasoning supervision.** (a) The eight MedSG-Bench tasks,
|
| 33 |
+
grouped into image difference grounding (IDG) and image consistency grounding (ICG). (b) A registered-difference example:
|
| 34 |
+
zero-shot Qwen3.5 and MedSeq-Grounder return imprecise boxes, whereas MedChain-R1 first identifies the new nodule and then
|
| 35 |
+
localizes it. (c) MedSG-Bench mIoU and Acc@0.5 of MedSeq-Grounder (7B) and MedChain-R1 at 4B and 9B (dCoT-SFT and
|
| 36 |
+
dCoT-SFT+GRPO) and 27B (dCoT-SFT).*
|
| 37 |
+
|
| 38 |
**MedChain-R1-4B** is a 4B vision-language model for **sequential medical image grounding**: given a short sequence of
|
| 39 |
medical images and a clinical question, it first writes an image-grounded rationale in `<think>…</think>` and then
|
| 40 |
returns one bounding box `<answer>(x1,y1),(x2,y2)</answer>` in pixel coordinates. It is built on
|
overview.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|