Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3
4example={
5 "image": "./Geo170K/images/test/0.png", ### your image path
6 "problem": "As shown in the figure, in triangle ABC, it is known that angle A = 80.0, angle B = 60.0, DE parallel BC, then the size of angle CED is ()",
7
8}
9
10def make_conversation_image(example):
11 return {
12 'image': example['image'], # Store path instead of loaded image
13 'prompt': [{
14 'role': 'user',
15 'content': [
16 {'type': 'image', 'text': None},
17 {'type': 'text', 'text': example['problem']}
18 ]
19 }]
20 }
21
22model_name = "kolerk/TON-3B-AITZ"
23
24model = AutoModelForCausalLM.from_pretrained(
25 model_name,
26 torch_dtype="auto",
27 device_map="auto"
28)
29tokenizer = AutoTokenizer.from_pretrained(model_name)
30
31
32text = tokenizer.apply_chat_template(
33 make_conversation_image(example),
34 tokenize=False,
35 add_generation_prompt=True
36)
37model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
38
39generated_ids = model.generate(
40 **model_inputs,
41 max_new_tokens=4096,
42 top_p=0.95,
43 top_k=1,
44 temperature=0.6
45)
46generated_ids = [
47 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
48]
49
50response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
51print(response)@misc{wang2025think,
title={Think or Not? Selective Reasoning via Reinforcement Learning for Vision-Language Models},
author={Jiaqi Wang and Kevin Qinghong Lin and James Cheng and Mike Zheng Shou},
year={2025},
eprint={2505.16854},
archivePrefix={arXiv},
primaryClass={cs.AI}
}