Image-Text-to-Text
Transformers
Safetensors
English
qwen2_5_vl
Pathology
VLM
Reasoning
conversational
text-generation-inference
Run this model with HF Jobs
Run ChiPhan1110/ScaleReasoner-R1 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/ChiPhan1110/ScaleReasoner-R1. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/ChiPhan1110/ScaleReasoner-R1 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/ChiPhan1110/ScaleReasoner-R1. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/ChiPhan1110/ScaleReasoner-R1. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use ChiPhan1110/ScaleReasoner-R1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ChiPhan1110/ScaleReasoner-R1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ChiPhan1110/ScaleReasoner-R1") 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("ChiPhan1110/ScaleReasoner-R1") model = AutoModelForMultimodalLM.from_pretrained("ChiPhan1110/ScaleReasoner-R1", 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 ChiPhan1110/ScaleReasoner-R1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ChiPhan1110/ScaleReasoner-R1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ChiPhan1110/ScaleReasoner-R1", "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/ChiPhan1110/ScaleReasoner-R1
- SGLang
How to use ChiPhan1110/ScaleReasoner-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 "ChiPhan1110/ScaleReasoner-R1" \ --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": "ChiPhan1110/ScaleReasoner-R1", "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 "ChiPhan1110/ScaleReasoner-R1" \ --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": "ChiPhan1110/ScaleReasoner-R1", "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 ChiPhan1110/ScaleReasoner-R1 with Docker Model Runner:
docker model run hf.co/ChiPhan1110/ScaleReasoner-R1
Create README.md
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305<h1 align="center">[MICCAI 2026] Enhancing Pathological VLMs with Cross-scale Reasoning</h1>
<p align="center"> Chi Phan*, Tianyi Zhang*, Qiaochu Xue, Yufeng Wu, Dan Hu, Zeyu Liu, Sudong Wang, Yueming Jin </p>
<p align="center"> <a href="https://conferences.miccai.org/2026/en/default.asp"> <img src="https://img.shields.io/badge/MICCAI-2026-blue" alt="MICCAI 2026" /> </a> <a href="https://arxiv.org/abs/2606.17412"> <img src="https://img.shields.io/badge/Paper-arXiv-red" alt="Paper arXiv" /> </a> <a href="https://huggingface.co/ChiPhan1110/ScaleReasoner-R1"> <img src="https://img.shields.io/badge/%F0%9F%A4%97%20Model-ScaleReasoner--R1-green" alt="Model ScaleReasoner-R1" /> </a> <a href="https://huggingface.co/ChiPhan1110/ScaleReasoner-R1"> <img src="https://img.shields.io/badge/%F0%9F%A4%97%20Data-Scale--VQA-yellow" alt="Data Scale-VQA" /> </a></p>
## π¬ OverviewPathological diagnosis is inherently multi-scale: pathologists reason from global tissue architecture at low magnification down to cellular morphology at high magnification, integrating evidence across views before reaching a conclusion. While existing pathological datasets for vision-language models (VLMs) include various scales, they often lack explicit cross-scale reasoning objectives. This limitation prevents VLMs from capturing essential cross-scale representations and learning evidence-based reasoning.
We introduce the **first cross-scale training and evaluation paradigm** for pathological VLMs, along with:
- **Scale-VQA** - a high-quality benchmark of 4,685 leakage-aware multiple-choice questions grounded in multi-magnification pathology images across 15 organs and 5 clinically-aligned reasoning dimensions.- **ScaleReasoner-R1** - a pathology VLM trained with Group Relative Policy Optimization (GRPO) that achieves state-of-the-art performance on cross-scale multi-image VQA and transfers strongly to established single-image benchmarks.
## π§© Method
<div align="center"><img src="assets/method_fig.png" alt="Method Overview" width="95%">
**(a)** Leakage-aware curation pipeline for Scale-VQA. **(b)** Dataset overview across organs and magnifications. **(c)** GRPO-based reinforcement learning framework for ScaleReasoner-R1.</div>
### Scale-VQA: Leakage-Aware Cross-Scale Benchmark
Naively constructed cross-scale VQA benchmarks suffer from **text-only shortcut solutions** β models can infer the correct answer from linguistic or biomedical priors without ever examining the images. Our curation pipeline eliminates these via three steps:
| Step | Description ||------|-------------|| **Scale-specific Feature Decomposition** | Expert annotations are decomposed into per-scale evidence sets; initial visual-grounding and scale-dependency constraints are imposed. || **Text-only Adversarial Screening** | Gemini 3 Pro and Qwen3-Max act as text-only adversaries. If either model answers correctly without images, constraints are tightened and questions are regenerated. || **Cross-scale MCQ Construction & Clinical Validation** | Final MCQs are reviewed by senior pathologists to confirm that correct answers are visually grounded and distractors are clinically plausible. |
### ScaleReasoner-R1: Cross-scale Reasoning via RLScaleReasoner-R1 is initialized from **Patho-R1-7B** and fine-tuned with **GRPO** on Scale-VQA. Given a multi-scale image set $I = \{I^{10\times}, I^{40\times}, I^{200\times}\}$, a question, and options, the model generates a structured response with a reasoning trace (`<think>`) followed by a final answer (`<answer>`).
**Training Dynamics:**
<div align="center">
| Training Reward | Validation Accuracy ||:-------------------:|:---------------:|| <img src="assets/rl_curve_critic.png" width="420"> | <img src="assets/rl_curve_val.png" width="500"> | </div>
## π Results<div align="center"><img src="assets/eval.png" alt="Evaluation Results" width="80%"></div>
### Cross-scale Multi-image VQA
| Model | Corresp. | Confirm. | Localiz. | Explan. | Diagno. | **AVG** ||-------|:--------:|:--------:|:--------:|:-------:|:-------:|:-------:|| Qwen2.5-VL-7B | 41.79 | 47.26 | 71.14 | 44.28 | 63.68 | 53.63 || Gemini 3 Flash | 48.26 | 58.71 | 71.64 | 53.73 | 72.14 | 60.90 || GPT-5.2 | 47.76 | 59.70 | 74.13 | 45.77 | 65.17 | 58.51 || LLaVA-Med-7B | 25.87 | 16.92 | 28.36 | 20.90 | 24.88 | 23.38 || Quilt-LLaVA | 32.34 | 14.43 | 45.27 | 30.35 | 29.35 | 30.35 || CLOVER | 37.31 | 61.69 | 73.13 | 46.27 | 65.77 | 56.82 || Patho-R1 | 31.84 | 40.30 | 59.70 | 56.22 | 68.66 | 51.34 || **ScaleReasoner-R1** | **80.60** | **89.05** | **84.58** | **76.12** | **84.08** | **82.89** |
### Single-image VQA (PathMMU)
| Model | Overall | PubMed | SocialPath | EduContent | Atlas | PathCLS ||-------|:------------:|:------:|:----------:|:----------:|:-----:|:-------:|| Patho-R1 | 64.8 | 68.7 | 63.9 | 65.7 | 73.5 | 41.8 || **ScaleReasoner-R1** | **66.2** | **71.2** | **67.6** | **67.6** | **79.3** | 37.9 |
---
## π Repository Structure```textScaleReasoner-R1/βββ assets/ βββ data/ # Cross-scale VQA json by splitβββ preprocess/β βββ generate_vqa_data/ # Feature extraction, VQA generation, split creationβ βββ prompts/ # Leakage-aware prompt templates and constraintsβββ script/β βββ preprocess/ # End-to-end preprocessing entrypointsβ βββ train/ # SFT and GRPO launch scriptsβ βββ postprocess/ # Postprocess after trainingβββ LLaMA-Factory/ # SFT training framework βββ verl/ # RL training framework ```## π Getting Started
### Environment Setup
```bash# Clone the repositorygit clone https://github.com/iMVR-PL/ScaleReasoner-R1.gitcd ScaleReasoner-R1
# Set up environment variablescp script/.env.example script/.env# Edit script/.env with your paths and API keys```
Configure `script/.env`:
```bash# Data pathsDATA_DIR=/path/to/triplet_raw_dataROOT=/path/to/ScaleReasoner-R1PROCESSED_DIR=/path/to/processed_data
# Model pathsACTOR_MODEL_DIR=/path/to/patho-r1-7b # base model (Patho-R1-7B)RESULTS_DIR=/path/to/results
# LoggingLOG_DIR=/path/to/logsWANDB_DIR=/path/to/wandb
# API keys (for VQA generation pipeline)GEMINI_API_KEY=...OPENAI_API_KEY=...DASHSCOPE_API_KEY=...HF_TOKEN=...```
**RL environment (verl).** ScaleReasoner-R1 is trained with [verl](https://github.com/volcengine/verl). Please follow the [verl installation guide](https://verl.readthedocs.io/en/latest/start/install.html) to set up the environment, then install the local copy:
```bashconda create -n verl python=3.10 -y && conda activate verlpip install -e verl/```
**SFT environment (LLaMA-Factory).** The SFT baseline uses [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory):
```bashconda create -n sft python=3.10 -y && conda activate sftpip install -e LLaMA-Factory/```
> Both environments require CUDA 12.1+ and PyTorch 2.3+. We recommend using separate conda environments for RL and SFT to avoid dependency conflicts.
## ποΈ Dataset
Download **Scale-VQA** from [HuggingFace](https://huggingface.co/datasets/iMVR-PL/Scale-VQA). The `data/` directory contains the train/val/test splits in JSON format. Each sample includes:
```json{ "question": "...", "options": { "A": "...", "B": "...", "C": "...", "D": "..." }, "answer": "D", "rationale": "...", "image_path": { "low_mag": "wsi_id/rois/10_....jpg", "mid_mag": "wsi_id/rois/40_....jpg", "high_mag": "wsi_id/rois/200_....jpg" }}```
## π€ Training & Inference
### RL Training (ScaleReasoner-R1)
We use [**verl**](https://github.com/volcengine/verl) for GRPO-based RL training:
```bashconda create -n verl python=3.10 -y && conda activate verlpip install -e verl/
bash script/train/run_grpo_cross_scale_vqa.sh```
Key hyperparameters: `n=5` rollouts per question, `total_epochs=5`, `train_batch_size=32`. The custom reward function is at `verl/verl/utils/reward_score/cross_scale_vqa.py`.
### SFT Baseline
We use [**LLaMA-Factory**](https://github.com/hiyouga/LLaMA-Factory) for supervised fine-tuning:
```bashconda create -n sft python=3.10 -y && conda activate sftpip install -e LLaMA-Factory/
bash script/train/run_sft_pathor1_new_triplet_mcq_think_only.sh```
### Inference
Download **ScaleReasoner-R1** from [HuggingFace](https://huggingface.co/ChiPhan1110/ScaleReasoner-R1). ScaleReasoner-R1 was trained to produce structured outputs using `<think>` and `<answer>` tags. To ensure reproducible results, pass the system prompt below:
```pythonSYSTEM_PROMPT = ( "You are a pathology expert. Read the question and options about the image carefully. " "Think step by step inside <think> </think>. Then output ONLY the SINGLE best option letter " "inside <answer> </answer>.\n" "Example: <think>Your reasoning</think> <answer>A</answer>. " "Do not include the option text or any extra words inside <answer> </answer> tags.")```
**Option 1 β vLLM server (recommended for batched evaluation)**
```bashvllm serve <path/to/ScaleReasoner-R1> \ --host 0.0.0.0 \ --port 8000 \ --tensor-parallel-size 1 \ --max-model-len 8192 \ --limit-mm-per-prompt.image 5
```
Then query via the OpenAI-compatible client:
```pythonfrom openai import OpenAIimport base64
def encode_image(path): with open(path, "rb") as f: return base64.b64encode(f.read()).decode("utf-8")
client = OpenAI(base_url="http://localhost:8000/v1", api_key="token")
response = client.chat.completions.create( model="ChiPhan1110/ScaleReasoner-R1", messages=[{ "role": "user", "content": [ {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{encode_image('low_mag.jpg')}"}}, {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{encode_image('mid_mag.jpg')}"}}, {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{encode_image('high_mag.jpg')}"}}, {"type": "text", "text": "<question>\n(A) ...\n(B) ...\n(C) ...\n(D) ..."}, ] }], max_tokens=4096,)print(response.choices[0].message.content)```
**Option 2 β Hugging Face Transformers**
```pythonfrom transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessorfrom qwen_vl_utils import process_vision_info
model = Qwen2_5_VLForConditionalGeneration.from_pretrained( "ChiPhan1110/ScaleReasoner-R1", torch_dtype="auto", device_map="auto")processor = AutoProcessor.from_pretrained("ChiPhan1110/ScaleReasoner-R1")
messages = [{ "role": "user", "content": [ {"type": "image", "image": "low_mag.jpg"}, {"type": "image", "image": "mid_mag.jpg"}, {"type": "image", "image": "high_mag.jpg"}, {"type": "text", "text": "<question>\n(A) ...\n(B) ...\n(C) ...\n(D) ..."}, ]}]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)image_inputs, _ = process_vision_info(messages)inputs = processor(text=[text], images=image_inputs, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=4096)print(processor.decode(output[0][len(inputs.input_ids[0]):], skip_special_tokens=True))```
## π Acknowledgements
This work was supported by the Ministry of Education, Singapore, under the Tier 1 grant (24-1250-P0001) and Tier 2 grant (T2EP20224-0028), and by PuzzleLogic Pte Ltd, Singapore.
We gratefully acknowledge the open-source projects that made the development of **ScaleReasoner-R1** possible:- [**verl**](https://github.com/volcengine/verl), for the reinforcement learning training framework.- [**LLaMA-Factory**](https://github.com/hiyouga/LLaMA-Factory), for the unified fine-tuning pipelines.- [**vLLM**](https://github.com/vllm-project/vllm), for efficient large language model inference and serving.
We also acknowledge the following open-source models used for comparison in our experiments: [Qwen2.5-VL-7B](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct), [LLaVA-Med-7B](https://github.com/microsoft/LLaVA-Med), [HuaTuoGPT-7B](https://github.com/FreedomIntelligence/HuatuoGPT-Vision), [Lingshu-7B](https://huggingface.co/lingshu-medical-mllm/Lingshu-7B), [Quilt-LLaVA](https://github.com/aldraus/quilt-llava), [CLOVER](https://huggingface.co/jline/CLOVER-Qwen2.5-VL), and [Patho-R1](https://github.com/wenchuan-zhang/patho-r1).
We sincerely thank the developers and contributors of these projects for their excellent work and for making their code and models publicly available to the research community.
## β€οΈ Citation
If you find our work helpful, please consider citing our paper and the frameworks we build upon:```bibtex@article{phan2026enhancing, title={Enhancing Pathological VLMs with Cross-scale Reasoning}, author={Phan, Chi and Zhang, Tianyi and Xue, Qiaochu and Wu, Yufeng and Hu, Dan and Liu, Zeyu and Wang, Sudong and Jin, Yueming}, journal={arXiv preprint arXiv:2606.17412}, year={2026}}
```README.mdAdded+305