Views
No views yet
1from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
2from qwen_vl_utils import process_vision_info
3
4instruct_prompt = r"You FIRST think about the reasoning process as an internal monologue and then provide the final answer. The reasoning process MUST BE enclosed within <think> </think> tags. The final answer MUST BE put in \boxed{}."
5
6model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
7 "russwang/ThinkLite-VL-7B", torch_dtype="auto", device_map="auto"
8)
9
10processor = AutoProcessor.from_pretrained("russwang/ThinkLite-VL-7B")
11
12greedy_generation_config = GenerationConfig(
13 do_sample=False,
14 max_new_tokens=2048
15 )
16
17messages = [
18 {
19 "role": "user",
20 "content": [
21 {
22 "type": "image",
23 "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
24 },
25 {"type": "text", "text": "Describe this image." + instruct_prompt},
26 ],
27 }
28]
29
30text = processor.apply_chat_template(
31 messages, tokenize=False, add_generation_prompt=True
32)
33
34inputs = processor(
35 text=text,
36 images=image_inputs,
37 padding=True,
38 return_tensors="pt",
39).to("cuda")
40
41output = model.generate(
42 **inputs,
43 generation_config=greedy_generation_config,
44 tokenizer=processor.tokenizer
45)
46output_text = processor.decode(
47 output[0],
48 skip_special_tokens=True,
49 clean_up_tokenization_spaces=False
50)
51
52print(output_text)@article{wang2025sota,
title={SoTA with Less: MCTS-Guided Sample Selection for Data-Efficient Visual Reasoning Self-Improvement},
author={Wang, Xiyao and Yang, Zhengyuan and Feng, Chao and Lu, Hongjin and Li, Linjie and Lin, Chung-Ching and Lin, Kevin and Huang, Furong and Wang, Lijuan},
journal={arXiv preprint arXiv:2504.07934},
year={2025}
}