Update README.md
Browse files
README.md
CHANGED
|
@@ -8,4 +8,94 @@ base_model:
|
|
| 8 |
- Qwen/Qwen2.5-VL-3B-Instruct
|
| 9 |
pipeline_tag: image-text-to-text
|
| 10 |
---
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
- Qwen/Qwen2.5-VL-3B-Instruct
|
| 9 |
pipeline_tag: image-text-to-text
|
| 10 |
---
|
| 11 |
+
# TON-AITZ
|
| 12 |
+
TON is a series of large language models trained using our efficient algorithm, which automatically decides whether to think or not, based on Qwen2.5-VL.
|
| 13 |
+
We apply Group Relative Policy Optimization (GRPO) for reinforcement learning with "thought dropout" supervised finetuning as a prelimary step.
|
| 14 |
+
## Introduction
|
| 15 |
+
|
| 16 |
+
Reinforcement Learning (RL) has proven to be an effective post-training strategy for enhancing reasoning in vision–language models (VLMs). Group Relative Policy Optimization (GRPO) is a recent prominent method that encourages models to generate complete reasoning traces before answering, leading to increased token usage and computational cost. Inspired by the human-like thinking process—where people skip reasoning for easy questions but think carefully when needed—we explore how to enable VLMs to first decide *when reasoning is necessary*. To realize this, we propose *TON*, a two-stage training strategy:
|
| 17 |
+
|
| 18 |
+
1. **(i)** A supervised fine-tuning (SFT) stage with a simple yet effective “**thought dropout**” operation, where reasoning traces are randomly replaced with empty thoughts. This introduces a think-or-not format that serves as a cold start for selective reasoning.
|
| 19 |
+
2. **(ii)** A GRPO stage that enables the model to freely explore when to think or not, while maximizing task-aware outcome rewards.
|
| 20 |
+
|
| 21 |
+
Experimental results show that *TON* can *reduce the completion length by up to **90%** compared to vanilla GRPO, without sacrificing performance or even improving it*. Further evaluations across diverse vision-language tasks—covering a range of reasoning difficulties under both 3B and 7B models—consistently reveal that the *model progressively learns to bypass unnecessary reasoning steps as training advances*. These findings shed light on the path toward human-like reasoning patterns in reinforcement learning approaches.
|
| 22 |
+
|
| 23 |
+
## Quickstart
|
| 24 |
+
|
| 25 |
+
```python
|
| 26 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
example={
|
| 30 |
+
'image': your_image_path,
|
| 31 |
+
'problem': 'You are an assistant trained to navigate the mobile phone. \nGiven a task instruction, a screen observation, and an action history sequence, \noutput the next action and wait for the next observation. \nHere is the action space:\n1. `CLICK`: Click on an element, value is not applicable and the position [x,y] is required. \n2. `TYPE`: Type a string into an element, value is a string to type and the position is not applicable.\n3. `SCROLL UP`: Scroll up for the screen.\n4. `SCROLL DOWN`: Scroll down for the screen.\n5. `SCROLL LEFT`: Scroll left for the screen.\n6. `SCROLL RIGHT`: Scroll right for the screen.\n7. `PRESS BACK`: Press for returning to the previous step, value and position are not applicable.\n8. `PRESS HOME`: Press for returning to the home screen, value and position are not applicable.\n9. `PRESS ENTER`: Press for submitting the input content, value and position are not applicable.\n10. `STATUS TASK COMPLETE`: Indicate the task is completed, value and position are not applicable.\n\nFormat the action as a dictionary with the following keys:\n{'action': 'ACTION_TYPE', 'value': 'element', 'position': [x,y]}\n\nIf value or position is not applicable, set it as `None`.\nPosition represents the relative coordinates on the screenshot and should be scaled to a range of 0-1.\n\n**Please first thinks about the reasoning process in the mind and then provides the user with the action. The reasoning process and answer are enclosed within <think> </think> and <action> </action> tags, respectively, i.e., <think> reasoning process here </think><action> action here </action>**\nTask: Search for hotels in London\n'
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
def make_conversation_image(example):
|
| 35 |
+
return {
|
| 36 |
+
'image': example['image'], # Store path instead of loaded image
|
| 37 |
+
'prompt': [{
|
| 38 |
+
'role': 'user',
|
| 39 |
+
'content': [
|
| 40 |
+
{'type': 'image', 'text': None},
|
| 41 |
+
{'type': 'text', 'text': example['problem']}
|
| 42 |
+
]
|
| 43 |
+
}]
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
model_name = "kolerk/TON-3B-AITZ"
|
| 47 |
+
|
| 48 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 49 |
+
model_name,
|
| 50 |
+
torch_dtype="auto",
|
| 51 |
+
device_map="auto"
|
| 52 |
+
)
|
| 53 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
text = tokenizer.apply_chat_template(
|
| 57 |
+
make_conversation_image(example),
|
| 58 |
+
tokenize=False,
|
| 59 |
+
add_generation_prompt=True
|
| 60 |
+
)
|
| 61 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 62 |
+
|
| 63 |
+
generated_ids = model.generate(
|
| 64 |
+
**model_inputs,
|
| 65 |
+
max_new_tokens=4096,
|
| 66 |
+
top_p=0.95,
|
| 67 |
+
top_k=1,
|
| 68 |
+
temperature=0.6
|
| 69 |
+
)
|
| 70 |
+
generated_ids = [
|
| 71 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 72 |
+
]
|
| 73 |
+
|
| 74 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 75 |
+
print(response)
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
## Evaluation
|
| 79 |
+
|
| 80 |
+
Refer to our [code repository](https://github.com/kokolerk/TON/blob/970ba8ca9292ff204c6fc51d087492c2884b385e/src/eval/aitz_evaluate/test_qwen25vl_aitz_from_json.py#L231) for more details.
|
| 81 |
+
|
| 82 |
+
Briefly, you should first use llamafactory to test the data, and then use our tool to run the score.
|
| 83 |
+
|
| 84 |
+
## Citation
|
| 85 |
+
|
| 86 |
+
If you find our work helpful, feel free to give us a cite.
|
| 87 |
+
|
| 88 |
+
```
|
| 89 |
+
@misc{wang2025think,
|
| 90 |
+
title={Think or Not? Selective Reasoning via Reinforcement Learning for Vision-Language Models},
|
| 91 |
+
author={Jiaqi Wang and Kevin Qinghong Lin and James Cheng and Mike Zheng Shou},
|
| 92 |
+
year={2025},
|
| 93 |
+
eprint={2505.16854},
|
| 94 |
+
archivePrefix={arXiv},
|
| 95 |
+
primaryClass={cs.AI}
|
| 96 |
+
}
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
|