arnocandel chenkq commited on
Commit
c58d1c5
0 Parent(s):

Duplicate from Qwen/Qwen2-VL-2B-Instruct-GPTQ-Int4

Browse files

Co-authored-by: Keqin Chen <chenkq@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2024 Alibaba Cloud
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
README.md ADDED
@@ -0,0 +1,516 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ pipeline_tag: image-text-to-text
6
+ tags:
7
+ - multimodal
8
+ base_model: Qwen/Qwen2-VL-2B-Instruct
9
+ ---
10
+
11
+ # Qwen2-VL-2B-Instruct-GPTQ-Int4
12
+
13
+ ## Introduction
14
+
15
+ We're excited to unveil **Qwen2-VL**, the latest iteration of our Qwen-VL model, representing nearly a year of innovation.
16
+
17
+ ### What’s New in Qwen2-VL?
18
+
19
+ #### Key Enhancements:
20
+
21
+
22
+ * **SoTA understanding of images of various resolution & ratio**: Qwen2-VL achieves state-of-the-art performance on visual understanding benchmarks, including MathVista, DocVQA, RealWorldQA, MTVQA, etc.
23
+
24
+ * **Understanding videos of 20min+**: Qwen2-VL can understand videos over 20 minutes for high-quality video-based question answering, dialog, content creation, etc.
25
+
26
+ * **Agent that can operate your mobiles, robots, etc.**: with the abilities of complex reasoning and decision making, Qwen2-VL can be integrated with devices like mobile phones, robots, etc., for automatic operation based on visual environment and text instructions.
27
+
28
+ * **Multilingual Support**: to serve global users, besides English and Chinese, Qwen2-VL now supports the understanding of texts in different languages inside images, including most European languages, Japanese, Korean, Arabic, Vietnamese, etc.
29
+
30
+
31
+ #### Model Architecture Updates:
32
+
33
+ * **Naive Dynamic Resolution**: Unlike before, Qwen2-VL can handle arbitrary image resolutions, mapping them into a dynamic number of visual tokens, offering a more human-like visual processing experience.
34
+
35
+ <p align="center">
36
+ <img src="https://qianwen-res.oss-accelerate-overseas.aliyuncs.com/Qwen2-VL/qwen2_vl.jpg" width="80%"/>
37
+ <p>
38
+
39
+ * **Multimodal Rotary Position Embedding (M-ROPE)**: Decomposes positional embedding into parts to capture 1D textual, 2D visual, and 3D video positional information, enhancing its multimodal processing capabilities.
40
+
41
+ <p align="center">
42
+ <img src="http://qianwen-res.oss-accelerate-overseas.aliyuncs.com/Qwen2-VL/mrope.png" width="80%"/>
43
+ <p>
44
+
45
+ We have three models with 2, 7 and 72 billion parameters. This repo contains the quantized version of the instruction-tuned 2B Qwen2-VL model. For more information, visit our [Blog](https://qwenlm.github.io/blog/qwen2-vl/) and [GitHub](https://github.com/QwenLM/Qwen2-VL).
46
+
47
+
48
+
49
+ ### Benchmark
50
+ #### Performance of Quantized Models
51
+ This section reports the generation performance of quantized models (including GPTQ and AWQ) of the Qwen2-VL series. Specifically, we report:
52
+
53
+ - MMMU_VAL (Accuracy)
54
+ - DocVQA_VAL (Accuracy)
55
+ - MMBench_DEV_EN (Accuracy)
56
+ - MathVista_MINI (Accuracy)
57
+
58
+ We use [VLMEvalkit](https://github.com/kq-chen/VLMEvalKit/tree/add_qwen2vl) to evaluate all models.
59
+
60
+ | Model Size | Quantization | MMMU | DocVQA | MMBench | MathVista |
61
+ | --- | --- | --- | --- | --- | --- |
62
+ Qwen2-VL-2B-Instruct | BF16<br><sup>([🤗](https://huggingface.co/Qwen/Qwen2-VL-2B-Instruct)[🤖](https://modelscope.cn/models/qwen/Qwen2-VL-2B-Instruct)) | 41.88 | 88.34 | 72.07 | 44.40 |
63
+ | | GPTQ-Int8<br><sup>([🤗](https://huggingface.co/Qwen/Qwen2-VL-2B-Instruct-GPTQ-Int8)[🤖](https://modelscope.cn/models/qwen/Qwen2-VL-2B-Instruct-GPTQ-Int8)) | 41.55 | 88.28 | 71.99 | 44.60 |
64
+ | | GPTQ-Int4<br><sup>([🤗](https://huggingface.co/Qwen/Qwen2-VL-2B-Instruct-GPTQ-Int4)[🤖](https://modelscope.cn/models/qwen/Qwen2-VL-2B-Instruct-GPTQ-Int4)) | 39.22 | 87.21 | 70.87 | 41.69 |
65
+ | | AWQ<br><sup>([🤗](https://huggingface.co/Qwen/Qwen2-VL-2B-Instruct-AWQ)[🤖](https://modelscope.cn/models/qwen/Qwen2-VL-2B-Instruct-AWQ)) | 41.33 | 86.96 | 71.64 | 39.90 |
66
+
67
+
68
+ #### Speed Benchmark
69
+ This section reports the speed performance of bf16 models, quantized models (including GPTQ-Int4, GPTQ-Int8 and AWQ) of the Qwen2-VL series. Specifically, we report the inference speed (tokens/s) as well as memory footprint (GB) under the conditions of different context lengths.
70
+
71
+ The environment of the evaluation with huggingface transformers is:
72
+
73
+ - NVIDIA A100 80GB
74
+ - CUDA 11.8
75
+ - Pytorch 2.2.1+cu118
76
+ - Flash Attention 2.6.1
77
+ - Transformers 4.38.2
78
+ - AutoGPTQ 0.6.0+cu118
79
+ - AutoAWQ 0.2.5+cu118 (autoawq_kernels 0.0.6+cu118)
80
+
81
+ Note:
82
+
83
+ - We use the batch size of 1 and the least number of GPUs as possible for the evalution.
84
+ - We test the speed and memory of generating 2048 tokens with the input lengths of 1, 6144, 14336, 30720, 63488, and 129024 tokens.
85
+ - 2B (transformers)
86
+
87
+ | Model | Input Length | Quantization | GPU Num | Speed(tokens/s) | GPU Memory(GB) |
88
+ | --- | --- | --- | --- | --- | --- |
89
+ | Qwen2-VL-2B-Instruct | 1 | BF16 | 1 | 35.29 | 4.68 |
90
+ | | | GPTQ-Int8 | 1 | 28.59 | 3.55 |
91
+ | | | GPTQ-Int4 | 1 | 39.76 | 2.91 |
92
+ | | | AWQ | 1 | 29.89 | 2.88 |
93
+ | | 6144 | BF16 | 1 | 36.58 | 10.01 |
94
+ | | | GPTQ-Int8 | 1 | 29.53 | 8.87 |
95
+ | | | GPTQ-Int4 | 1 | 39.27 | 8.21 |
96
+ | | | AWQ | 1 | 33.42 | 8.18 |
97
+ | | 14336 | BF16 | 1 | 36.31 | 17.20 |
98
+ | | | GPTQ-Int8 | 1 | 31.03 | 16.07 |
99
+ | | | GPTQ-Int4 | 1 | 39.89 | 15.40 |
100
+ | | | AWQ | 1 | 32.28 | 15.40 |
101
+ | | 30720 | BF16 | 1 | 32.53 | 31.64 |
102
+ | | | GPTQ-Int8 | 1 | 27.76 | 30.51 |
103
+ | | | GPTQ-Int4 | 1 | 30.73 | 29.84 |
104
+ | | | AWQ | 1 | 31.55 | 29.84 |
105
+
106
+ ## Requirements
107
+ The code of Qwen2-VL has been in the latest Hugging face transformers and we advise you to build from source with command `pip install git+https://github.com/huggingface/transformers`, or you might encounter the following error:
108
+ ```
109
+ KeyError: 'qwen2_vl'
110
+ ```
111
+
112
+ ## Quickstart
113
+ We offer a toolkit to help you handle various types of visual input more conveniently. This includes base64, URLs, and interleaved images and videos. You can install it using the following command:
114
+
115
+ ```bash
116
+ pip install qwen-vl-utils
117
+ ```
118
+
119
+ Here we show a code snippet to show you how to use the chat model with `transformers` and `qwen_vl_utils`:
120
+
121
+ ```python
122
+ from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
123
+ from qwen_vl_utils import process_vision_info
124
+
125
+ # default: Load the model on the available device(s)
126
+ model = Qwen2VLForConditionalGeneration.from_pretrained(
127
+ "Qwen/Qwen2-VL-2B-Instruct-GPTQ-Int4", torch_dtype="auto", device_map="auto"
128
+ )
129
+
130
+ # We recommend enabling flash_attention_2 for better acceleration and memory saving, especially in multi-image and video scenarios.
131
+ # model = Qwen2VLForConditionalGeneration.from_pretrained(
132
+ # "Qwen/Qwen2-VL-2B-Instruct-GPTQ-Int4",
133
+ # torch_dtype=torch.bfloat16,
134
+ # attn_implementation="flash_attention_2",
135
+ # device_map="auto",
136
+ # )
137
+
138
+ # default processer
139
+ processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-2B-Instruct-GPTQ-Int4")
140
+
141
+ # 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.
142
+ # min_pixels = 256*28*28
143
+ # max_pixels = 1280*28*28
144
+ # processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-2B-Instruct-GPTQ-Int4", min_pixels=min_pixels, max_pixels=max_pixels)
145
+
146
+
147
+ messages = [
148
+ {
149
+ "role": "user",
150
+ "content": [
151
+ {
152
+ "type": "image",
153
+ "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
154
+ },
155
+ {"type": "text", "text": "Describe this image."},
156
+ ],
157
+ }
158
+ ]
159
+
160
+ # Preparation for inference
161
+ text = processor.apply_chat_template(
162
+ messages, tokenize=False, add_generation_prompt=True
163
+ )
164
+ image_inputs, video_inputs = process_vision_info(messages)
165
+ inputs = processor(
166
+ text=[text],
167
+ images=image_inputs,
168
+ videos=video_inputs,
169
+ padding=True,
170
+ return_tensors="pt",
171
+ )
172
+ inputs = inputs.to("cuda")
173
+
174
+ # Inference: Generation of the output
175
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
176
+ generated_ids_trimmed = [
177
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
178
+ ]
179
+ output_text = processor.batch_decode(
180
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
181
+ )
182
+ print(output_text)
183
+ ```
184
+ <details>
185
+ <summary>Without qwen_vl_utils</summary>
186
+
187
+ ```python
188
+ from PIL import Image
189
+ import requests
190
+ import torch
191
+ from torchvision import io
192
+ from typing import Dict
193
+ from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
194
+
195
+ # Load the model in half-precision on the available device(s)
196
+ model = Qwen2VLForConditionalGeneration.from_pretrained(
197
+ "Qwen/Qwen2-VL-2B-Instruct-GPTQ-Int4", torch_dtype="auto", device_map="auto"
198
+ )
199
+ processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-2B-Instruct-GPTQ-Int4")
200
+
201
+ # Image
202
+ url = "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
203
+ image = Image.open(requests.get(url, stream=True).raw)
204
+
205
+ conversation = [
206
+ {
207
+ "role": "user",
208
+ "content": [
209
+ {
210
+ "type": "image",
211
+ },
212
+ {"type": "text", "text": "Describe this image."},
213
+ ],
214
+ }
215
+ ]
216
+
217
+
218
+ # Preprocess the inputs
219
+ text_prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
220
+ # Excepted output: '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|>Describe this image.<|im_end|>\n<|im_start|>assistant\n'
221
+
222
+ inputs = processor(
223
+ text=[text_prompt], images=[image], padding=True, return_tensors="pt"
224
+ )
225
+ inputs = inputs.to("cuda")
226
+
227
+ # Inference: Generation of the output
228
+ output_ids = model.generate(**inputs, max_new_tokens=128)
229
+ generated_ids = [
230
+ output_ids[len(input_ids) :]
231
+ for input_ids, output_ids in zip(inputs.input_ids, output_ids)
232
+ ]
233
+ output_text = processor.batch_decode(
234
+ generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True
235
+ )
236
+ print(output_text)
237
+ ```
238
+ </details>
239
+
240
+ <details>
241
+ <summary>Multi image inference</summary>
242
+
243
+ ```python
244
+ # Messages containing multiple images and a text query
245
+ messages = [
246
+ {
247
+ "role": "user",
248
+ "content": [
249
+ {"type": "image", "image": "file:///path/to/image1.jpg"},
250
+ {"type": "image", "image": "file:///path/to/image2.jpg"},
251
+ {"type": "text", "text": "Identify the similarities between these images."},
252
+ ],
253
+ }
254
+ ]
255
+
256
+ # Preparation for inference
257
+ text = processor.apply_chat_template(
258
+ messages, tokenize=False, add_generation_prompt=True
259
+ )
260
+ image_inputs, video_inputs = process_vision_info(messages)
261
+ inputs = processor(
262
+ text=[text],
263
+ images=image_inputs,
264
+ videos=video_inputs,
265
+ padding=True,
266
+ return_tensors="pt",
267
+ )
268
+ inputs = inputs.to("cuda")
269
+
270
+ # Inference
271
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
272
+ generated_ids_trimmed = [
273
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
274
+ ]
275
+ output_text = processor.batch_decode(
276
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
277
+ )
278
+ print(output_text)
279
+ ```
280
+ </details>
281
+
282
+ <details>
283
+ <summary>Video inference</summary>
284
+
285
+ ```python
286
+ # Messages containing a images list as a video and a text query
287
+ messages = [
288
+ {
289
+ "role": "user",
290
+ "content": [
291
+ {
292
+ "type": "video",
293
+ "video": [
294
+ "file:///path/to/frame1.jpg",
295
+ "file:///path/to/frame2.jpg",
296
+ "file:///path/to/frame3.jpg",
297
+ "file:///path/to/frame4.jpg",
298
+ ],
299
+ "fps": 1.0,
300
+ },
301
+ {"type": "text", "text": "Describe this video."},
302
+ ],
303
+ }
304
+ ]
305
+ # Messages containing a video and a text query
306
+ messages = [
307
+ {
308
+ "role": "user",
309
+ "content": [
310
+ {
311
+ "type": "video",
312
+ "video": "file:///path/to/video1.mp4",
313
+ "max_pixels": 360 * 420,
314
+ "fps": 1.0,
315
+ },
316
+ {"type": "text", "text": "Describe this video."},
317
+ ],
318
+ }
319
+ ]
320
+
321
+ # Preparation for inference
322
+ text = processor.apply_chat_template(
323
+ messages, tokenize=False, add_generation_prompt=True
324
+ )
325
+ image_inputs, video_inputs = process_vision_info(messages)
326
+ inputs = processor(
327
+ text=[text],
328
+ images=image_inputs,
329
+ videos=video_inputs,
330
+ padding=True,
331
+ return_tensors="pt",
332
+ )
333
+ inputs = inputs.to("cuda")
334
+
335
+ # Inference
336
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
337
+ generated_ids_trimmed = [
338
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
339
+ ]
340
+ output_text = processor.batch_decode(
341
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
342
+ )
343
+ print(output_text)
344
+ ```
345
+ </details>
346
+
347
+ <details>
348
+ <summary>Batch inference</summary>
349
+
350
+ ```python
351
+ # Sample messages for batch inference
352
+ messages1 = [
353
+ {
354
+ "role": "user",
355
+ "content": [
356
+ {"type": "image", "image": "file:///path/to/image1.jpg"},
357
+ {"type": "image", "image": "file:///path/to/image2.jpg"},
358
+ {"type": "text", "text": "What are the common elements in these pictures?"},
359
+ ],
360
+ }
361
+ ]
362
+ messages2 = [
363
+ {"role": "system", "content": "You are a helpful assistant."},
364
+ {"role": "user", "content": "Who are you?"},
365
+ ]
366
+ # Combine messages for batch processing
367
+ messages = [messages1, messages1]
368
+
369
+ # Preparation for batch inference
370
+ texts = [
371
+ processor.apply_chat_template(msg, tokenize=False, add_generation_prompt=True)
372
+ for msg in messages
373
+ ]
374
+ image_inputs, video_inputs = process_vision_info(messages)
375
+ inputs = processor(
376
+ text=texts,
377
+ images=image_inputs,
378
+ videos=video_inputs,
379
+ padding=True,
380
+ return_tensors="pt",
381
+ )
382
+ inputs = inputs.to("cuda")
383
+
384
+ # Batch Inference
385
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
386
+ generated_ids_trimmed = [
387
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
388
+ ]
389
+ output_texts = processor.batch_decode(
390
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
391
+ )
392
+ print(output_texts)
393
+ ```
394
+ </details>
395
+
396
+ ### More Usage Tips
397
+
398
+ For input images, we support local files, base64, and URLs. For videos, we currently only support local files.
399
+
400
+ ```python
401
+ # You can directly insert a local file path, a URL, or a base64-encoded image into the position where you want in the text.
402
+ ## Local file path
403
+ messages = [
404
+ {
405
+ "role": "user",
406
+ "content": [
407
+ {"type": "image", "image": "file:///path/to/your/image.jpg"},
408
+ {"type": "text", "text": "Describe this image."},
409
+ ],
410
+ }
411
+ ]
412
+ ## Image URL
413
+ messages = [
414
+ {
415
+ "role": "user",
416
+ "content": [
417
+ {"type": "image", "image": "http://path/to/your/image.jpg"},
418
+ {"type": "text", "text": "Describe this image."},
419
+ ],
420
+ }
421
+ ]
422
+ ## Base64 encoded image
423
+ messages = [
424
+ {
425
+ "role": "user",
426
+ "content": [
427
+ {"type": "image", "image": "data:image;base64,/9j/..."},
428
+ {"type": "text", "text": "Describe this image."},
429
+ ],
430
+ }
431
+ ]
432
+ ```
433
+ #### Image Resolution for performance boost
434
+
435
+ The model supports a wide range of resolution inputs. By default, it uses the native resolution for input, but higher resolutions can enhance performance at the cost of more computation. Users can set the minimum and maximum number of pixels to achieve an optimal configuration for their needs, such as a token count range of 256-1280, to balance speed and memory usage.
436
+
437
+ ```python
438
+ min_pixels = 256 * 28 * 28
439
+ max_pixels = 1280 * 28 * 28
440
+ processor = AutoProcessor.from_pretrained(
441
+ "Qwen/Qwen2-VL-2B-Instruct-GPTQ-Int4", min_pixels=min_pixels, max_pixels=max_pixels
442
+ )
443
+ ```
444
+
445
+ Besides, We provide two methods for fine-grained control over the image size input to the model:
446
+
447
+ 1. Define min_pixels and max_pixels: Images will be resized to maintain their aspect ratio within the range of min_pixels and max_pixels.
448
+
449
+ 2. Specify exact dimensions: Directly set `resized_height` and `resized_width`. These values will be rounded to the nearest multiple of 28.
450
+
451
+ ```python
452
+ # min_pixels and max_pixels
453
+ messages = [
454
+ {
455
+ "role": "user",
456
+ "content": [
457
+ {
458
+ "type": "image",
459
+ "image": "file:///path/to/your/image.jpg",
460
+ "resized_height": 280,
461
+ "resized_width": 420,
462
+ },
463
+ {"type": "text", "text": "Describe this image."},
464
+ ],
465
+ }
466
+ ]
467
+ # resized_height and resized_width
468
+ messages = [
469
+ {
470
+ "role": "user",
471
+ "content": [
472
+ {
473
+ "type": "image",
474
+ "image": "file:///path/to/your/image.jpg",
475
+ "min_pixels": 50176,
476
+ "max_pixels": 50176,
477
+ },
478
+ {"type": "text", "text": "Describe this image."},
479
+ ],
480
+ }
481
+ ]
482
+ ```
483
+
484
+ ## Limitations
485
+
486
+ While Qwen2-VL are applicable to a wide range of visual tasks, it is equally important to understand its limitations. Here are some known restrictions:
487
+
488
+ 1. Lack of Audio Support: The current model does **not comprehend audio information** within videos.
489
+ 2. Data timeliness: Our image dataset is **updated until June 2023**, and information subsequent to this date may not be covered.
490
+ 3. Constraints in Individuals and Intellectual Property (IP): The model's capacity to recognize specific individuals or IPs is limited, potentially failing to comprehensively cover all well-known personalities or brands.
491
+ 4. Limited Capacity for Complex Instruction: When faced with intricate multi-step instructions, the model's understanding and execution capabilities require enhancement.
492
+ 5. Insufficient Counting Accuracy: Particularly in complex scenes, the accuracy of object counting is not high, necessitating further improvements.
493
+ 6. Weak Spatial Reasoning Skills: Especially in 3D spaces, the model's inference of object positional relationships is inadequate, making it difficult to precisely judge the relative positions of objects.
494
+
495
+ These limitations serve as ongoing directions for model optimization and improvement, and we are committed to continually enhancing the model's performance and scope of application.
496
+
497
+
498
+ ## Citation
499
+
500
+ If you find our work helpful, feel free to give us a cite.
501
+
502
+ ```
503
+ @article{Qwen2VL,
504
+ title={Qwen2-VL: Enhancing Vision-Language Model's Perception of the World at Any Resolution},
505
+ 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},
506
+ journal={arXiv preprint arXiv:2409.12191},
507
+ year={2024}
508
+ }
509
+
510
+ @article{Qwen-VL,
511
+ title={Qwen-VL: A Versatile Vision-Language Model for Understanding, Localization, Text Reading, and Beyond},
512
+ author={Bai, Jinze and Bai, Shuai and Yang, Shusheng and Wang, Shijie and Tan, Sinan and Wang, Peng and Lin, Junyang and Zhou, Chang and Zhou, Jingren},
513
+ journal={arXiv preprint arXiv:2308.12966},
514
+ year={2023}
515
+ }
516
+ ```
added_tokens.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "<|box_end|>": 151649,
3
+ "<|box_start|>": 151648,
4
+ "<|endoftext|>": 151643,
5
+ "<|im_end|>": 151645,
6
+ "<|im_start|>": 151644,
7
+ "<|image_pad|>": 151655,
8
+ "<|object_ref_end|>": 151647,
9
+ "<|object_ref_start|>": 151646,
10
+ "<|quad_end|>": 151651,
11
+ "<|quad_start|>": 151650,
12
+ "<|video_pad|>": 151656,
13
+ "<|vision_end|>": 151653,
14
+ "<|vision_pad|>": 151654,
15
+ "<|vision_start|>": 151652
16
+ }
chat_template.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "chat_template": "{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% endif %}"
3
+ }
config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "Qwen/Qwen2-VL-2B-Instruct-319",
3
+ "architectures": [
4
+ "Qwen2VLForConditionalGeneration"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 151643,
8
+ "eos_token_id": 151645,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 1536,
11
+ "image_token_id": 151655,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 8960,
14
+ "max_position_embeddings": 32768,
15
+ "max_window_layers": 28,
16
+ "model_type": "qwen2_vl",
17
+ "num_attention_heads": 12,
18
+ "num_hidden_layers": 28,
19
+ "num_key_value_heads": 2,
20
+ "quantization_config": {
21
+ "bits": 4,
22
+ "damp_percent": 0.1,
23
+ "dataset": null,
24
+ "desc_act": false,
25
+ "group_size": 128,
26
+ "modules_in_block_to_quantize": null,
27
+ "quant_method": "gptq",
28
+ "sym": true,
29
+ "true_sequential": true
30
+ },
31
+ "rms_norm_eps": 1e-06,
32
+ "rope_scaling": {
33
+ "mrope_section": [
34
+ 16,
35
+ 24,
36
+ 24
37
+ ],
38
+ "type": "mrope"
39
+ },
40
+ "rope_theta": 1000000.0,
41
+ "sliding_window": 32768,
42
+ "tie_word_embeddings": true,
43
+ "torch_dtype": "float16",
44
+ "transformers_version": "4.45.0.dev0",
45
+ "use_cache": true,
46
+ "use_sliding_window": false,
47
+ "video_token_id": 151656,
48
+ "vision_config": {
49
+ "hidden_size": 1536,
50
+ "in_chans": 3,
51
+ "model_type": "qwen2_vl",
52
+ "spatial_patch_size": 14
53
+ },
54
+ "vision_end_token_id": 151653,
55
+ "vision_start_token_id": 151652,
56
+ "vision_token_id": 151654,
57
+ "vocab_size": 151936
58
+ }
generation_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 151645,
6
+ 151643
7
+ ],
8
+ "pad_token_id": 151643,
9
+ "repetition_penalty": 1.0,
10
+ "temperature": 0.01,
11
+ "top_k": 1,
12
+ "top_p": 0.001,
13
+ "transformers_version": "4.45.0.dev0"
14
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:101dd80c19339bf505e1788629867b93b912a990a45f2b3f239fc66cac1858f1
3
+ size 2480446272
preprocessor_config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_convert_rgb": true,
3
+ "do_normalize": true,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.48145466,
8
+ 0.4578275,
9
+ 0.40821073
10
+ ],
11
+ "image_processor_type": "Qwen2VLImageProcessor",
12
+ "image_std": [
13
+ 0.26862954,
14
+ 0.26130258,
15
+ 0.27577711
16
+ ],
17
+ "max_pixels": 1003520,
18
+ "merge_size": 2,
19
+ "min_pixels": 3136,
20
+ "patch_size": 14,
21
+ "processor_class": "Qwen2VLProcessor",
22
+ "resample": 3,
23
+ "rescale_factor": 0.00392156862745098,
24
+ "size": {
25
+ "max_pixels": 1003520,
26
+ "min_pixels": 3136
27
+ },
28
+ "temporal_patch_size": 2,
29
+ "vision_token_id": 151654
30
+ }
quantize_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bits": 4,
3
+ "dataset": null,
4
+ "group_size": 128,
5
+ "damp_percent": 0.1,
6
+ "desc_act": false,
7
+ "sym": true,
8
+ "true_sequential": true,
9
+ "quant_method": "gptq",
10
+ "modules_in_block_to_quantize": null
11
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|im_end|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "151643": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "151644": {
13
+ "content": "<|im_start|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "151645": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "151646": {
29
+ "content": "<|object_ref_start|>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "151647": {
37
+ "content": "<|object_ref_end|>",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "151648": {
45
+ "content": "<|box_start|>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "151649": {
53
+ "content": "<|box_end|>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "151650": {
61
+ "content": "<|quad_start|>",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "151651": {
69
+ "content": "<|quad_end|>",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "151652": {
77
+ "content": "<|vision_start|>",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "151653": {
85
+ "content": "<|vision_end|>",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "151654": {
93
+ "content": "<|vision_pad|>",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ },
100
+ "151655": {
101
+ "content": "<|image_pad|>",
102
+ "lstrip": false,
103
+ "normalized": false,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": true
107
+ },
108
+ "151656": {
109
+ "content": "<|video_pad|>",
110
+ "lstrip": false,
111
+ "normalized": false,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": true
115
+ }
116
+ },
117
+ "additional_special_tokens": [
118
+ "<|im_start|>",
119
+ "<|im_end|>",
120
+ "<|object_ref_start|>",
121
+ "<|object_ref_end|>",
122
+ "<|box_start|>",
123
+ "<|box_end|>",
124
+ "<|quad_start|>",
125
+ "<|quad_end|>",
126
+ "<|vision_start|>",
127
+ "<|vision_end|>",
128
+ "<|vision_pad|>",
129
+ "<|image_pad|>",
130
+ "<|video_pad|>"
131
+ ],
132
+ "bos_token": null,
133
+ "chat_template": "{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% endif %}",
134
+ "clean_up_tokenization_spaces": false,
135
+ "eos_token": "<|im_end|>",
136
+ "errors": "replace",
137
+ "model_max_length": 32768,
138
+ "pad_token": "<|endoftext|>",
139
+ "padding_side": "left",
140
+ "processor_class": "Qwen2VLProcessor",
141
+ "split_special_tokens": false,
142
+ "tokenizer_class": "Qwen2Tokenizer",
143
+ "unk_token": null
144
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff