Update README.md
Browse files
README.md
CHANGED
|
@@ -11,15 +11,19 @@ library_name: transformers
|
|
| 11 |
|
| 12 |
This repository contains the model presented in: [OneThinker: All-in-one Reasoning Model for Image and Video](https://huggingface.co/papers/2512.03043)
|
| 13 |
|
|
|
|
|
|
|
| 14 |
**Project Page**: https://github.com/tulerfeng/OneThinker
|
| 15 |
**Code**: https://github.com/tulerfeng/OneThinker
|
| 16 |
|
|
|
|
| 17 |
## 👀 About OneThinker
|
| 18 |
|
| 19 |
<div align="center">
|
| 20 |
-
<img src="https://
|
| 21 |
-
</div>
|
| 22 |
|
|
|
|
|
|
|
| 23 |
We introduce **OneThinker**, an all-in-one multimodal reasoning generalist that is **capable of thinking across a wide range of fundamental visual tasks within a single model**.
|
| 24 |
|
| 25 |
We construct the large-scale **OneThinker-600k** multi-task training corpus and build **OneThinker-SFT-340k** with high-quality CoT annotations for cold-start SFT. Moreover, we propose **EMA-GRPO**, a new RL method that **balances heterogeneous reward signals across diverse visual tasks**, via simply tracking task-wise moving averages of reward std.
|
|
@@ -28,32 +32,13 @@ OneThinker demonstrates **strong performance on 31 benchmarks across 10 fundamen
|
|
| 28 |
|
| 29 |
All code, models, and data are fully released.
|
| 30 |
|
| 31 |
-
## 🔥 News
|
| 32 |
-
- [2025/12/03] We release the code, model, data of OneThinker
|
| 33 |
-
|
| 34 |
-
## 📍 Features
|
| 35 |
-
|
| 36 |
-
+ Support Qwen3-VL Training
|
| 37 |
-
+ Support Image-Video mixed training
|
| 38 |
-
+ Support reward types in diverse visual tasks
|
| 39 |
-
+ Provide full pipeline (dataset, SFT training, RL training, evaluation, etc)
|
| 40 |
-
|
| 41 |
-
## 🔍 Dataset
|
| 42 |
-
|
| 43 |
-
Our dataset covers both image and video modalities and spans a series of fundamental visual reasoning tasks, including rule-based QA, open-ended QA, captioning, spatial grounding, temporal grounding, spatio-temporal grounding, tracking, and segmentation
|
| 44 |
-
|
| 45 |
-
<div align="center">
|
| 46 |
-
<img src="https://huggingface.co/datasets/OneThink/OneThinker-8B/resolve/main/assets/dataset.png" alt="Descriptive alt text" width="90%">
|
| 47 |
-
</div>
|
| 48 |
-
|
| 49 |
-
To enable effective SFT initialization for reasoning, we leverage a strong proprietary model, Seed1.5-VL to produce CoT annotations.
|
| 50 |
|
| 51 |
## 🏆 Performance
|
| 52 |
|
| 53 |
Our model obtains significant performance gains after training based on Qwen3-VL-Instruct-8B across diverse visual tasks. For examle, OneThinker-8B reaches 70.6% accuracy on MMMU, 64.3% on MathVerse, 66.2% on VideoMMMU, 93.7 on Refcoco-testA, 54.9 J&F on ReasonVOS.
|
| 54 |
|
| 55 |
<div align="center">
|
| 56 |
-
<img src="https://
|
| 57 |
</div>
|
| 58 |
|
| 59 |
Besides, we also observe beneficial cross-task and cross-modality knowledge transfer, along with promising preliminary zero-shot generalization under unified training. This highlights the effectiveness and generalization ability of our unified training framework across diverse visual tasks.
|
|
@@ -66,7 +51,7 @@ Some reasoning examples are as follows.
|
|
| 66 |
<summary>Demo 1 (QA)</summary>
|
| 67 |
|
| 68 |
<div align="center">
|
| 69 |
-
<img src="https://
|
| 70 |
</div>
|
| 71 |
|
| 72 |
**Question:**
|
|
@@ -96,7 +81,7 @@ AB is diameter, so ∠ACB = 90°, ∠ADB = 90°. In △ABD, ∠BAD = 90° - 50°
|
|
| 96 |
<summary>Demo 2 (Tracking)</summary>
|
| 97 |
|
| 98 |
<div align="center">
|
| 99 |
-
<img src="https://
|
| 100 |
</div>
|
| 101 |
|
| 102 |
**Question:**
|
|
@@ -116,7 +101,7 @@ Given the bounding box [537,403,768,703] of the target object in the first frame
|
|
| 116 |
<summary>Demo 3 (Segmentation)</summary>
|
| 117 |
|
| 118 |
<div align="center">
|
| 119 |
-
<img src="https://
|
| 120 |
</div>
|
| 121 |
|
| 122 |
**Question:**
|
|
@@ -132,156 +117,6 @@ Pleae segment the shorter one.
|
|
| 132 |
|
| 133 |
</details>
|
| 134 |
|
| 135 |
-
## 🚀 Quick Start (Inference)
|
| 136 |
-
|
| 137 |
-
Here's a simple example to run inference with the OneThinker model using the Hugging Face `transformers` library:
|
| 138 |
-
|
| 139 |
-
```python
|
| 140 |
-
import numpy as np
|
| 141 |
-
import torch
|
| 142 |
-
from PIL import Image
|
| 143 |
-
from transformers import AutoProcessor, AutoModelForCausalLM
|
| 144 |
-
|
| 145 |
-
# Load model and processor
|
| 146 |
-
model_id = "OneThink/OneThinker-8B" # This model
|
| 147 |
-
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
|
| 148 |
-
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True).eval()
|
| 149 |
-
|
| 150 |
-
# Example 1: Image QA
|
| 151 |
-
print("--- Image QA Demo ---")
|
| 152 |
-
# Replace with a valid local path to your image, e.g., downloaded from the GitHub repo or assets
|
| 153 |
-
image_path = "./assets/math.png"
|
| 154 |
-
try:
|
| 155 |
-
image = Image.open(image_path).convert("RGB")
|
| 156 |
-
except FileNotFoundError:
|
| 157 |
-
print(f"Warning: Image '{image_path}' not found. Using a placeholder image.")
|
| 158 |
-
image = Image.new('RGB', (500, 500), color = 'blue') # Placeholder if image not found
|
| 159 |
-
|
| 160 |
-
prompt_qa = "As shown in the figure, AB is the diameter of ⊙O, and points C and D are on ⊙O. If ∠ABD = 50.0, then the degree of ∠BCD is () Choices: (A) 30° (B) 35° (C) 40° (D) 45°"
|
| 161 |
-
|
| 162 |
-
messages_qa = [
|
| 163 |
-
{"role": "user", "content": [
|
| 164 |
-
{"type": "image", "content": image},
|
| 165 |
-
{"type": "text", "content": prompt_qa}
|
| 166 |
-
]}
|
| 167 |
-
]
|
| 168 |
-
input_ids = processor.apply_chat_template(messages_qa, tokenize=True, add_generation_prompt=True, return_tensors="pt", max_new_tokens=2048)
|
| 169 |
-
inputs = processor(messages_qa, return_tensors="pt")
|
| 170 |
-
inputs = {k: v.to(model.device) for k, v in inputs.items()}
|
| 171 |
-
|
| 172 |
-
with torch.no_grad():
|
| 173 |
-
output_ids = model.generate(**inputs, max_new_tokens=2048)
|
| 174 |
-
output_text = processor.batch_decode(output_ids[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0]
|
| 175 |
-
print(f"Question: {prompt_qa}
|
| 176 |
-
Answer: {output_text}
|
| 177 |
-
")
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
# Example 2: Video Tracking (Conceptual/Simplified)
|
| 181 |
-
print("--- Video Tracking Demo (Conceptual/Simplified) ---")
|
| 182 |
-
# For full video processing, refer to the scripts in the original GitHub repository.
|
| 183 |
-
# This is a simplified example showing how to pass video frames.
|
| 184 |
-
# In a real scenario, you would load a sequence of actual video frames:
|
| 185 |
-
# video_frames_list = [Image.open(f"path/to/video_frame_{i:04d}.jpg").convert("RGB") for i in range(num_frames)]
|
| 186 |
-
# For demonstration, we'll use a list of placeholder images:
|
| 187 |
-
video_frames_list = [Image.new('RGB', (224, 224), color = 'red') for _ in range(5)] # 5 placeholder frames
|
| 188 |
-
|
| 189 |
-
prompt_tracking = "Given the bounding box [537,403,768,703] of the target object in the first frame, track this object in each frame."
|
| 190 |
-
|
| 191 |
-
messages_tracking = [
|
| 192 |
-
{"role": "user", "content": [
|
| 193 |
-
{"type": "video", "content": video_frames_list}, # Pass video frames directly
|
| 194 |
-
{"type": "text", "content": prompt_tracking}
|
| 195 |
-
]}
|
| 196 |
-
]
|
| 197 |
-
inputs_tracking = processor(messages_tracking, return_tensors="pt")
|
| 198 |
-
inputs_tracking = {k: v.to(model.device) for k, v in inputs_tracking.items()}
|
| 199 |
-
|
| 200 |
-
with torch.no_grad():
|
| 201 |
-
output_ids_tracking = model.generate(**inputs_tracking, max_new_tokens=2048)
|
| 202 |
-
output_text_tracking = processor.batch_decode(output_ids_tracking[:, inputs_tracking["input_ids"].shape[1]:], skip_special_tokens=True)[0]
|
| 203 |
-
print(f"Question: {prompt_tracking}
|
| 204 |
-
Answer: {output_text_tracking}
|
| 205 |
-
")
|
| 206 |
-
```
|
| 207 |
-
|
| 208 |
-
## 📐 Set up
|
| 209 |
-
|
| 210 |
-
```bash
|
| 211 |
-
git clone https://github.com/tulerfeng/OneThinker
|
| 212 |
-
cd OneThinker
|
| 213 |
-
|
| 214 |
-
# build SFT environment
|
| 215 |
-
conda create -n llamafactory python=3.11
|
| 216 |
-
conda activate llamafactory
|
| 217 |
-
cd LLaMA-Factory
|
| 218 |
-
pip install -e ".[torch,metrics]" --no-build-isolation
|
| 219 |
-
|
| 220 |
-
# build RL environment
|
| 221 |
-
conda create -n easyr1 python=3.11
|
| 222 |
-
conda activate easyr1
|
| 223 |
-
cd EasyR1
|
| 224 |
-
pip install -e .
|
| 225 |
-
|
| 226 |
-
```
|
| 227 |
-
|
| 228 |
-
For more details for the SFT and RL environment installation, please refer to [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory), [EasyR1](https://github.com/hiyouga/EasyR1)
|
| 229 |
-
|
| 230 |
-
Then, download the training datasets [[🤗 OneThinker-train-data](https://huggingface.co/datasets/OneThink/OneThinker-train-data)] and unzip all the data.
|
| 231 |
-
|
| 232 |
-
The `onethinker_rl_train.json` file is for RL training while `onethinker_sft_image.json` and `onethinker_sft_video.json` is for SFT cold start. The json files end with `_unsampled` are unsampled full set.
|
| 233 |
-
|
| 234 |
-
## 🚀 Training
|
| 235 |
-
|
| 236 |
-
For SFT and RL training, a minimum of 8 × 80GB GPUs is required; alternatively, you may reduce the number of frames or the input resolution.
|
| 237 |
-
|
| 238 |
-
We first perform SFT cold start.
|
| 239 |
-
|
| 240 |
-
```bash
|
| 241 |
-
bash ./LLaMA-Factory/local_scripts/run_onethinker_sft.sh
|
| 242 |
-
```
|
| 243 |
-
If you want to skip the SFT process, we also provide our SFT model at [🤗[OneThinker-SFT-model](https://huggingface.co/OneThink/OneThinker-SFT-Qwen3-8B)]
|
| 244 |
-
|
| 245 |
-
Then, we perform RL training as follows
|
| 246 |
-
|
| 247 |
-
```bash
|
| 248 |
-
bash ./EasyR1/local_scripts/run_onethinker_rl.sh
|
| 249 |
-
```
|
| 250 |
-
|
| 251 |
-
For setting Ray in multi-node training, please refer to [EasyR1](https://github.com/hiyouga/EasyR1), or you may use single-node training by setting `NNODES=1`. Performing RL training for about 200 steps can already yield strong performance.
|
| 252 |
-
|
| 253 |
-
If you want to use model-based rewards for open-ended problem, please use vllm to lanuch [POLAR-7B](https://github.com/InternLM/POLAR) and revised the setting in `/EasyR1/verl/reward_function/onethinker_reward.py`
|
| 254 |
-
|
| 255 |
-
## 🔮 Inference & Evaluation
|
| 256 |
-
|
| 257 |
-
For the majority of tasks and benchmarks, we recommend using our provided json files and scripts for easier evaluation.
|
| 258 |
-
|
| 259 |
-
The json files can be downloaded at: [🤗 [OneThinker-eval](https://huggingface.co/datasets/OneThink/OneThinker-eval)]
|
| 260 |
-
|
| 261 |
-
Download the trained model [[🤗 OneThinker-8B-model](https://huggingface.co/OneThink/OneThinker-8B)]
|
| 262 |
-
|
| 263 |
-
Conduct evaluation on all benchmarks using the following scripts
|
| 264 |
-
|
| 265 |
-
```bash
|
| 266 |
-
bash ./Evaluation/Eval/eval_bench_all.sh
|
| 267 |
-
```
|
| 268 |
-
If you want to perform evaluation on segmentation tasks, please download and install [sam2](https://github.com/facebookresearch/sam2) and revise the related path in `/Evaluation/Eval/seg_post_sam2.py`
|
| 269 |
-
|
| 270 |
-
For image QA and part of video QA, we use [VLMEvalKit](https://github.com/open-compass/VLMEvalKit) for evaluation, please install corresponding environment and run:
|
| 271 |
-
|
| 272 |
-
```bash
|
| 273 |
-
bash ./Evaluation/VLMEvalKit/local_scripts/eval_vlmevalkit.sh
|
| 274 |
-
```
|
| 275 |
-
|
| 276 |
-
For infernce on a single example, you may refer to:
|
| 277 |
-
|
| 278 |
-
```bash
|
| 279 |
-
python ./Evaluation/inference_single/inference.py
|
| 280 |
-
```
|
| 281 |
-
|
| 282 |
-
## Acknowledgements
|
| 283 |
-
|
| 284 |
-
We sincerely appreciate the contributions of the open-source community. The related projects are as follows: [Video-R1](https://github.com/tulerfeng/Video-R1), [DeepSeek-R1](https://github.com/deepseek-ai/DeepSeek-R1), [EasyR1](https://github.com/hiyouga/EasyR1), [verl](https://github.com/volcengine/verl), [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory), [VLMEvalKit](https://github.com/open-compass/VLMEvalKit)
|
| 285 |
|
| 286 |
## Citations
|
| 287 |
|
|
|
|
| 11 |
|
| 12 |
This repository contains the model presented in: [OneThinker: All-in-one Reasoning Model for Image and Video](https://huggingface.co/papers/2512.03043)
|
| 13 |
|
| 14 |
+
For inference, please refer to:
|
| 15 |
+
|
| 16 |
**Project Page**: https://github.com/tulerfeng/OneThinker
|
| 17 |
**Code**: https://github.com/tulerfeng/OneThinker
|
| 18 |
|
| 19 |
+
|
| 20 |
## 👀 About OneThinker
|
| 21 |
|
| 22 |
<div align="center">
|
| 23 |
+
<img src="https://github.com/tulerfeng/OneThinker/blob/main/assets/teaser.png?raw=true" alt="OneThinker teaser" width="95%">
|
|
|
|
| 24 |
|
| 25 |
+
|
| 26 |
+
</div>
|
| 27 |
We introduce **OneThinker**, an all-in-one multimodal reasoning generalist that is **capable of thinking across a wide range of fundamental visual tasks within a single model**.
|
| 28 |
|
| 29 |
We construct the large-scale **OneThinker-600k** multi-task training corpus and build **OneThinker-SFT-340k** with high-quality CoT annotations for cold-start SFT. Moreover, we propose **EMA-GRPO**, a new RL method that **balances heterogeneous reward signals across diverse visual tasks**, via simply tracking task-wise moving averages of reward std.
|
|
|
|
| 32 |
|
| 33 |
All code, models, and data are fully released.
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
## 🏆 Performance
|
| 37 |
|
| 38 |
Our model obtains significant performance gains after training based on Qwen3-VL-Instruct-8B across diverse visual tasks. For examle, OneThinker-8B reaches 70.6% accuracy on MMMU, 64.3% on MathVerse, 66.2% on VideoMMMU, 93.7 on Refcoco-testA, 54.9 J&F on ReasonVOS.
|
| 39 |
|
| 40 |
<div align="center">
|
| 41 |
+
<img src="https://github.com/tulerfeng/OneThinker/blob/main/assets/performance.png?raw=true" alt="Descriptive alt text" width="90%">
|
| 42 |
</div>
|
| 43 |
|
| 44 |
Besides, we also observe beneficial cross-task and cross-modality knowledge transfer, along with promising preliminary zero-shot generalization under unified training. This highlights the effectiveness and generalization ability of our unified training framework across diverse visual tasks.
|
|
|
|
| 51 |
<summary>Demo 1 (QA)</summary>
|
| 52 |
|
| 53 |
<div align="center">
|
| 54 |
+
<img src="https://github.com/tulerfeng/OneThinker/blob/main/assets/math.png?raw=true" width="36%">
|
| 55 |
</div>
|
| 56 |
|
| 57 |
**Question:**
|
|
|
|
| 81 |
<summary>Demo 2 (Tracking)</summary>
|
| 82 |
|
| 83 |
<div align="center">
|
| 84 |
+
<img src="https://github.com/tulerfeng/OneThinker/blob/main/assets/got_car.gif?raw=true" width="60%">
|
| 85 |
</div>
|
| 86 |
|
| 87 |
**Question:**
|
|
|
|
| 101 |
<summary>Demo 3 (Segmentation)</summary>
|
| 102 |
|
| 103 |
<div align="center">
|
| 104 |
+
<img src="https://github.com/tulerfeng/OneThinker/blob/main/assets/lalaland.gif?raw=true" width="60%">
|
| 105 |
</div>
|
| 106 |
|
| 107 |
**Question:**
|
|
|
|
| 117 |
|
| 118 |
</details>
|
| 119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
## Citations
|
| 122 |
|