Upload 12 files
Browse files- .gitattributes +1 -0
- added_tokens.json +24 -0
- chat_template.json +3 -0
- config.json +75 -0
- configuration.json +1 -0
- configuration_qwen2_5_vl.py +258 -0
- generation_config.json +14 -0
- merges.txt +0 -0
- preprocessor_config.json +29 -0
- special_tokens_map.json +31 -0
- tokenizer.json +3 -0
- tokenizer_config.json +209 -0
- vocab.json +0 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* 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
|
|
|
|
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
|
36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
added_tokens.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"</tool_call>": 151658,
|
3 |
+
"<tool_call>": 151657,
|
4 |
+
"<|box_end|>": 151649,
|
5 |
+
"<|box_start|>": 151648,
|
6 |
+
"<|endoftext|>": 151643,
|
7 |
+
"<|file_sep|>": 151664,
|
8 |
+
"<|fim_middle|>": 151660,
|
9 |
+
"<|fim_pad|>": 151662,
|
10 |
+
"<|fim_prefix|>": 151659,
|
11 |
+
"<|fim_suffix|>": 151661,
|
12 |
+
"<|im_end|>": 151645,
|
13 |
+
"<|im_start|>": 151644,
|
14 |
+
"<|image_pad|>": 151655,
|
15 |
+
"<|object_ref_end|>": 151647,
|
16 |
+
"<|object_ref_start|>": 151646,
|
17 |
+
"<|quad_end|>": 151651,
|
18 |
+
"<|quad_start|>": 151650,
|
19 |
+
"<|repo_name|>": 151663,
|
20 |
+
"<|video_pad|>": 151656,
|
21 |
+
"<|vision_end|>": 151653,
|
22 |
+
"<|vision_pad|>": 151654,
|
23 |
+
"<|vision_start|>": 151652
|
24 |
+
}
|
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,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "models/Nexus-GenV2",
|
3 |
+
"architectures": [
|
4 |
+
"Qwen2_5_VLForConditionalGeneration"
|
5 |
+
],
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"auto_map": {
|
8 |
+
"AutoConfig": "configuration_qwen2_5_vl.Qwen2_5_VLConfig",
|
9 |
+
"AutoModel": "modeling_qwen2_5_vl.Qwen2_5_VLModel",
|
10 |
+
"AutoModelForCausalLM": "modeling_qwen2_5_vl.Qwen2_5_VLForConditionalGeneration"
|
11 |
+
},
|
12 |
+
"bos_token_id": 151643,
|
13 |
+
"eos_token_id": 151645,
|
14 |
+
"hidden_act": "silu",
|
15 |
+
"hidden_size": 3584,
|
16 |
+
"image_token_id": 151655,
|
17 |
+
"initializer_range": 0.02,
|
18 |
+
"intermediate_size": 18944,
|
19 |
+
"max_position_embeddings": 128000,
|
20 |
+
"max_window_layers": 28,
|
21 |
+
"model_type": "qwen2_5_vl",
|
22 |
+
"num_attention_heads": 28,
|
23 |
+
"num_hidden_layers": 28,
|
24 |
+
"num_key_value_heads": 4,
|
25 |
+
"pad_token_id": 151643,
|
26 |
+
"quantization_config": {
|
27 |
+
"_load_in_4bit": true,
|
28 |
+
"_load_in_8bit": false,
|
29 |
+
"bnb_4bit_compute_dtype": "bfloat16",
|
30 |
+
"bnb_4bit_quant_storage": "uint8",
|
31 |
+
"bnb_4bit_quant_type": "nf4",
|
32 |
+
"bnb_4bit_use_double_quant": false,
|
33 |
+
"llm_int8_enable_fp32_cpu_offload": false,
|
34 |
+
"llm_int8_has_fp16_weight": false,
|
35 |
+
"llm_int8_skip_modules": [
|
36 |
+
"lm_head",
|
37 |
+
"image_prefill_embeds",
|
38 |
+
"merger"
|
39 |
+
],
|
40 |
+
"llm_int8_threshold": 6.0,
|
41 |
+
"load_in_4bit": true,
|
42 |
+
"load_in_8bit": false,
|
43 |
+
"quant_method": "bitsandbytes"
|
44 |
+
},
|
45 |
+
"rms_norm_eps": 1e-06,
|
46 |
+
"rope_scaling": {
|
47 |
+
"mrope_section": [
|
48 |
+
16,
|
49 |
+
24,
|
50 |
+
24
|
51 |
+
],
|
52 |
+
"rope_type": "default",
|
53 |
+
"type": "default"
|
54 |
+
},
|
55 |
+
"rope_theta": 1000000.0,
|
56 |
+
"sliding_window": 32768,
|
57 |
+
"tie_word_embeddings": false,
|
58 |
+
"torch_dtype": "bfloat16",
|
59 |
+
"transformers_version": "4.49.0",
|
60 |
+
"use_cache": false,
|
61 |
+
"use_sliding_window": false,
|
62 |
+
"video_token_id": 151656,
|
63 |
+
"vision_config": {
|
64 |
+
"hidden_size": 1280,
|
65 |
+
"in_chans": 3,
|
66 |
+
"model_type": "qwen2_5_vl",
|
67 |
+
"spatial_patch_size": 14,
|
68 |
+
"tokens_per_second": 2,
|
69 |
+
"torch_dtype": "bfloat16"
|
70 |
+
},
|
71 |
+
"vision_end_token_id": 151653,
|
72 |
+
"vision_start_token_id": 151652,
|
73 |
+
"vision_token_id": 151654,
|
74 |
+
"vocab_size": 152064
|
75 |
+
}
|
configuration.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"framework":"Pytorch","task":"any-to-any"}
|
configuration_qwen2_5_vl.py
ADDED
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
2 |
+
# This file was automatically generated from src/transformers/models/qwen2_5_vl/modular_qwen2_5_vl.py.
|
3 |
+
# Do NOT edit this file manually as any edits will be overwritten by the generation of
|
4 |
+
# the file from the modular. If any change should be done, please apply the change to the
|
5 |
+
# modular_qwen2_5_vl.py file directly. One of our CI enforces this.
|
6 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
7 |
+
# coding=utf-8
|
8 |
+
# Copyright 2025 The Qwen Team and The HuggingFace Inc. team. All rights reserved.
|
9 |
+
#
|
10 |
+
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
|
11 |
+
# and OPT implementations in this library. It has been modified from its
|
12 |
+
# original forms to accommodate minor architectural differences compared
|
13 |
+
# to GPT-NeoX and OPT used by the Meta AI team that trained the model.
|
14 |
+
#
|
15 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
16 |
+
# you may not use this file except in compliance with the License.
|
17 |
+
# You may obtain a copy of the License at
|
18 |
+
#
|
19 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
20 |
+
#
|
21 |
+
# Unless required by applicable law or agreed to in writing, software
|
22 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
23 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
24 |
+
# See the License for the specific language governing permissions and
|
25 |
+
# limitations under the License.
|
26 |
+
from transformers.configuration_utils import PretrainedConfig
|
27 |
+
from transformers.modeling_rope_utils import rope_config_validation
|
28 |
+
|
29 |
+
|
30 |
+
class Qwen2_5_VLVisionConfig(PretrainedConfig):
|
31 |
+
model_type = "qwen2_5_vl"
|
32 |
+
base_config_key = "vision_config"
|
33 |
+
|
34 |
+
def __init__(
|
35 |
+
self,
|
36 |
+
depth=32,
|
37 |
+
hidden_size=3584,
|
38 |
+
hidden_act="silu",
|
39 |
+
intermediate_size=3420,
|
40 |
+
num_heads=16,
|
41 |
+
in_channels=3,
|
42 |
+
patch_size=14,
|
43 |
+
spatial_merge_size=2,
|
44 |
+
temporal_patch_size=2,
|
45 |
+
tokens_per_second=4,
|
46 |
+
window_size=112,
|
47 |
+
out_hidden_size=3584,
|
48 |
+
fullatt_block_indexes=[7, 15, 23, 31],
|
49 |
+
**kwargs,
|
50 |
+
):
|
51 |
+
super().__init__(**kwargs)
|
52 |
+
|
53 |
+
self.depth = depth
|
54 |
+
self.hidden_size = hidden_size
|
55 |
+
self.hidden_act = hidden_act
|
56 |
+
self.intermediate_size = intermediate_size
|
57 |
+
self.num_heads = num_heads
|
58 |
+
self.in_channels = in_channels
|
59 |
+
self.patch_size = patch_size
|
60 |
+
self.spatial_merge_size = spatial_merge_size
|
61 |
+
self.temporal_patch_size = temporal_patch_size
|
62 |
+
self.tokens_per_second = tokens_per_second
|
63 |
+
self.window_size = window_size
|
64 |
+
self.fullatt_block_indexes = fullatt_block_indexes
|
65 |
+
self.out_hidden_size = out_hidden_size
|
66 |
+
|
67 |
+
|
68 |
+
class Qwen2_5_VLConfig(PretrainedConfig):
|
69 |
+
r"""
|
70 |
+
This is the configuration class to store the configuration of a [`Qwen2_5_VLModel`]. It is used to instantiate a
|
71 |
+
Qwen2-VL model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
72 |
+
with the defaults will yield a similar configuration to that of
|
73 |
+
Qwen2-VL-7B-Instruct [Qwen/Qwen2-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct).
|
74 |
+
|
75 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
76 |
+
documentation from [`PretrainedConfig`] for more information.
|
77 |
+
|
78 |
+
|
79 |
+
Args:
|
80 |
+
vocab_size (`int`, *optional*, defaults to 152064):
|
81 |
+
Vocabulary size of the Qwen2_5_VL model. Defines the number of different tokens that can be represented by the
|
82 |
+
`inputs_ids` passed when calling [`Qwen2_5_VLModel`]
|
83 |
+
hidden_size (`int`, *optional*, defaults to 8192):
|
84 |
+
Dimension of the hidden representations.
|
85 |
+
intermediate_size (`int`, *optional*, defaults to 29568):
|
86 |
+
Dimension of the MLP representations.
|
87 |
+
num_hidden_layers (`int`, *optional*, defaults to 80):
|
88 |
+
Number of hidden layers in the Transformer encoder.
|
89 |
+
num_attention_heads (`int`, *optional*, defaults to 64):
|
90 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
91 |
+
num_key_value_heads (`int`, *optional*, defaults to 8):
|
92 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
93 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
94 |
+
`num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
95 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
96 |
+
by meanpooling all the original heads within that group. For more details checkout [this
|
97 |
+
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to `32`.
|
98 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
99 |
+
The non-linear activation function (function or string) in the decoder.
|
100 |
+
max_position_embeddings (`int`, *optional*, defaults to 32768):
|
101 |
+
The maximum sequence length that this model might ever be used with.
|
102 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
103 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
104 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-05):
|
105 |
+
The epsilon used by the rms normalization layers.
|
106 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
107 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
108 |
+
relevant if `config.is_decoder=True`.
|
109 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
110 |
+
Whether the model's input and output word embeddings should be tied.
|
111 |
+
rope_theta (`float`, *optional*, defaults to 1000000.0):
|
112 |
+
The base period of the RoPE embeddings.
|
113 |
+
use_sliding_window (`bool`, *optional*, defaults to `False`):
|
114 |
+
Whether to use sliding window attention.
|
115 |
+
sliding_window (`int`, *optional*, defaults to 4096):
|
116 |
+
Sliding window attention (SWA) window size. If not specified, will default to `4096`.
|
117 |
+
max_window_layers (`int`, *optional*, defaults to 80):
|
118 |
+
The number of layers that use SWA (Sliding Window Attention). The bottom layers use SWA while the top use full attention.
|
119 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
120 |
+
The dropout ratio for the attention probabilities.
|
121 |
+
vision_config (`Dict`, *optional*):
|
122 |
+
The config for the visual encoder initialization.
|
123 |
+
rope_scaling (`Dict`, *optional*):
|
124 |
+
Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
|
125 |
+
and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
|
126 |
+
accordingly.
|
127 |
+
Expected contents:
|
128 |
+
`rope_type` (`str`):
|
129 |
+
The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
|
130 |
+
'llama3'], with 'default' being the original RoPE implementation.
|
131 |
+
`factor` (`float`, *optional*):
|
132 |
+
Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
|
133 |
+
most scaling types, a `factor` of x will enable the model to handle sequences of length x *
|
134 |
+
original maximum pre-trained length.
|
135 |
+
`original_max_position_embeddings` (`int`, *optional*):
|
136 |
+
Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
|
137 |
+
pretraining.
|
138 |
+
`attention_factor` (`float`, *optional*):
|
139 |
+
Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
|
140 |
+
computation. If unspecified, it defaults to value recommended by the implementation, using the
|
141 |
+
`factor` field to infer the suggested value.
|
142 |
+
`beta_fast` (`float`, *optional*):
|
143 |
+
Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
|
144 |
+
ramp function. If unspecified, it defaults to 32.
|
145 |
+
`beta_slow` (`float`, *optional*):
|
146 |
+
Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
|
147 |
+
ramp function. If unspecified, it defaults to 1.
|
148 |
+
`short_factor` (`List[float]`, *optional*):
|
149 |
+
Only used with 'longrope'. The scaling factor to be applied to short contexts (<
|
150 |
+
`original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
|
151 |
+
size divided by the number of attention heads divided by 2
|
152 |
+
`long_factor` (`List[float]`, *optional*):
|
153 |
+
Only used with 'longrope'. The scaling factor to be applied to long contexts (<
|
154 |
+
`original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
|
155 |
+
size divided by the number of attention heads divided by 2
|
156 |
+
`low_freq_factor` (`float`, *optional*):
|
157 |
+
Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
|
158 |
+
`high_freq_factor` (`float`, *optional*):
|
159 |
+
Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
|
160 |
+
|
161 |
+
```python
|
162 |
+
>>> from transformers import Qwen2_5_VLForConditionalGeneration, Qwen2_5_VLConfig
|
163 |
+
|
164 |
+
>>> # Initializing a Qwen2_5_VL style configuration
|
165 |
+
>>> configuration = Qwen2_5_VLConfig()
|
166 |
+
|
167 |
+
>>> # Initializing a model from the Qwen2-VL-7B style configuration
|
168 |
+
>>> model = Qwen2_5_VLForConditionalGeneration(configuration)
|
169 |
+
|
170 |
+
>>> # Accessing the model configuration
|
171 |
+
>>> configuration = model.config
|
172 |
+
```"""
|
173 |
+
|
174 |
+
model_type = "qwen2_5_vl"
|
175 |
+
sub_configs = {"vision_config": Qwen2_5_VLVisionConfig}
|
176 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
177 |
+
# Default tensor parallel plan for base model `Qwen2_5_VL`
|
178 |
+
base_model_tp_plan = {
|
179 |
+
"layers.*.self_attn.q_proj": "colwise",
|
180 |
+
"layers.*.self_attn.k_proj": "colwise",
|
181 |
+
"layers.*.self_attn.v_proj": "colwise",
|
182 |
+
"layers.*.self_attn.o_proj": "rowwise",
|
183 |
+
"layers.*.mlp.gate_proj": "colwise",
|
184 |
+
"layers.*.mlp.up_proj": "colwise",
|
185 |
+
"layers.*.mlp.down_proj": "rowwise",
|
186 |
+
}
|
187 |
+
base_model_pp_plan = {
|
188 |
+
"embed_tokens": (["input_ids"], ["inputs_embeds"]),
|
189 |
+
"layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
|
190 |
+
"norm": (["hidden_states"], ["hidden_states"]),
|
191 |
+
}
|
192 |
+
|
193 |
+
def __init__(
|
194 |
+
self,
|
195 |
+
vocab_size=152064,
|
196 |
+
hidden_size=8192,
|
197 |
+
intermediate_size=29568,
|
198 |
+
num_hidden_layers=80,
|
199 |
+
num_attention_heads=64,
|
200 |
+
num_key_value_heads=8,
|
201 |
+
hidden_act="silu",
|
202 |
+
max_position_embeddings=32768,
|
203 |
+
initializer_range=0.02,
|
204 |
+
rms_norm_eps=1e-05,
|
205 |
+
use_cache=True,
|
206 |
+
tie_word_embeddings=False,
|
207 |
+
rope_theta=1000000.0,
|
208 |
+
use_sliding_window=False,
|
209 |
+
sliding_window=4096,
|
210 |
+
max_window_layers=80,
|
211 |
+
attention_dropout=0.0,
|
212 |
+
vision_config=None,
|
213 |
+
rope_scaling=None,
|
214 |
+
**kwargs,
|
215 |
+
):
|
216 |
+
if isinstance(vision_config, dict):
|
217 |
+
self.vision_config = self.sub_configs["vision_config"](**vision_config)
|
218 |
+
elif vision_config is None:
|
219 |
+
self.vision_config = self.sub_configs["vision_config"]()
|
220 |
+
|
221 |
+
self.vocab_size = vocab_size
|
222 |
+
self.max_position_embeddings = max_position_embeddings
|
223 |
+
self.hidden_size = hidden_size
|
224 |
+
self.intermediate_size = intermediate_size
|
225 |
+
self.num_hidden_layers = num_hidden_layers
|
226 |
+
self.num_attention_heads = num_attention_heads
|
227 |
+
self.use_sliding_window = use_sliding_window
|
228 |
+
self.sliding_window = sliding_window
|
229 |
+
self.max_window_layers = max_window_layers
|
230 |
+
|
231 |
+
# for backward compatibility
|
232 |
+
if num_key_value_heads is None:
|
233 |
+
num_key_value_heads = num_attention_heads
|
234 |
+
|
235 |
+
self.num_key_value_heads = num_key_value_heads
|
236 |
+
self.hidden_act = hidden_act
|
237 |
+
self.initializer_range = initializer_range
|
238 |
+
self.rms_norm_eps = rms_norm_eps
|
239 |
+
self.use_cache = use_cache
|
240 |
+
self.rope_theta = rope_theta
|
241 |
+
self.attention_dropout = attention_dropout
|
242 |
+
self.rope_scaling = rope_scaling
|
243 |
+
|
244 |
+
# Validate the correctness of rotary position embeddings parameters
|
245 |
+
# BC: if there is a 'type' field, move it to 'rope_type'.
|
246 |
+
# and change type from 'mrope' to 'default' because `mrope` does default RoPE calculations
|
247 |
+
# one can set it to "linear"/"dynamic" etc. to have scaled RoPE
|
248 |
+
# TODO: @raushan update config in the hub
|
249 |
+
if self.rope_scaling is not None and "type" in self.rope_scaling:
|
250 |
+
if self.rope_scaling["type"] == "mrope":
|
251 |
+
self.rope_scaling["type"] = "default"
|
252 |
+
self.rope_scaling["rope_type"] = self.rope_scaling["type"]
|
253 |
+
rope_config_validation(self, ignore_keys={"mrope_section"})
|
254 |
+
|
255 |
+
super().__init__(tie_word_embeddings=tie_word_embeddings, **kwargs)
|
256 |
+
|
257 |
+
|
258 |
+
__all__ = ["Qwen2_5_VLConfig"]
|
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.05,
|
10 |
+
"temperature": 0.1,
|
11 |
+
"top_k": 1,
|
12 |
+
"top_p": 0.001,
|
13 |
+
"transformers_version": "4.49.0"
|
14 |
+
}
|
merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
preprocessor_config.json
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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": 12845056,
|
18 |
+
"merge_size": 2,
|
19 |
+
"min_pixels": 3136,
|
20 |
+
"patch_size": 14,
|
21 |
+
"processor_class": "Qwen2_5_VLProcessor",
|
22 |
+
"resample": 3,
|
23 |
+
"rescale_factor": 0.00392156862745098,
|
24 |
+
"size": {
|
25 |
+
"longest_edge": 12845056,
|
26 |
+
"shortest_edge": 3136
|
27 |
+
},
|
28 |
+
"temporal_patch_size": 2
|
29 |
+
}
|
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
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9c5ae00e602b8860cbd784ba82a8aa14e8feecec692e7076590d014d7b7fdafa
|
3 |
+
size 11421896
|
tokenizer_config.json
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": false,
|
3 |
+
"add_prefix_space": false,
|
4 |
+
"added_tokens_decoder": {
|
5 |
+
"151643": {
|
6 |
+
"content": "<|endoftext|>",
|
7 |
+
"lstrip": false,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false,
|
11 |
+
"special": true
|
12 |
+
},
|
13 |
+
"151644": {
|
14 |
+
"content": "<|im_start|>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": false,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false,
|
19 |
+
"special": true
|
20 |
+
},
|
21 |
+
"151645": {
|
22 |
+
"content": "<|im_end|>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": false,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false,
|
27 |
+
"special": true
|
28 |
+
},
|
29 |
+
"151646": {
|
30 |
+
"content": "<|object_ref_start|>",
|
31 |
+
"lstrip": false,
|
32 |
+
"normalized": false,
|
33 |
+
"rstrip": false,
|
34 |
+
"single_word": false,
|
35 |
+
"special": true
|
36 |
+
},
|
37 |
+
"151647": {
|
38 |
+
"content": "<|object_ref_end|>",
|
39 |
+
"lstrip": false,
|
40 |
+
"normalized": false,
|
41 |
+
"rstrip": false,
|
42 |
+
"single_word": false,
|
43 |
+
"special": true
|
44 |
+
},
|
45 |
+
"151648": {
|
46 |
+
"content": "<|box_start|>",
|
47 |
+
"lstrip": false,
|
48 |
+
"normalized": false,
|
49 |
+
"rstrip": false,
|
50 |
+
"single_word": false,
|
51 |
+
"special": true
|
52 |
+
},
|
53 |
+
"151649": {
|
54 |
+
"content": "<|box_end|>",
|
55 |
+
"lstrip": false,
|
56 |
+
"normalized": false,
|
57 |
+
"rstrip": false,
|
58 |
+
"single_word": false,
|
59 |
+
"special": true
|
60 |
+
},
|
61 |
+
"151650": {
|
62 |
+
"content": "<|quad_start|>",
|
63 |
+
"lstrip": false,
|
64 |
+
"normalized": false,
|
65 |
+
"rstrip": false,
|
66 |
+
"single_word": false,
|
67 |
+
"special": true
|
68 |
+
},
|
69 |
+
"151651": {
|
70 |
+
"content": "<|quad_end|>",
|
71 |
+
"lstrip": false,
|
72 |
+
"normalized": false,
|
73 |
+
"rstrip": false,
|
74 |
+
"single_word": false,
|
75 |
+
"special": true
|
76 |
+
},
|
77 |
+
"151652": {
|
78 |
+
"content": "<|vision_start|>",
|
79 |
+
"lstrip": false,
|
80 |
+
"normalized": false,
|
81 |
+
"rstrip": false,
|
82 |
+
"single_word": false,
|
83 |
+
"special": true
|
84 |
+
},
|
85 |
+
"151653": {
|
86 |
+
"content": "<|vision_end|>",
|
87 |
+
"lstrip": false,
|
88 |
+
"normalized": false,
|
89 |
+
"rstrip": false,
|
90 |
+
"single_word": false,
|
91 |
+
"special": true
|
92 |
+
},
|
93 |
+
"151654": {
|
94 |
+
"content": "<|vision_pad|>",
|
95 |
+
"lstrip": false,
|
96 |
+
"normalized": false,
|
97 |
+
"rstrip": false,
|
98 |
+
"single_word": false,
|
99 |
+
"special": true
|
100 |
+
},
|
101 |
+
"151655": {
|
102 |
+
"content": "<|image_pad|>",
|
103 |
+
"lstrip": false,
|
104 |
+
"normalized": false,
|
105 |
+
"rstrip": false,
|
106 |
+
"single_word": false,
|
107 |
+
"special": true
|
108 |
+
},
|
109 |
+
"151656": {
|
110 |
+
"content": "<|video_pad|>",
|
111 |
+
"lstrip": false,
|
112 |
+
"normalized": false,
|
113 |
+
"rstrip": false,
|
114 |
+
"single_word": false,
|
115 |
+
"special": true
|
116 |
+
},
|
117 |
+
"151657": {
|
118 |
+
"content": "<tool_call>",
|
119 |
+
"lstrip": false,
|
120 |
+
"normalized": false,
|
121 |
+
"rstrip": false,
|
122 |
+
"single_word": false,
|
123 |
+
"special": false
|
124 |
+
},
|
125 |
+
"151658": {
|
126 |
+
"content": "</tool_call>",
|
127 |
+
"lstrip": false,
|
128 |
+
"normalized": false,
|
129 |
+
"rstrip": false,
|
130 |
+
"single_word": false,
|
131 |
+
"special": false
|
132 |
+
},
|
133 |
+
"151659": {
|
134 |
+
"content": "<|fim_prefix|>",
|
135 |
+
"lstrip": false,
|
136 |
+
"normalized": false,
|
137 |
+
"rstrip": false,
|
138 |
+
"single_word": false,
|
139 |
+
"special": false
|
140 |
+
},
|
141 |
+
"151660": {
|
142 |
+
"content": "<|fim_middle|>",
|
143 |
+
"lstrip": false,
|
144 |
+
"normalized": false,
|
145 |
+
"rstrip": false,
|
146 |
+
"single_word": false,
|
147 |
+
"special": false
|
148 |
+
},
|
149 |
+
"151661": {
|
150 |
+
"content": "<|fim_suffix|>",
|
151 |
+
"lstrip": false,
|
152 |
+
"normalized": false,
|
153 |
+
"rstrip": false,
|
154 |
+
"single_word": false,
|
155 |
+
"special": false
|
156 |
+
},
|
157 |
+
"151662": {
|
158 |
+
"content": "<|fim_pad|>",
|
159 |
+
"lstrip": false,
|
160 |
+
"normalized": false,
|
161 |
+
"rstrip": false,
|
162 |
+
"single_word": false,
|
163 |
+
"special": false
|
164 |
+
},
|
165 |
+
"151663": {
|
166 |
+
"content": "<|repo_name|>",
|
167 |
+
"lstrip": false,
|
168 |
+
"normalized": false,
|
169 |
+
"rstrip": false,
|
170 |
+
"single_word": false,
|
171 |
+
"special": false
|
172 |
+
},
|
173 |
+
"151664": {
|
174 |
+
"content": "<|file_sep|>",
|
175 |
+
"lstrip": false,
|
176 |
+
"normalized": false,
|
177 |
+
"rstrip": false,
|
178 |
+
"single_word": false,
|
179 |
+
"special": false
|
180 |
+
}
|
181 |
+
},
|
182 |
+
"additional_special_tokens": [
|
183 |
+
"<|im_start|>",
|
184 |
+
"<|im_end|>",
|
185 |
+
"<|object_ref_start|>",
|
186 |
+
"<|object_ref_end|>",
|
187 |
+
"<|box_start|>",
|
188 |
+
"<|box_end|>",
|
189 |
+
"<|quad_start|>",
|
190 |
+
"<|quad_end|>",
|
191 |
+
"<|vision_start|>",
|
192 |
+
"<|vision_end|>",
|
193 |
+
"<|vision_pad|>",
|
194 |
+
"<|image_pad|>",
|
195 |
+
"<|video_pad|>"
|
196 |
+
],
|
197 |
+
"bos_token": null,
|
198 |
+
"chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0]['role'] == 'system' %}\n {{- messages[0]['content'] }}\n {%- else %}\n {{- 'You are a helpful assistant.' }}\n {%- endif %}\n {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0]['role'] == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\nYou are a helpful assistant.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + message.content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n",
|
199 |
+
"clean_up_tokenization_spaces": false,
|
200 |
+
"eos_token": "<|im_end|>",
|
201 |
+
"errors": "replace",
|
202 |
+
"extra_special_tokens": {},
|
203 |
+
"model_max_length": 131072,
|
204 |
+
"pad_token": "<|endoftext|>",
|
205 |
+
"processor_class": "Qwen2_5_VLProcessor",
|
206 |
+
"split_special_tokens": false,
|
207 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
208 |
+
"unk_token": null
|
209 |
+
}
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|