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 3 |
+
This model card describes the ViGoRL (**Vi**sually **G**r**o**unded **R**einforcement **L**earning) model, introduced in our paper ["Grounded Reinforcement Learning for Visual Reasoning"](https://arxiv.org/abs/2505.23678).
|
| 4 |
+
|
| 5 |
+
**Authors:** Gabriel Sarch, Snigdha Saha, Naitik Khandelwal, Ayush Jain, Michael J. Tarr, Aviral Kumar, Katerina Fragkiadaki
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## Model Overview
|
| 10 |
+
|
| 11 |
+
ViGoRL is a vision-language model fine-tuned using reinforcement learning (RL) to explicitly anchor textual reasoning steps to visual coordinates. Inspired by human visual cognition, ViGoRL employs multi-turn visual grounding, dynamically zooming into image regions to perform fine-grained visual reasoning and grounding.
|
| 12 |
+
|
| 13 |
+
This model was trained using supervised fine-tuning (SFT) on visually-grounded reasoning traces generated via Monte Carlo Tree Search (MCTS), followed by reinforcement learning with Group Relative Policy Optimization (GRPO).
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## Model Details
|
| 18 |
+
|
| 19 |
+
* **Base Architecture:** Qwen2.5-Vision-Language (3B or 7B parameters)
|
| 20 |
+
* **Training Paradigm:**
|
| 21 |
+
|
| 22 |
+
* Supervised Fine-Tuning on MCTS-generated reasoning traces
|
| 23 |
+
* Group Relative Policy Optimization (GRPO)
|
| 24 |
+
* Multi-turn visual grounding with dynamic zoom-in feedback (if "Multiturn" appears in name)
|
| 25 |
+
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
## Use Cases
|
| 29 |
+
|
| 30 |
+
This model excels in visual reasoning tasks that require precise visual grounding and region-level reasoning. Please see model name for specific domain.
|
| 31 |
+
|
| 32 |
+
* **Spatial Reasoning:** SAT-2, BLINK, RoboSpatial
|
| 33 |
+
* **Visual Search:** V\*Bench
|
| 34 |
+
* **Web Interaction and Grounding:** ScreenSpot (Pro and V2), VisualWebArena
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
## Usage
|
| 39 |
+
|
| 40 |
+
You can load this model easily using Hugging Face's Transformers library:
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
|
| 44 |
+
from qwen_vl_utils import process_vision_info
|
| 45 |
+
import torch
|
| 46 |
+
|
| 47 |
+
# # default: Load the model on the available device(s)
|
| 48 |
+
# model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
| 49 |
+
# "gsarch/ViGoRL-Multiturn-3b-Visual-Search", torch_dtype="auto", device_map="auto"
|
| 50 |
+
# ) # replace with any of the ViGoRL models
|
| 51 |
+
|
| 52 |
+
# We recommend enabling flash_attention_2 for better acceleration and memory saving.
|
| 53 |
+
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
| 54 |
+
"gsarch/ViGoRL-Multiturn-3b-Visual-Search",
|
| 55 |
+
torch_dtype=torch.bfloat16,
|
| 56 |
+
attn_implementation="flash_attention_2",
|
| 57 |
+
device_map="auto",
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
# default processer
|
| 61 |
+
processor = AutoProcessor.from_pretrained("gsarch/ViGoRL-Multiturn-3b-Visual-Search")
|
| 62 |
+
|
| 63 |
+
# The default range for the number of visual tokens per image in the model is 4-16384.
|
| 64 |
+
# You can set min_pixels and max_pixels according to your needs, such as a token range of 256-1280, to balance performance and cost.
|
| 65 |
+
# min_pixels = 256*28*28
|
| 66 |
+
# max_pixels = 1280*28*28
|
| 67 |
+
# processor = AutoProcessor.from_pretrained("gsarch/ViGoRL-Multiturn-3b-Visual-Search", min_pixels=min_pixels, max_pixels=max_pixels)
|
| 68 |
+
|
| 69 |
+
# messages = [
|
| 70 |
+
# {
|
| 71 |
+
# "role": "user",
|
| 72 |
+
# "content": [
|
| 73 |
+
# {
|
| 74 |
+
# "type": "image",
|
| 75 |
+
# "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
|
| 76 |
+
# },
|
| 77 |
+
# {"type": "text", "text": "What color is the leash."},
|
| 78 |
+
# ],
|
| 79 |
+
# }
|
| 80 |
+
# ]
|
| 81 |
+
|
| 82 |
+
messages = [
|
| 83 |
+
{
|
| 84 |
+
"role": "user",
|
| 85 |
+
"content": [
|
| 86 |
+
{
|
| 87 |
+
"type": "image",
|
| 88 |
+
"image": "path/to/image.png",
|
| 89 |
+
},
|
| 90 |
+
{"type": "text", "text": "QUERY HERE"},
|
| 91 |
+
],
|
| 92 |
+
}
|
| 93 |
+
]
|
| 94 |
+
|
| 95 |
+
# Preparation for inference
|
| 96 |
+
text = processor.apply_chat_template(
|
| 97 |
+
messages, tokenize=False, add_generation_prompt=True
|
| 98 |
+
)
|
| 99 |
+
image_inputs, video_inputs = process_vision_info(messages)
|
| 100 |
+
inputs = processor(
|
| 101 |
+
text=[text],
|
| 102 |
+
images=image_inputs,
|
| 103 |
+
videos=video_inputs,
|
| 104 |
+
padding=True,
|
| 105 |
+
return_tensors="pt",
|
| 106 |
+
)
|
| 107 |
+
inputs = inputs.to("cuda")
|
| 108 |
+
|
| 109 |
+
# Inference: Generation of the output
|
| 110 |
+
generated_ids = model.generate(**inputs, max_new_tokens=512)
|
| 111 |
+
generated_ids_trimmed = [
|
| 112 |
+
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
| 113 |
+
]
|
| 114 |
+
output_text = processor.batch_decode(
|
| 115 |
+
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
| 116 |
+
)
|
| 117 |
+
print(output_text) # this will output a single tool call turn of the model if version is multiturn.
|
| 118 |
+
# Example output of gsarch/ViGoRL-Multiturn-3b-Visual-Search: ['<think> The leash appears to be red, as seen near the dog\'s paw and the person\'s hand. (1028, 1093). </think>\n<tool_call>\n{"name": "search_coordinate", "arguments": {"coordinate": [1028, 1093]}}\n</tool_call>']
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
**Important**: This model requires a system prompt for proper usage. Please see the model's chat template for details.
|
| 122 |
+
|
| 123 |
+
---
|
| 124 |
+
|
| 125 |
+
## Datasets and Training Data
|
| 126 |
+
|
| 127 |
+
Training datasets and generated reasoning chains are publicly available:
|
| 128 |
+
|
| 129 |
+
* [Code](https://github.com/Gabesarch/grounded-rl)
|
| 130 |
+
* [ViGoRL Datasets on Hugging Face](https://huggingface.co/datasets/gsarch/vigorl_datasets)
|
| 131 |
+
|
| 132 |
+
---
|
| 133 |
+
|
| 134 |
+
## Citation
|
| 135 |
+
|
| 136 |
+
If you use ViGoRL in your research or applications, please cite our paper:
|
| 137 |
+
|
| 138 |
+
```bibtex
|
| 139 |
+
@article{sarch2025vigorl,
|
| 140 |
+
title={Grounded Reinforcement Learning for Visual Reasoning},
|
| 141 |
+
author={Sarch, Gabriel and Saha, Snigdha and Khandelwal, Naitik and Jain, Ayush and Tarr, Michael J and Kumar, Aviral and Fragkiadaki, Katerina},
|
| 142 |
+
year={2025}
|
| 143 |
+
}
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
---
|
| 147 |
+
|
| 148 |
+
## Contact
|
| 149 |
+
|
| 150 |
+
For questions, feedback, or collaborations, please reach out to Gabriel Sarch or open an issue in our [GitHub repository](https://github.com/Gabesarch/grounded-rl).
|
| 151 |
+
|
| 152 |
+
---
|