Views
No views yet
| QVQ-72B-Preview | o1-2024-12-17 | gpt-4o-2024-05-13 | Claude3.5 Sonnet-20241022 | Qwen2VL-72B | |
|---|---|---|---|---|---|
| MMMU(val) | 70.3 | 77.3 | 69.1 | 70.4 | 64.5 |
| MathVista(mini) | 71.4 | 71.0 | 63.8 | 65.3 | 70.5 |
| MathVision(full) | 35.9 | – | 30.4 | 35.6 | 25.9 |
| OlympiadBench | 20.4 | – | 25.9 | – | 11.2 |
pip install qwen-vl-utilstransformers and qwen_vl_utils:1from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
2from qwen_vl_utils import process_vision_info
3
4# default: Load the model on the available device(s)
5model = Qwen2VLForConditionalGeneration.from_pretrained(
6 "Qwen/QVQ-72B-Preview", torch_dtype="auto", device_map="auto"
7)
8
9# default processer
10processor = AutoProcessor.from_pretrained("Qwen/QVQ-72B-Preview")
11
12# The default range for the number of visual tokens per image in the model is 4-16384. You can set min_pixels and max_pixels according to your needs, such as a token count range of 256-1280, to balance speed and memory usage.
13# min_pixels = 256*28*28
14# max_pixels = 1280*28*28
15# processor = AutoProcessor.from_pretrained("Qwen/QVQ-72B-Preview", min_pixels=min_pixels, max_pixels=max_pixels)
16
17messages = [
18 {
19 "role": "system",
20 "content": [
21 {"type": "text", "text": "You are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step."}
22 ],
23 },
24 {
25 "role": "user",
26 "content": [
27 {
28 "type": "image",
29 "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/QVQ/demo.png",
30 },
31 {"type": "text", "text": "What value should be filled in the blank space?"},
32 ],
33 }
34]
35
36# Preparation for inference
37text = processor.apply_chat_template(
38 messages, tokenize=False, add_generation_prompt=True
39)
40image_inputs, video_inputs = process_vision_info(messages)
41inputs = processor(
42 text=[text],
43 images=image_inputs,
44 videos=video_inputs,
45 padding=True,
46 return_tensors="pt",
47)
48inputs = inputs.to("cuda")
49
50# Inference: Generation of the output
51generated_ids = model.generate(**inputs, max_new_tokens=8192)
52generated_ids_trimmed = [
53 out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
54]
55output_text = processor.batch_decode(
56 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
57)
58print(output_text)@misc{qvq-72b-preview,
title = {QVQ: To See the World with Wisdom},
url = {https://qwenlm.github.io/blog/qvq-72b-preview/},
author = {Qwen Team},
month = {December},
year = {2024}
}
@article{Qwen2VL,
title={Qwen2-VL: Enhancing Vision-Language Model's Perception of the World at Any Resolution},
author={Wang, Peng and Bai, Shuai and Tan, Sinan and Wang, Shijie and Fan, Zhihao and Bai, Jinze and Chen, Keqin and Liu, Xuejing and Wang, Jialin and Ge, Wenbin and Fan, Yang and Dang, Kai and Du, Mengfei and Ren, Xuancheng and Men, Rui and Liu, Dayiheng and Zhou, Chang and Zhou, Jingren and Lin, Junyang},
journal={arXiv preprint arXiv:2409.12191},
year={2024}
}