Markgazol commited on
Commit
5f76bcd
·
verified ·
1 Parent(s): a78067a

Upload folder using huggingface_hub

Browse files
.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,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,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ColQwenStella"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "auto_map": {
7
+ "AutoModel": "modeling_colqwenstella.ColQwenStella",
8
+ "AutoConfig": "modeling_colqwenstella.ColStellaVLConfig"
9
+ },
10
+ "img_end_token": "<|im_end|>",
11
+ "img_end_token_id": 151645,
12
+ "img_start_token": "<|im_start|>",
13
+ "img_start_token_id": 151644,
14
+ "img_token": "<|image_pad|>",
15
+ "img_token_id": 151646,
16
+ "model_type": "colstella_vl",
17
+ "text_config": {
18
+ "_attn_implementation_autoset": true,
19
+ "bos_token_id": 151643,
20
+ "eos_token_id": 151643,
21
+ "hidden_size": 1536,
22
+ "intermediate_size": 8960,
23
+ "max_position_embeddings": 131072,
24
+ "max_window_layers": 21,
25
+ "model_type": "qwen2",
26
+ "num_attention_heads": 12,
27
+ "num_hidden_layers": 28,
28
+ "num_key_value_heads": 2,
29
+ "rope_theta": 1000000.0,
30
+ "torch_dtype": "float32",
31
+ "vocab_size": 151647
32
+ },
33
+ "torch_dtype": "float32",
34
+ "transformers_version": "4.46.3",
35
+ "vision_config": {
36
+ "_attn_implementation_autoset": true,
37
+ "bos_token_id": 151643,
38
+ "eos_token_id": 151645,
39
+ "hidden_size": 1536,
40
+ "image_token_id": 151646,
41
+ "intermediate_size": 8960,
42
+ "max_window_layers": 28,
43
+ "model_type": "qwen2_vl",
44
+ "num_attention_heads": 12,
45
+ "num_hidden_layers": 28,
46
+ "num_key_value_heads": 2,
47
+ "rms_norm_eps": 1e-06,
48
+ "rope_scaling": {
49
+ "mrope_section": [
50
+ 16,
51
+ 24,
52
+ 24
53
+ ],
54
+ "rope_type": "default",
55
+ "type": "default"
56
+ },
57
+ "sliding_window": 32768,
58
+ "tie_word_embeddings": true,
59
+ "torch_dtype": "float32",
60
+ "video_token_id": 151656,
61
+ "vision_config": {
62
+ "hidden_size": 1536,
63
+ "in_chans": 3,
64
+ "spatial_patch_size": 14,
65
+ "attn_implementation": "flash_attention_2"
66
+ },
67
+ "vision_end_token_id": 151653,
68
+ "vision_start_token_id": 151652,
69
+ "vision_token_id": 151654,
70
+ "vocab_size": 151936
71
+ }
72
+ }
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f82ecdcefd16660bfd365c60246352cf683c57cc4e0a83273287ef3407997e7d
3
+ size 4994894848
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3b9c4210f404914ca8de7e32963dd350b68e79fea1e3bd701046c850cd93b35
3
+ size 3845648960
model.safetensors.index.json ADDED
@@ -0,0 +1,738 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 8840462336
4
+ },
5
+ "weight_map": {
6
+ "model.embed_tokens.weight": "model-00001-of-00002.safetensors",
7
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
8
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
9
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
10
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
11
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
12
+ "model.layers.0.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
13
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
14
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
15
+ "model.layers.0.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
16
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
17
+ "model.layers.0.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
18
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
19
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
20
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
21
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
22
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
23
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
24
+ "model.layers.1.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
25
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
26
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
27
+ "model.layers.1.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
28
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
29
+ "model.layers.1.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
30
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
31
+ "model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
32
+ "model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
33
+ "model.layers.10.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
34
+ "model.layers.10.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
35
+ "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
36
+ "model.layers.10.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
37
+ "model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
38
+ "model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
39
+ "model.layers.10.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
40
+ "model.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
41
+ "model.layers.10.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
42
+ "model.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
43
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
44
+ "model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
45
+ "model.layers.11.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
46
+ "model.layers.11.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
47
+ "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
48
+ "model.layers.11.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
49
+ "model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
50
+ "model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
51
+ "model.layers.11.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
52
+ "model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
53
+ "model.layers.11.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
54
+ "model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
55
+ "model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
56
+ "model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
57
+ "model.layers.12.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
58
+ "model.layers.12.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
59
+ "model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
60
+ "model.layers.12.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
61
+ "model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
62
+ "model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
63
+ "model.layers.12.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
64
+ "model.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
65
+ "model.layers.12.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
66
+ "model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
67
+ "model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
68
+ "model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
69
+ "model.layers.13.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
70
+ "model.layers.13.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
71
+ "model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
72
+ "model.layers.13.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
73
+ "model.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
74
+ "model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
75
+ "model.layers.13.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
76
+ "model.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
77
+ "model.layers.13.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
78
+ "model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
79
+ "model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
80
+ "model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
81
+ "model.layers.14.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
82
+ "model.layers.14.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
83
+ "model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
84
+ "model.layers.14.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
85
+ "model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
86
+ "model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
87
+ "model.layers.14.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
88
+ "model.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
89
+ "model.layers.14.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
90
+ "model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
91
+ "model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
92
+ "model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
93
+ "model.layers.15.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
94
+ "model.layers.15.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
95
+ "model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
96
+ "model.layers.15.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
97
+ "model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
98
+ "model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
99
+ "model.layers.15.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
100
+ "model.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
101
+ "model.layers.15.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
102
+ "model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
103
+ "model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
104
+ "model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
105
+ "model.layers.16.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
106
+ "model.layers.16.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
107
+ "model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
108
+ "model.layers.16.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
109
+ "model.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
110
+ "model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
111
+ "model.layers.16.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
112
+ "model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
113
+ "model.layers.16.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
114
+ "model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
115
+ "model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
116
+ "model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
117
+ "model.layers.17.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
118
+ "model.layers.17.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
119
+ "model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
120
+ "model.layers.17.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
121
+ "model.layers.17.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
122
+ "model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
123
+ "model.layers.17.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
124
+ "model.layers.17.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
125
+ "model.layers.17.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
126
+ "model.layers.17.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
127
+ "model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
128
+ "model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
129
+ "model.layers.18.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
130
+ "model.layers.18.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
131
+ "model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
132
+ "model.layers.18.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
133
+ "model.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
134
+ "model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
135
+ "model.layers.18.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
136
+ "model.layers.18.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
137
+ "model.layers.18.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
138
+ "model.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
139
+ "model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
140
+ "model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
141
+ "model.layers.19.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
142
+ "model.layers.19.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
143
+ "model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
144
+ "model.layers.19.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
145
+ "model.layers.19.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
146
+ "model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
147
+ "model.layers.19.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
148
+ "model.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
149
+ "model.layers.19.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
150
+ "model.layers.19.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
151
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
152
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
153
+ "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
154
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
155
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
156
+ "model.layers.2.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
157
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
158
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
159
+ "model.layers.2.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
160
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
161
+ "model.layers.2.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
162
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
163
+ "model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
164
+ "model.layers.20.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
165
+ "model.layers.20.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
166
+ "model.layers.20.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
167
+ "model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
168
+ "model.layers.20.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
169
+ "model.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
170
+ "model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
171
+ "model.layers.20.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
172
+ "model.layers.20.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
173
+ "model.layers.20.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
174
+ "model.layers.20.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
175
+ "model.layers.21.input_layernorm.weight": "model-00002-of-00002.safetensors",
176
+ "model.layers.21.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
177
+ "model.layers.21.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
178
+ "model.layers.21.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
179
+ "model.layers.21.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
180
+ "model.layers.21.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
181
+ "model.layers.21.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
182
+ "model.layers.21.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
183
+ "model.layers.21.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
184
+ "model.layers.21.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
185
+ "model.layers.21.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
186
+ "model.layers.21.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
187
+ "model.layers.22.input_layernorm.weight": "model-00002-of-00002.safetensors",
188
+ "model.layers.22.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
189
+ "model.layers.22.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
190
+ "model.layers.22.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
191
+ "model.layers.22.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
192
+ "model.layers.22.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
193
+ "model.layers.22.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
194
+ "model.layers.22.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
195
+ "model.layers.22.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
196
+ "model.layers.22.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
197
+ "model.layers.22.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
198
+ "model.layers.22.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
199
+ "model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors",
200
+ "model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
201
+ "model.layers.23.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
202
+ "model.layers.23.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
203
+ "model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
204
+ "model.layers.23.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
205
+ "model.layers.23.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
206
+ "model.layers.23.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
207
+ "model.layers.23.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
208
+ "model.layers.23.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
209
+ "model.layers.23.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
210
+ "model.layers.23.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
211
+ "model.layers.24.input_layernorm.weight": "model-00002-of-00002.safetensors",
212
+ "model.layers.24.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
213
+ "model.layers.24.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
214
+ "model.layers.24.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
215
+ "model.layers.24.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
216
+ "model.layers.24.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
217
+ "model.layers.24.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
218
+ "model.layers.24.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
219
+ "model.layers.24.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
220
+ "model.layers.24.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
221
+ "model.layers.24.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
222
+ "model.layers.24.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
223
+ "model.layers.25.input_layernorm.weight": "model-00002-of-00002.safetensors",
224
+ "model.layers.25.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
225
+ "model.layers.25.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
226
+ "model.layers.25.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
227
+ "model.layers.25.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
228
+ "model.layers.25.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
229
+ "model.layers.25.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
230
+ "model.layers.25.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
231
+ "model.layers.25.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
232
+ "model.layers.25.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
233
+ "model.layers.25.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
234
+ "model.layers.25.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
235
+ "model.layers.26.input_layernorm.weight": "model-00002-of-00002.safetensors",
236
+ "model.layers.26.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
237
+ "model.layers.26.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
238
+ "model.layers.26.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
239
+ "model.layers.26.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
240
+ "model.layers.26.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
241
+ "model.layers.26.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
242
+ "model.layers.26.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
243
+ "model.layers.26.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
244
+ "model.layers.26.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
245
+ "model.layers.26.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
246
+ "model.layers.26.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
247
+ "model.layers.27.input_layernorm.weight": "model-00002-of-00002.safetensors",
248
+ "model.layers.27.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
249
+ "model.layers.27.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
250
+ "model.layers.27.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
251
+ "model.layers.27.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
252
+ "model.layers.27.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
253
+ "model.layers.27.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
254
+ "model.layers.27.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
255
+ "model.layers.27.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
256
+ "model.layers.27.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
257
+ "model.layers.27.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
258
+ "model.layers.27.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
259
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
260
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
261
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
262
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
263
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
264
+ "model.layers.3.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
265
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
266
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
267
+ "model.layers.3.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
268
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
269
+ "model.layers.3.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
270
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
271
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
272
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
273
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
274
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
275
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
276
+ "model.layers.4.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
277
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
278
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
279
+ "model.layers.4.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
280
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
281
+ "model.layers.4.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
282
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
283
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
284
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
285
+ "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
286
+ "model.layers.5.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
287
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
288
+ "model.layers.5.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
289
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
290
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
291
+ "model.layers.5.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
292
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
293
+ "model.layers.5.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
294
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
295
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
296
+ "model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
297
+ "model.layers.6.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
298
+ "model.layers.6.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
299
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
300
+ "model.layers.6.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
301
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
302
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
303
+ "model.layers.6.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
304
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
305
+ "model.layers.6.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
306
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
307
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
308
+ "model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
309
+ "model.layers.7.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
310
+ "model.layers.7.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
311
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
312
+ "model.layers.7.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
313
+ "model.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
314
+ "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
315
+ "model.layers.7.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
316
+ "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
317
+ "model.layers.7.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
318
+ "model.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
319
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
320
+ "model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
321
+ "model.layers.8.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
322
+ "model.layers.8.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
323
+ "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
324
+ "model.layers.8.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
325
+ "model.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
326
+ "model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
327
+ "model.layers.8.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
328
+ "model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
329
+ "model.layers.8.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
330
+ "model.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
331
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
332
+ "model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
333
+ "model.layers.9.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
334
+ "model.layers.9.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
335
+ "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
336
+ "model.layers.9.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
337
+ "model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
338
+ "model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
339
+ "model.layers.9.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
340
+ "model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
341
+ "model.layers.9.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
342
+ "model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
343
+ "model.norm.weight": "model-00002-of-00002.safetensors",
344
+ "vector_linear_1024.bias": "model-00002-of-00002.safetensors",
345
+ "vector_linear_1024.weight": "model-00002-of-00002.safetensors",
346
+ "vision_model.blocks.0.attn.proj.bias": "model-00002-of-00002.safetensors",
347
+ "vision_model.blocks.0.attn.proj.weight": "model-00002-of-00002.safetensors",
348
+ "vision_model.blocks.0.attn.qkv.bias": "model-00002-of-00002.safetensors",
349
+ "vision_model.blocks.0.attn.qkv.weight": "model-00002-of-00002.safetensors",
350
+ "vision_model.blocks.0.mlp.fc1.bias": "model-00002-of-00002.safetensors",
351
+ "vision_model.blocks.0.mlp.fc1.weight": "model-00002-of-00002.safetensors",
352
+ "vision_model.blocks.0.mlp.fc2.bias": "model-00002-of-00002.safetensors",
353
+ "vision_model.blocks.0.mlp.fc2.weight": "model-00002-of-00002.safetensors",
354
+ "vision_model.blocks.0.norm1.bias": "model-00002-of-00002.safetensors",
355
+ "vision_model.blocks.0.norm1.weight": "model-00002-of-00002.safetensors",
356
+ "vision_model.blocks.0.norm2.bias": "model-00002-of-00002.safetensors",
357
+ "vision_model.blocks.0.norm2.weight": "model-00002-of-00002.safetensors",
358
+ "vision_model.blocks.1.attn.proj.bias": "model-00002-of-00002.safetensors",
359
+ "vision_model.blocks.1.attn.proj.weight": "model-00002-of-00002.safetensors",
360
+ "vision_model.blocks.1.attn.qkv.bias": "model-00002-of-00002.safetensors",
361
+ "vision_model.blocks.1.attn.qkv.weight": "model-00002-of-00002.safetensors",
362
+ "vision_model.blocks.1.mlp.fc1.bias": "model-00002-of-00002.safetensors",
363
+ "vision_model.blocks.1.mlp.fc1.weight": "model-00002-of-00002.safetensors",
364
+ "vision_model.blocks.1.mlp.fc2.bias": "model-00002-of-00002.safetensors",
365
+ "vision_model.blocks.1.mlp.fc2.weight": "model-00002-of-00002.safetensors",
366
+ "vision_model.blocks.1.norm1.bias": "model-00002-of-00002.safetensors",
367
+ "vision_model.blocks.1.norm1.weight": "model-00002-of-00002.safetensors",
368
+ "vision_model.blocks.1.norm2.bias": "model-00002-of-00002.safetensors",
369
+ "vision_model.blocks.1.norm2.weight": "model-00002-of-00002.safetensors",
370
+ "vision_model.blocks.10.attn.proj.bias": "model-00002-of-00002.safetensors",
371
+ "vision_model.blocks.10.attn.proj.weight": "model-00002-of-00002.safetensors",
372
+ "vision_model.blocks.10.attn.qkv.bias": "model-00002-of-00002.safetensors",
373
+ "vision_model.blocks.10.attn.qkv.weight": "model-00002-of-00002.safetensors",
374
+ "vision_model.blocks.10.mlp.fc1.bias": "model-00002-of-00002.safetensors",
375
+ "vision_model.blocks.10.mlp.fc1.weight": "model-00002-of-00002.safetensors",
376
+ "vision_model.blocks.10.mlp.fc2.bias": "model-00002-of-00002.safetensors",
377
+ "vision_model.blocks.10.mlp.fc2.weight": "model-00002-of-00002.safetensors",
378
+ "vision_model.blocks.10.norm1.bias": "model-00002-of-00002.safetensors",
379
+ "vision_model.blocks.10.norm1.weight": "model-00002-of-00002.safetensors",
380
+ "vision_model.blocks.10.norm2.bias": "model-00002-of-00002.safetensors",
381
+ "vision_model.blocks.10.norm2.weight": "model-00002-of-00002.safetensors",
382
+ "vision_model.blocks.11.attn.proj.bias": "model-00002-of-00002.safetensors",
383
+ "vision_model.blocks.11.attn.proj.weight": "model-00002-of-00002.safetensors",
384
+ "vision_model.blocks.11.attn.qkv.bias": "model-00002-of-00002.safetensors",
385
+ "vision_model.blocks.11.attn.qkv.weight": "model-00002-of-00002.safetensors",
386
+ "vision_model.blocks.11.mlp.fc1.bias": "model-00002-of-00002.safetensors",
387
+ "vision_model.blocks.11.mlp.fc1.weight": "model-00002-of-00002.safetensors",
388
+ "vision_model.blocks.11.mlp.fc2.bias": "model-00002-of-00002.safetensors",
389
+ "vision_model.blocks.11.mlp.fc2.weight": "model-00002-of-00002.safetensors",
390
+ "vision_model.blocks.11.norm1.bias": "model-00002-of-00002.safetensors",
391
+ "vision_model.blocks.11.norm1.weight": "model-00002-of-00002.safetensors",
392
+ "vision_model.blocks.11.norm2.bias": "model-00002-of-00002.safetensors",
393
+ "vision_model.blocks.11.norm2.weight": "model-00002-of-00002.safetensors",
394
+ "vision_model.blocks.12.attn.proj.bias": "model-00002-of-00002.safetensors",
395
+ "vision_model.blocks.12.attn.proj.weight": "model-00002-of-00002.safetensors",
396
+ "vision_model.blocks.12.attn.qkv.bias": "model-00002-of-00002.safetensors",
397
+ "vision_model.blocks.12.attn.qkv.weight": "model-00002-of-00002.safetensors",
398
+ "vision_model.blocks.12.mlp.fc1.bias": "model-00002-of-00002.safetensors",
399
+ "vision_model.blocks.12.mlp.fc1.weight": "model-00002-of-00002.safetensors",
400
+ "vision_model.blocks.12.mlp.fc2.bias": "model-00002-of-00002.safetensors",
401
+ "vision_model.blocks.12.mlp.fc2.weight": "model-00002-of-00002.safetensors",
402
+ "vision_model.blocks.12.norm1.bias": "model-00002-of-00002.safetensors",
403
+ "vision_model.blocks.12.norm1.weight": "model-00002-of-00002.safetensors",
404
+ "vision_model.blocks.12.norm2.bias": "model-00002-of-00002.safetensors",
405
+ "vision_model.blocks.12.norm2.weight": "model-00002-of-00002.safetensors",
406
+ "vision_model.blocks.13.attn.proj.bias": "model-00002-of-00002.safetensors",
407
+ "vision_model.blocks.13.attn.proj.weight": "model-00002-of-00002.safetensors",
408
+ "vision_model.blocks.13.attn.qkv.bias": "model-00002-of-00002.safetensors",
409
+ "vision_model.blocks.13.attn.qkv.weight": "model-00002-of-00002.safetensors",
410
+ "vision_model.blocks.13.mlp.fc1.bias": "model-00002-of-00002.safetensors",
411
+ "vision_model.blocks.13.mlp.fc1.weight": "model-00002-of-00002.safetensors",
412
+ "vision_model.blocks.13.mlp.fc2.bias": "model-00002-of-00002.safetensors",
413
+ "vision_model.blocks.13.mlp.fc2.weight": "model-00002-of-00002.safetensors",
414
+ "vision_model.blocks.13.norm1.bias": "model-00002-of-00002.safetensors",
415
+ "vision_model.blocks.13.norm1.weight": "model-00002-of-00002.safetensors",
416
+ "vision_model.blocks.13.norm2.bias": "model-00002-of-00002.safetensors",
417
+ "vision_model.blocks.13.norm2.weight": "model-00002-of-00002.safetensors",
418
+ "vision_model.blocks.14.attn.proj.bias": "model-00002-of-00002.safetensors",
419
+ "vision_model.blocks.14.attn.proj.weight": "model-00002-of-00002.safetensors",
420
+ "vision_model.blocks.14.attn.qkv.bias": "model-00002-of-00002.safetensors",
421
+ "vision_model.blocks.14.attn.qkv.weight": "model-00002-of-00002.safetensors",
422
+ "vision_model.blocks.14.mlp.fc1.bias": "model-00002-of-00002.safetensors",
423
+ "vision_model.blocks.14.mlp.fc1.weight": "model-00002-of-00002.safetensors",
424
+ "vision_model.blocks.14.mlp.fc2.bias": "model-00002-of-00002.safetensors",
425
+ "vision_model.blocks.14.mlp.fc2.weight": "model-00002-of-00002.safetensors",
426
+ "vision_model.blocks.14.norm1.bias": "model-00002-of-00002.safetensors",
427
+ "vision_model.blocks.14.norm1.weight": "model-00002-of-00002.safetensors",
428
+ "vision_model.blocks.14.norm2.bias": "model-00002-of-00002.safetensors",
429
+ "vision_model.blocks.14.norm2.weight": "model-00002-of-00002.safetensors",
430
+ "vision_model.blocks.15.attn.proj.bias": "model-00002-of-00002.safetensors",
431
+ "vision_model.blocks.15.attn.proj.weight": "model-00002-of-00002.safetensors",
432
+ "vision_model.blocks.15.attn.qkv.bias": "model-00002-of-00002.safetensors",
433
+ "vision_model.blocks.15.attn.qkv.weight": "model-00002-of-00002.safetensors",
434
+ "vision_model.blocks.15.mlp.fc1.bias": "model-00002-of-00002.safetensors",
435
+ "vision_model.blocks.15.mlp.fc1.weight": "model-00002-of-00002.safetensors",
436
+ "vision_model.blocks.15.mlp.fc2.bias": "model-00002-of-00002.safetensors",
437
+ "vision_model.blocks.15.mlp.fc2.weight": "model-00002-of-00002.safetensors",
438
+ "vision_model.blocks.15.norm1.bias": "model-00002-of-00002.safetensors",
439
+ "vision_model.blocks.15.norm1.weight": "model-00002-of-00002.safetensors",
440
+ "vision_model.blocks.15.norm2.bias": "model-00002-of-00002.safetensors",
441
+ "vision_model.blocks.15.norm2.weight": "model-00002-of-00002.safetensors",
442
+ "vision_model.blocks.16.attn.proj.bias": "model-00002-of-00002.safetensors",
443
+ "vision_model.blocks.16.attn.proj.weight": "model-00002-of-00002.safetensors",
444
+ "vision_model.blocks.16.attn.qkv.bias": "model-00002-of-00002.safetensors",
445
+ "vision_model.blocks.16.attn.qkv.weight": "model-00002-of-00002.safetensors",
446
+ "vision_model.blocks.16.mlp.fc1.bias": "model-00002-of-00002.safetensors",
447
+ "vision_model.blocks.16.mlp.fc1.weight": "model-00002-of-00002.safetensors",
448
+ "vision_model.blocks.16.mlp.fc2.bias": "model-00002-of-00002.safetensors",
449
+ "vision_model.blocks.16.mlp.fc2.weight": "model-00002-of-00002.safetensors",
450
+ "vision_model.blocks.16.norm1.bias": "model-00002-of-00002.safetensors",
451
+ "vision_model.blocks.16.norm1.weight": "model-00002-of-00002.safetensors",
452
+ "vision_model.blocks.16.norm2.bias": "model-00002-of-00002.safetensors",
453
+ "vision_model.blocks.16.norm2.weight": "model-00002-of-00002.safetensors",
454
+ "vision_model.blocks.17.attn.proj.bias": "model-00002-of-00002.safetensors",
455
+ "vision_model.blocks.17.attn.proj.weight": "model-00002-of-00002.safetensors",
456
+ "vision_model.blocks.17.attn.qkv.bias": "model-00002-of-00002.safetensors",
457
+ "vision_model.blocks.17.attn.qkv.weight": "model-00002-of-00002.safetensors",
458
+ "vision_model.blocks.17.mlp.fc1.bias": "model-00002-of-00002.safetensors",
459
+ "vision_model.blocks.17.mlp.fc1.weight": "model-00002-of-00002.safetensors",
460
+ "vision_model.blocks.17.mlp.fc2.bias": "model-00002-of-00002.safetensors",
461
+ "vision_model.blocks.17.mlp.fc2.weight": "model-00002-of-00002.safetensors",
462
+ "vision_model.blocks.17.norm1.bias": "model-00002-of-00002.safetensors",
463
+ "vision_model.blocks.17.norm1.weight": "model-00002-of-00002.safetensors",
464
+ "vision_model.blocks.17.norm2.bias": "model-00002-of-00002.safetensors",
465
+ "vision_model.blocks.17.norm2.weight": "model-00002-of-00002.safetensors",
466
+ "vision_model.blocks.18.attn.proj.bias": "model-00002-of-00002.safetensors",
467
+ "vision_model.blocks.18.attn.proj.weight": "model-00002-of-00002.safetensors",
468
+ "vision_model.blocks.18.attn.qkv.bias": "model-00002-of-00002.safetensors",
469
+ "vision_model.blocks.18.attn.qkv.weight": "model-00002-of-00002.safetensors",
470
+ "vision_model.blocks.18.mlp.fc1.bias": "model-00002-of-00002.safetensors",
471
+ "vision_model.blocks.18.mlp.fc1.weight": "model-00002-of-00002.safetensors",
472
+ "vision_model.blocks.18.mlp.fc2.bias": "model-00002-of-00002.safetensors",
473
+ "vision_model.blocks.18.mlp.fc2.weight": "model-00002-of-00002.safetensors",
474
+ "vision_model.blocks.18.norm1.bias": "model-00002-of-00002.safetensors",
475
+ "vision_model.blocks.18.norm1.weight": "model-00002-of-00002.safetensors",
476
+ "vision_model.blocks.18.norm2.bias": "model-00002-of-00002.safetensors",
477
+ "vision_model.blocks.18.norm2.weight": "model-00002-of-00002.safetensors",
478
+ "vision_model.blocks.19.attn.proj.bias": "model-00002-of-00002.safetensors",
479
+ "vision_model.blocks.19.attn.proj.weight": "model-00002-of-00002.safetensors",
480
+ "vision_model.blocks.19.attn.qkv.bias": "model-00002-of-00002.safetensors",
481
+ "vision_model.blocks.19.attn.qkv.weight": "model-00002-of-00002.safetensors",
482
+ "vision_model.blocks.19.mlp.fc1.bias": "model-00002-of-00002.safetensors",
483
+ "vision_model.blocks.19.mlp.fc1.weight": "model-00002-of-00002.safetensors",
484
+ "vision_model.blocks.19.mlp.fc2.bias": "model-00002-of-00002.safetensors",
485
+ "vision_model.blocks.19.mlp.fc2.weight": "model-00002-of-00002.safetensors",
486
+ "vision_model.blocks.19.norm1.bias": "model-00002-of-00002.safetensors",
487
+ "vision_model.blocks.19.norm1.weight": "model-00002-of-00002.safetensors",
488
+ "vision_model.blocks.19.norm2.bias": "model-00002-of-00002.safetensors",
489
+ "vision_model.blocks.19.norm2.weight": "model-00002-of-00002.safetensors",
490
+ "vision_model.blocks.2.attn.proj.bias": "model-00002-of-00002.safetensors",
491
+ "vision_model.blocks.2.attn.proj.weight": "model-00002-of-00002.safetensors",
492
+ "vision_model.blocks.2.attn.qkv.bias": "model-00002-of-00002.safetensors",
493
+ "vision_model.blocks.2.attn.qkv.weight": "model-00002-of-00002.safetensors",
494
+ "vision_model.blocks.2.mlp.fc1.bias": "model-00002-of-00002.safetensors",
495
+ "vision_model.blocks.2.mlp.fc1.weight": "model-00002-of-00002.safetensors",
496
+ "vision_model.blocks.2.mlp.fc2.bias": "model-00002-of-00002.safetensors",
497
+ "vision_model.blocks.2.mlp.fc2.weight": "model-00002-of-00002.safetensors",
498
+ "vision_model.blocks.2.norm1.bias": "model-00002-of-00002.safetensors",
499
+ "vision_model.blocks.2.norm1.weight": "model-00002-of-00002.safetensors",
500
+ "vision_model.blocks.2.norm2.bias": "model-00002-of-00002.safetensors",
501
+ "vision_model.blocks.2.norm2.weight": "model-00002-of-00002.safetensors",
502
+ "vision_model.blocks.20.attn.proj.bias": "model-00002-of-00002.safetensors",
503
+ "vision_model.blocks.20.attn.proj.weight": "model-00002-of-00002.safetensors",
504
+ "vision_model.blocks.20.attn.qkv.bias": "model-00002-of-00002.safetensors",
505
+ "vision_model.blocks.20.attn.qkv.weight": "model-00002-of-00002.safetensors",
506
+ "vision_model.blocks.20.mlp.fc1.bias": "model-00002-of-00002.safetensors",
507
+ "vision_model.blocks.20.mlp.fc1.weight": "model-00002-of-00002.safetensors",
508
+ "vision_model.blocks.20.mlp.fc2.bias": "model-00002-of-00002.safetensors",
509
+ "vision_model.blocks.20.mlp.fc2.weight": "model-00002-of-00002.safetensors",
510
+ "vision_model.blocks.20.norm1.bias": "model-00002-of-00002.safetensors",
511
+ "vision_model.blocks.20.norm1.weight": "model-00002-of-00002.safetensors",
512
+ "vision_model.blocks.20.norm2.bias": "model-00002-of-00002.safetensors",
513
+ "vision_model.blocks.20.norm2.weight": "model-00002-of-00002.safetensors",
514
+ "vision_model.blocks.21.attn.proj.bias": "model-00002-of-00002.safetensors",
515
+ "vision_model.blocks.21.attn.proj.weight": "model-00002-of-00002.safetensors",
516
+ "vision_model.blocks.21.attn.qkv.bias": "model-00002-of-00002.safetensors",
517
+ "vision_model.blocks.21.attn.qkv.weight": "model-00002-of-00002.safetensors",
518
+ "vision_model.blocks.21.mlp.fc1.bias": "model-00002-of-00002.safetensors",
519
+ "vision_model.blocks.21.mlp.fc1.weight": "model-00002-of-00002.safetensors",
520
+ "vision_model.blocks.21.mlp.fc2.bias": "model-00002-of-00002.safetensors",
521
+ "vision_model.blocks.21.mlp.fc2.weight": "model-00002-of-00002.safetensors",
522
+ "vision_model.blocks.21.norm1.bias": "model-00002-of-00002.safetensors",
523
+ "vision_model.blocks.21.norm1.weight": "model-00002-of-00002.safetensors",
524
+ "vision_model.blocks.21.norm2.bias": "model-00002-of-00002.safetensors",
525
+ "vision_model.blocks.21.norm2.weight": "model-00002-of-00002.safetensors",
526
+ "vision_model.blocks.22.attn.proj.bias": "model-00002-of-00002.safetensors",
527
+ "vision_model.blocks.22.attn.proj.weight": "model-00002-of-00002.safetensors",
528
+ "vision_model.blocks.22.attn.qkv.bias": "model-00002-of-00002.safetensors",
529
+ "vision_model.blocks.22.attn.qkv.weight": "model-00002-of-00002.safetensors",
530
+ "vision_model.blocks.22.mlp.fc1.bias": "model-00002-of-00002.safetensors",
531
+ "vision_model.blocks.22.mlp.fc1.weight": "model-00002-of-00002.safetensors",
532
+ "vision_model.blocks.22.mlp.fc2.bias": "model-00002-of-00002.safetensors",
533
+ "vision_model.blocks.22.mlp.fc2.weight": "model-00002-of-00002.safetensors",
534
+ "vision_model.blocks.22.norm1.bias": "model-00002-of-00002.safetensors",
535
+ "vision_model.blocks.22.norm1.weight": "model-00002-of-00002.safetensors",
536
+ "vision_model.blocks.22.norm2.bias": "model-00002-of-00002.safetensors",
537
+ "vision_model.blocks.22.norm2.weight": "model-00002-of-00002.safetensors",
538
+ "vision_model.blocks.23.attn.proj.bias": "model-00002-of-00002.safetensors",
539
+ "vision_model.blocks.23.attn.proj.weight": "model-00002-of-00002.safetensors",
540
+ "vision_model.blocks.23.attn.qkv.bias": "model-00002-of-00002.safetensors",
541
+ "vision_model.blocks.23.attn.qkv.weight": "model-00002-of-00002.safetensors",
542
+ "vision_model.blocks.23.mlp.fc1.bias": "model-00002-of-00002.safetensors",
543
+ "vision_model.blocks.23.mlp.fc1.weight": "model-00002-of-00002.safetensors",
544
+ "vision_model.blocks.23.mlp.fc2.bias": "model-00002-of-00002.safetensors",
545
+ "vision_model.blocks.23.mlp.fc2.weight": "model-00002-of-00002.safetensors",
546
+ "vision_model.blocks.23.norm1.bias": "model-00002-of-00002.safetensors",
547
+ "vision_model.blocks.23.norm1.weight": "model-00002-of-00002.safetensors",
548
+ "vision_model.blocks.23.norm2.bias": "model-00002-of-00002.safetensors",
549
+ "vision_model.blocks.23.norm2.weight": "model-00002-of-00002.safetensors",
550
+ "vision_model.blocks.24.attn.proj.bias": "model-00002-of-00002.safetensors",
551
+ "vision_model.blocks.24.attn.proj.weight": "model-00002-of-00002.safetensors",
552
+ "vision_model.blocks.24.attn.qkv.bias": "model-00002-of-00002.safetensors",
553
+ "vision_model.blocks.24.attn.qkv.weight": "model-00002-of-00002.safetensors",
554
+ "vision_model.blocks.24.mlp.fc1.bias": "model-00002-of-00002.safetensors",
555
+ "vision_model.blocks.24.mlp.fc1.weight": "model-00002-of-00002.safetensors",
556
+ "vision_model.blocks.24.mlp.fc2.bias": "model-00002-of-00002.safetensors",
557
+ "vision_model.blocks.24.mlp.fc2.weight": "model-00002-of-00002.safetensors",
558
+ "vision_model.blocks.24.norm1.bias": "model-00002-of-00002.safetensors",
559
+ "vision_model.blocks.24.norm1.weight": "model-00002-of-00002.safetensors",
560
+ "vision_model.blocks.24.norm2.bias": "model-00002-of-00002.safetensors",
561
+ "vision_model.blocks.24.norm2.weight": "model-00002-of-00002.safetensors",
562
+ "vision_model.blocks.25.attn.proj.bias": "model-00002-of-00002.safetensors",
563
+ "vision_model.blocks.25.attn.proj.weight": "model-00002-of-00002.safetensors",
564
+ "vision_model.blocks.25.attn.qkv.bias": "model-00002-of-00002.safetensors",
565
+ "vision_model.blocks.25.attn.qkv.weight": "model-00002-of-00002.safetensors",
566
+ "vision_model.blocks.25.mlp.fc1.bias": "model-00002-of-00002.safetensors",
567
+ "vision_model.blocks.25.mlp.fc1.weight": "model-00002-of-00002.safetensors",
568
+ "vision_model.blocks.25.mlp.fc2.bias": "model-00002-of-00002.safetensors",
569
+ "vision_model.blocks.25.mlp.fc2.weight": "model-00002-of-00002.safetensors",
570
+ "vision_model.blocks.25.norm1.bias": "model-00002-of-00002.safetensors",
571
+ "vision_model.blocks.25.norm1.weight": "model-00002-of-00002.safetensors",
572
+ "vision_model.blocks.25.norm2.bias": "model-00002-of-00002.safetensors",
573
+ "vision_model.blocks.25.norm2.weight": "model-00002-of-00002.safetensors",
574
+ "vision_model.blocks.26.attn.proj.bias": "model-00002-of-00002.safetensors",
575
+ "vision_model.blocks.26.attn.proj.weight": "model-00002-of-00002.safetensors",
576
+ "vision_model.blocks.26.attn.qkv.bias": "model-00002-of-00002.safetensors",
577
+ "vision_model.blocks.26.attn.qkv.weight": "model-00002-of-00002.safetensors",
578
+ "vision_model.blocks.26.mlp.fc1.bias": "model-00002-of-00002.safetensors",
579
+ "vision_model.blocks.26.mlp.fc1.weight": "model-00002-of-00002.safetensors",
580
+ "vision_model.blocks.26.mlp.fc2.bias": "model-00002-of-00002.safetensors",
581
+ "vision_model.blocks.26.mlp.fc2.weight": "model-00002-of-00002.safetensors",
582
+ "vision_model.blocks.26.norm1.bias": "model-00002-of-00002.safetensors",
583
+ "vision_model.blocks.26.norm1.weight": "model-00002-of-00002.safetensors",
584
+ "vision_model.blocks.26.norm2.bias": "model-00002-of-00002.safetensors",
585
+ "vision_model.blocks.26.norm2.weight": "model-00002-of-00002.safetensors",
586
+ "vision_model.blocks.27.attn.proj.bias": "model-00002-of-00002.safetensors",
587
+ "vision_model.blocks.27.attn.proj.weight": "model-00002-of-00002.safetensors",
588
+ "vision_model.blocks.27.attn.qkv.bias": "model-00002-of-00002.safetensors",
589
+ "vision_model.blocks.27.attn.qkv.weight": "model-00002-of-00002.safetensors",
590
+ "vision_model.blocks.27.mlp.fc1.bias": "model-00002-of-00002.safetensors",
591
+ "vision_model.blocks.27.mlp.fc1.weight": "model-00002-of-00002.safetensors",
592
+ "vision_model.blocks.27.mlp.fc2.bias": "model-00002-of-00002.safetensors",
593
+ "vision_model.blocks.27.mlp.fc2.weight": "model-00002-of-00002.safetensors",
594
+ "vision_model.blocks.27.norm1.bias": "model-00002-of-00002.safetensors",
595
+ "vision_model.blocks.27.norm1.weight": "model-00002-of-00002.safetensors",
596
+ "vision_model.blocks.27.norm2.bias": "model-00002-of-00002.safetensors",
597
+ "vision_model.blocks.27.norm2.weight": "model-00002-of-00002.safetensors",
598
+ "vision_model.blocks.28.attn.proj.bias": "model-00002-of-00002.safetensors",
599
+ "vision_model.blocks.28.attn.proj.weight": "model-00002-of-00002.safetensors",
600
+ "vision_model.blocks.28.attn.qkv.bias": "model-00002-of-00002.safetensors",
601
+ "vision_model.blocks.28.attn.qkv.weight": "model-00002-of-00002.safetensors",
602
+ "vision_model.blocks.28.mlp.fc1.bias": "model-00002-of-00002.safetensors",
603
+ "vision_model.blocks.28.mlp.fc1.weight": "model-00002-of-00002.safetensors",
604
+ "vision_model.blocks.28.mlp.fc2.bias": "model-00002-of-00002.safetensors",
605
+ "vision_model.blocks.28.mlp.fc2.weight": "model-00002-of-00002.safetensors",
606
+ "vision_model.blocks.28.norm1.bias": "model-00002-of-00002.safetensors",
607
+ "vision_model.blocks.28.norm1.weight": "model-00002-of-00002.safetensors",
608
+ "vision_model.blocks.28.norm2.bias": "model-00002-of-00002.safetensors",
609
+ "vision_model.blocks.28.norm2.weight": "model-00002-of-00002.safetensors",
610
+ "vision_model.blocks.29.attn.proj.bias": "model-00002-of-00002.safetensors",
611
+ "vision_model.blocks.29.attn.proj.weight": "model-00002-of-00002.safetensors",
612
+ "vision_model.blocks.29.attn.qkv.bias": "model-00002-of-00002.safetensors",
613
+ "vision_model.blocks.29.attn.qkv.weight": "model-00002-of-00002.safetensors",
614
+ "vision_model.blocks.29.mlp.fc1.bias": "model-00002-of-00002.safetensors",
615
+ "vision_model.blocks.29.mlp.fc1.weight": "model-00002-of-00002.safetensors",
616
+ "vision_model.blocks.29.mlp.fc2.bias": "model-00002-of-00002.safetensors",
617
+ "vision_model.blocks.29.mlp.fc2.weight": "model-00002-of-00002.safetensors",
618
+ "vision_model.blocks.29.norm1.bias": "model-00002-of-00002.safetensors",
619
+ "vision_model.blocks.29.norm1.weight": "model-00002-of-00002.safetensors",
620
+ "vision_model.blocks.29.norm2.bias": "model-00002-of-00002.safetensors",
621
+ "vision_model.blocks.29.norm2.weight": "model-00002-of-00002.safetensors",
622
+ "vision_model.blocks.3.attn.proj.bias": "model-00002-of-00002.safetensors",
623
+ "vision_model.blocks.3.attn.proj.weight": "model-00002-of-00002.safetensors",
624
+ "vision_model.blocks.3.attn.qkv.bias": "model-00002-of-00002.safetensors",
625
+ "vision_model.blocks.3.attn.qkv.weight": "model-00002-of-00002.safetensors",
626
+ "vision_model.blocks.3.mlp.fc1.bias": "model-00002-of-00002.safetensors",
627
+ "vision_model.blocks.3.mlp.fc1.weight": "model-00002-of-00002.safetensors",
628
+ "vision_model.blocks.3.mlp.fc2.bias": "model-00002-of-00002.safetensors",
629
+ "vision_model.blocks.3.mlp.fc2.weight": "model-00002-of-00002.safetensors",
630
+ "vision_model.blocks.3.norm1.bias": "model-00002-of-00002.safetensors",
631
+ "vision_model.blocks.3.norm1.weight": "model-00002-of-00002.safetensors",
632
+ "vision_model.blocks.3.norm2.bias": "model-00002-of-00002.safetensors",
633
+ "vision_model.blocks.3.norm2.weight": "model-00002-of-00002.safetensors",
634
+ "vision_model.blocks.30.attn.proj.bias": "model-00002-of-00002.safetensors",
635
+ "vision_model.blocks.30.attn.proj.weight": "model-00002-of-00002.safetensors",
636
+ "vision_model.blocks.30.attn.qkv.bias": "model-00002-of-00002.safetensors",
637
+ "vision_model.blocks.30.attn.qkv.weight": "model-00002-of-00002.safetensors",
638
+ "vision_model.blocks.30.mlp.fc1.bias": "model-00002-of-00002.safetensors",
639
+ "vision_model.blocks.30.mlp.fc1.weight": "model-00002-of-00002.safetensors",
640
+ "vision_model.blocks.30.mlp.fc2.bias": "model-00002-of-00002.safetensors",
641
+ "vision_model.blocks.30.mlp.fc2.weight": "model-00002-of-00002.safetensors",
642
+ "vision_model.blocks.30.norm1.bias": "model-00002-of-00002.safetensors",
643
+ "vision_model.blocks.30.norm1.weight": "model-00002-of-00002.safetensors",
644
+ "vision_model.blocks.30.norm2.bias": "model-00002-of-00002.safetensors",
645
+ "vision_model.blocks.30.norm2.weight": "model-00002-of-00002.safetensors",
646
+ "vision_model.blocks.31.attn.proj.bias": "model-00002-of-00002.safetensors",
647
+ "vision_model.blocks.31.attn.proj.weight": "model-00002-of-00002.safetensors",
648
+ "vision_model.blocks.31.attn.qkv.bias": "model-00002-of-00002.safetensors",
649
+ "vision_model.blocks.31.attn.qkv.weight": "model-00002-of-00002.safetensors",
650
+ "vision_model.blocks.31.mlp.fc1.bias": "model-00002-of-00002.safetensors",
651
+ "vision_model.blocks.31.mlp.fc1.weight": "model-00002-of-00002.safetensors",
652
+ "vision_model.blocks.31.mlp.fc2.bias": "model-00002-of-00002.safetensors",
653
+ "vision_model.blocks.31.mlp.fc2.weight": "model-00002-of-00002.safetensors",
654
+ "vision_model.blocks.31.norm1.bias": "model-00002-of-00002.safetensors",
655
+ "vision_model.blocks.31.norm1.weight": "model-00002-of-00002.safetensors",
656
+ "vision_model.blocks.31.norm2.bias": "model-00002-of-00002.safetensors",
657
+ "vision_model.blocks.31.norm2.weight": "model-00002-of-00002.safetensors",
658
+ "vision_model.blocks.4.attn.proj.bias": "model-00002-of-00002.safetensors",
659
+ "vision_model.blocks.4.attn.proj.weight": "model-00002-of-00002.safetensors",
660
+ "vision_model.blocks.4.attn.qkv.bias": "model-00002-of-00002.safetensors",
661
+ "vision_model.blocks.4.attn.qkv.weight": "model-00002-of-00002.safetensors",
662
+ "vision_model.blocks.4.mlp.fc1.bias": "model-00002-of-00002.safetensors",
663
+ "vision_model.blocks.4.mlp.fc1.weight": "model-00002-of-00002.safetensors",
664
+ "vision_model.blocks.4.mlp.fc2.bias": "model-00002-of-00002.safetensors",
665
+ "vision_model.blocks.4.mlp.fc2.weight": "model-00002-of-00002.safetensors",
666
+ "vision_model.blocks.4.norm1.bias": "model-00002-of-00002.safetensors",
667
+ "vision_model.blocks.4.norm1.weight": "model-00002-of-00002.safetensors",
668
+ "vision_model.blocks.4.norm2.bias": "model-00002-of-00002.safetensors",
669
+ "vision_model.blocks.4.norm2.weight": "model-00002-of-00002.safetensors",
670
+ "vision_model.blocks.5.attn.proj.bias": "model-00002-of-00002.safetensors",
671
+ "vision_model.blocks.5.attn.proj.weight": "model-00002-of-00002.safetensors",
672
+ "vision_model.blocks.5.attn.qkv.bias": "model-00002-of-00002.safetensors",
673
+ "vision_model.blocks.5.attn.qkv.weight": "model-00002-of-00002.safetensors",
674
+ "vision_model.blocks.5.mlp.fc1.bias": "model-00002-of-00002.safetensors",
675
+ "vision_model.blocks.5.mlp.fc1.weight": "model-00002-of-00002.safetensors",
676
+ "vision_model.blocks.5.mlp.fc2.bias": "model-00002-of-00002.safetensors",
677
+ "vision_model.blocks.5.mlp.fc2.weight": "model-00002-of-00002.safetensors",
678
+ "vision_model.blocks.5.norm1.bias": "model-00002-of-00002.safetensors",
679
+ "vision_model.blocks.5.norm1.weight": "model-00002-of-00002.safetensors",
680
+ "vision_model.blocks.5.norm2.bias": "model-00002-of-00002.safetensors",
681
+ "vision_model.blocks.5.norm2.weight": "model-00002-of-00002.safetensors",
682
+ "vision_model.blocks.6.attn.proj.bias": "model-00002-of-00002.safetensors",
683
+ "vision_model.blocks.6.attn.proj.weight": "model-00002-of-00002.safetensors",
684
+ "vision_model.blocks.6.attn.qkv.bias": "model-00002-of-00002.safetensors",
685
+ "vision_model.blocks.6.attn.qkv.weight": "model-00002-of-00002.safetensors",
686
+ "vision_model.blocks.6.mlp.fc1.bias": "model-00002-of-00002.safetensors",
687
+ "vision_model.blocks.6.mlp.fc1.weight": "model-00002-of-00002.safetensors",
688
+ "vision_model.blocks.6.mlp.fc2.bias": "model-00002-of-00002.safetensors",
689
+ "vision_model.blocks.6.mlp.fc2.weight": "model-00002-of-00002.safetensors",
690
+ "vision_model.blocks.6.norm1.bias": "model-00002-of-00002.safetensors",
691
+ "vision_model.blocks.6.norm1.weight": "model-00002-of-00002.safetensors",
692
+ "vision_model.blocks.6.norm2.bias": "model-00002-of-00002.safetensors",
693
+ "vision_model.blocks.6.norm2.weight": "model-00002-of-00002.safetensors",
694
+ "vision_model.blocks.7.attn.proj.bias": "model-00002-of-00002.safetensors",
695
+ "vision_model.blocks.7.attn.proj.weight": "model-00002-of-00002.safetensors",
696
+ "vision_model.blocks.7.attn.qkv.bias": "model-00002-of-00002.safetensors",
697
+ "vision_model.blocks.7.attn.qkv.weight": "model-00002-of-00002.safetensors",
698
+ "vision_model.blocks.7.mlp.fc1.bias": "model-00002-of-00002.safetensors",
699
+ "vision_model.blocks.7.mlp.fc1.weight": "model-00002-of-00002.safetensors",
700
+ "vision_model.blocks.7.mlp.fc2.bias": "model-00002-of-00002.safetensors",
701
+ "vision_model.blocks.7.mlp.fc2.weight": "model-00002-of-00002.safetensors",
702
+ "vision_model.blocks.7.norm1.bias": "model-00002-of-00002.safetensors",
703
+ "vision_model.blocks.7.norm1.weight": "model-00002-of-00002.safetensors",
704
+ "vision_model.blocks.7.norm2.bias": "model-00002-of-00002.safetensors",
705
+ "vision_model.blocks.7.norm2.weight": "model-00002-of-00002.safetensors",
706
+ "vision_model.blocks.8.attn.proj.bias": "model-00002-of-00002.safetensors",
707
+ "vision_model.blocks.8.attn.proj.weight": "model-00002-of-00002.safetensors",
708
+ "vision_model.blocks.8.attn.qkv.bias": "model-00002-of-00002.safetensors",
709
+ "vision_model.blocks.8.attn.qkv.weight": "model-00002-of-00002.safetensors",
710
+ "vision_model.blocks.8.mlp.fc1.bias": "model-00002-of-00002.safetensors",
711
+ "vision_model.blocks.8.mlp.fc1.weight": "model-00002-of-00002.safetensors",
712
+ "vision_model.blocks.8.mlp.fc2.bias": "model-00002-of-00002.safetensors",
713
+ "vision_model.blocks.8.mlp.fc2.weight": "model-00002-of-00002.safetensors",
714
+ "vision_model.blocks.8.norm1.bias": "model-00002-of-00002.safetensors",
715
+ "vision_model.blocks.8.norm1.weight": "model-00002-of-00002.safetensors",
716
+ "vision_model.blocks.8.norm2.bias": "model-00002-of-00002.safetensors",
717
+ "vision_model.blocks.8.norm2.weight": "model-00002-of-00002.safetensors",
718
+ "vision_model.blocks.9.attn.proj.bias": "model-00002-of-00002.safetensors",
719
+ "vision_model.blocks.9.attn.proj.weight": "model-00002-of-00002.safetensors",
720
+ "vision_model.blocks.9.attn.qkv.bias": "model-00002-of-00002.safetensors",
721
+ "vision_model.blocks.9.attn.qkv.weight": "model-00002-of-00002.safetensors",
722
+ "vision_model.blocks.9.mlp.fc1.bias": "model-00002-of-00002.safetensors",
723
+ "vision_model.blocks.9.mlp.fc1.weight": "model-00002-of-00002.safetensors",
724
+ "vision_model.blocks.9.mlp.fc2.bias": "model-00002-of-00002.safetensors",
725
+ "vision_model.blocks.9.mlp.fc2.weight": "model-00002-of-00002.safetensors",
726
+ "vision_model.blocks.9.norm1.bias": "model-00002-of-00002.safetensors",
727
+ "vision_model.blocks.9.norm1.weight": "model-00002-of-00002.safetensors",
728
+ "vision_model.blocks.9.norm2.bias": "model-00002-of-00002.safetensors",
729
+ "vision_model.blocks.9.norm2.weight": "model-00002-of-00002.safetensors",
730
+ "vision_model.merger.ln_q.bias": "model-00002-of-00002.safetensors",
731
+ "vision_model.merger.ln_q.weight": "model-00002-of-00002.safetensors",
732
+ "vision_model.merger.mlp.0.bias": "model-00002-of-00002.safetensors",
733
+ "vision_model.merger.mlp.0.weight": "model-00002-of-00002.safetensors",
734
+ "vision_model.merger.mlp.2.bias": "model-00002-of-00002.safetensors",
735
+ "vision_model.merger.mlp.2.weight": "model-00002-of-00002.safetensors",
736
+ "vision_model.patch_embed.proj.weight": "model-00002-of-00002.safetensors"
737
+ }
738
+ }
modeling_colqwenstella.py ADDED
@@ -0,0 +1,1636 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
5
+ # and OPT implementations in this library. It has been modified from its
6
+ # original forms to accommodate minor architectural differences compared
7
+ # to GPT-NeoX and OPT used by the Meta AI team that trained the model.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ """ PyTorch Qwen2 model."""
21
+ from transformers import Qwen2Config
22
+ import inspect
23
+ import math
24
+ import os
25
+ import warnings
26
+ from typing import List, Optional, Tuple, Union
27
+
28
+ import torch
29
+ import torch.nn.functional as F
30
+ import torch.utils.checkpoint
31
+ from torch import nn
32
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
33
+ from transformers import AutoConfig, AutoModel
34
+ from transformers.activations import ACT2FN
35
+ from transformers.cache_utils import Cache, DynamicCache
36
+ from transformers.modeling_attn_mask_utils import _prepare_4d_causal_attention_mask, _prepare_4d_causal_attention_mask_for_sdpa, _prepare_4d_attention_mask, _prepare_4d_attention_mask_for_sdpa
37
+ from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
38
+ from transformers.modeling_utils import PreTrainedModel
39
+ from transformers.utils import (
40
+ add_start_docstrings,
41
+ add_start_docstrings_to_model_forward,
42
+ is_flash_attn_2_available,
43
+ is_flash_attn_greater_or_equal_2_10,
44
+ logging,
45
+ replace_return_docstrings,
46
+ )
47
+
48
+
49
+ if is_flash_attn_2_available():
50
+ from flash_attn import flash_attn_func, flash_attn_varlen_func
51
+ from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
52
+
53
+ _flash_supports_window_size = "window_size" in list(inspect.signature(flash_attn_func).parameters)
54
+
55
+ # REMOVE THE CODE ABOVE SHOULD ALLOW FOR RUNNING OF THIS MODEL WITHOUT FLASH ATTENTION SUPPORT.
56
+
57
+
58
+ logger = logging.get_logger(__name__)
59
+
60
+
61
+ _CHECKPOINT_FOR_DOC = "Qwen/Qwen2-7B-beta"
62
+ _CONFIG_FOR_DOC = "Qwen2Config"
63
+
64
+ QWEN2_PRETRAINED_MODEL_ARCHIVE_LIST = [
65
+ "Qwen/Qwen2-7B-beta",
66
+ # See all Qwen2 models at https://huggingface.co/models?filter=qwen2
67
+ ]
68
+
69
+
70
+ # Copied from transformers.models.llama.modeling_llama._get_unpad_data
71
+ def _get_unpad_data(attention_mask):
72
+ seqlens_in_batch = attention_mask.sum(dim=-1, dtype=torch.int32)
73
+ indices = torch.nonzero(attention_mask.flatten(), as_tuple=False).flatten()
74
+ max_seqlen_in_batch = seqlens_in_batch.max().item()
75
+ cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.int32), (1, 0))
76
+ return (
77
+ indices,
78
+ cu_seqlens,
79
+ max_seqlen_in_batch,
80
+ )
81
+
82
+
83
+ # Copied from transformers.models.llama.modeling_llama.LlamaRMSNorm with Llama->Qwen2
84
+ class Qwen2RMSNorm(nn.Module):
85
+ def __init__(self, hidden_size, eps=1e-6):
86
+ """
87
+ Qwen2RMSNorm is equivalent to T5LayerNorm
88
+ """
89
+ super().__init__()
90
+ self.weight = nn.Parameter(torch.ones(hidden_size))
91
+ self.variance_epsilon = eps
92
+
93
+ def forward(self, hidden_states):
94
+ input_dtype = hidden_states.dtype
95
+ hidden_states = hidden_states.to(torch.float32)
96
+ variance = hidden_states.pow(2).mean(-1, keepdim=True)
97
+ hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
98
+ return self.weight * hidden_states.to(input_dtype)
99
+
100
+
101
+ # Copied from transformers.models.mistral.modeling_mistral.MistralRotaryEmbedding with Mistral->Qwen2
102
+ class Qwen2RotaryEmbedding(nn.Module):
103
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
104
+ super().__init__()
105
+
106
+ self.dim = dim
107
+ self.max_position_embeddings = max_position_embeddings
108
+ self.base = base
109
+ inv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2, dtype=torch.int64).float().to(device) / self.dim))
110
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
111
+
112
+ # Build here to make `torch.jit.trace` work.
113
+ self._set_cos_sin_cache(
114
+ seq_len=max_position_embeddings, device=self.inv_freq.device, dtype=torch.get_default_dtype()
115
+ )
116
+
117
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
118
+ self.max_seq_len_cached = seq_len
119
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=torch.int64).type_as(self.inv_freq)
120
+
121
+ freqs = torch.outer(t, self.inv_freq)
122
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
123
+ emb = torch.cat((freqs, freqs), dim=-1)
124
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
125
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
126
+
127
+ def forward(self, x, seq_len=None):
128
+ # x: [bs, num_attention_heads, seq_len, head_size]
129
+ if seq_len > self.max_seq_len_cached:
130
+ self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=x.dtype)
131
+
132
+ return (
133
+ self.cos_cached[:seq_len].to(dtype=x.dtype),
134
+ self.sin_cached[:seq_len].to(dtype=x.dtype),
135
+ )
136
+
137
+
138
+ # Copied from transformers.models.llama.modeling_llama.rotate_half
139
+ def rotate_half(x):
140
+ """Rotates half the hidden dims of the input."""
141
+ x1 = x[..., : x.shape[-1] // 2]
142
+ x2 = x[..., x.shape[-1] // 2 :]
143
+ return torch.cat((-x2, x1), dim=-1)
144
+
145
+
146
+ # Copied from transformers.models.mistral.modeling_mistral.apply_rotary_pos_emb
147
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids, unsqueeze_dim=1):
148
+ """Applies Rotary Position Embedding to the query and key tensors.
149
+
150
+ Args:
151
+ q (`torch.Tensor`): The query tensor.
152
+ k (`torch.Tensor`): The key tensor.
153
+ cos (`torch.Tensor`): The cosine part of the rotary embedding.
154
+ sin (`torch.Tensor`): The sine part of the rotary embedding.
155
+ position_ids (`torch.Tensor`):
156
+ The position indices of the tokens corresponding to the query and key tensors. For example, this can be
157
+ used to pass offsetted position ids when working with a KV-cache.
158
+ unsqueeze_dim (`int`, *optional*, defaults to 1):
159
+ The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
160
+ sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
161
+ that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
162
+ k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
163
+ cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
164
+ the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
165
+ Returns:
166
+ `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
167
+ """
168
+ cos = cos[position_ids].unsqueeze(unsqueeze_dim)
169
+ sin = sin[position_ids].unsqueeze(unsqueeze_dim)
170
+ q_embed = (q * cos) + (rotate_half(q) * sin)
171
+ k_embed = (k * cos) + (rotate_half(k) * sin)
172
+ return q_embed, k_embed
173
+
174
+
175
+ # Copied from transformers.models.mistral.modeling_mistral.MistralMLP with Mistral->Qwen2
176
+ class Qwen2MLP(nn.Module):
177
+ def __init__(self, config):
178
+ super().__init__()
179
+ self.config = config
180
+ self.hidden_size = config.hidden_size
181
+ self.intermediate_size = config.intermediate_size
182
+ self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
183
+ self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
184
+ self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
185
+ self.act_fn = ACT2FN[config.hidden_act]
186
+
187
+ def forward(self, x):
188
+ return self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
189
+
190
+
191
+ # Copied from transformers.models.llama.modeling_llama.repeat_kv
192
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
193
+ """
194
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
195
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
196
+ """
197
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
198
+ if n_rep == 1:
199
+ return hidden_states
200
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
201
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
202
+
203
+
204
+ class Qwen2Attention(nn.Module):
205
+ """
206
+ Multi-headed attention from 'Attention Is All You Need' paper. Modified to use sliding window attention: Longformer
207
+ and "Generating Long Sequences with Sparse Transformers".
208
+ """
209
+
210
+ def __init__(self, config: Qwen2Config, layer_idx: Optional[int] = None):
211
+ super().__init__()
212
+ self.config = config
213
+ self.layer_idx = layer_idx
214
+ if layer_idx is None:
215
+ logger.warning_once(
216
+ f"Instantiating {self.__class__.__name__} without passing `layer_idx` is not recommended and will "
217
+ "to errors during the forward call, if caching is used. Please make sure to provide a `layer_idx` "
218
+ "when creating this class."
219
+ )
220
+
221
+ self.hidden_size = config.hidden_size
222
+ self.num_heads = config.num_attention_heads
223
+ self.head_dim = self.hidden_size // self.num_heads
224
+ self.num_key_value_heads = config.num_key_value_heads
225
+ self.num_key_value_groups = self.num_heads // self.num_key_value_heads
226
+ self.max_position_embeddings = config.max_position_embeddings
227
+ self.rope_theta = config.rope_theta
228
+ self.is_causal = True
229
+ self.attention_dropout = config.attention_dropout
230
+
231
+ if (self.head_dim * self.num_heads) != self.hidden_size:
232
+ raise ValueError(
233
+ f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
234
+ f" and `num_heads`: {self.num_heads})."
235
+ )
236
+ self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=True)
237
+ self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=True)
238
+ self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=True)
239
+ self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=False)
240
+
241
+ self.rotary_emb = Qwen2RotaryEmbedding(
242
+ self.head_dim,
243
+ max_position_embeddings=self.max_position_embeddings,
244
+ base=self.rope_theta,
245
+ )
246
+
247
+ def forward(
248
+ self,
249
+ hidden_states: torch.Tensor,
250
+ attention_mask: Optional[torch.Tensor] = None,
251
+ position_ids: Optional[torch.LongTensor] = None,
252
+ past_key_value: Optional[Cache] = None,
253
+ output_attentions: bool = False,
254
+ use_cache: bool = False,
255
+ **kwargs,
256
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
257
+ if "padding_mask" in kwargs:
258
+ warnings.warn(
259
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
260
+ )
261
+ bsz, q_len, _ = hidden_states.size()
262
+
263
+ query_states = self.q_proj(hidden_states)
264
+ key_states = self.k_proj(hidden_states)
265
+ value_states = self.v_proj(hidden_states)
266
+
267
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
268
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
269
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
270
+
271
+ kv_seq_len = key_states.shape[-2]
272
+ if past_key_value is not None:
273
+ if self.layer_idx is None:
274
+ raise ValueError(
275
+ f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
276
+ "for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
277
+ "with a layer index."
278
+ )
279
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
280
+ cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
281
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
282
+
283
+ if past_key_value is not None:
284
+ cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
285
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
286
+
287
+ # repeat k/v heads if n_kv_heads < n_heads
288
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
289
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
290
+
291
+ attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
292
+
293
+ if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
294
+ raise ValueError(
295
+ f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
296
+ f" {attn_weights.size()}"
297
+ )
298
+
299
+ if attention_mask is not None:
300
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
301
+ raise ValueError(
302
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
303
+ )
304
+
305
+ attn_weights = attn_weights + attention_mask
306
+
307
+ # upcast attention to fp32
308
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
309
+ attn_weights = nn.functional.dropout(attn_weights, p=self.attention_dropout, training=self.training)
310
+ attn_output = torch.matmul(attn_weights, value_states)
311
+
312
+ if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
313
+ raise ValueError(
314
+ f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
315
+ f" {attn_output.size()}"
316
+ )
317
+
318
+ attn_output = attn_output.transpose(1, 2).contiguous()
319
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
320
+
321
+ attn_output = self.o_proj(attn_output)
322
+
323
+ if not output_attentions:
324
+ attn_weights = None
325
+
326
+ return attn_output, attn_weights, past_key_value
327
+
328
+
329
+ class Qwen2FlashAttention2(Qwen2Attention):
330
+ """
331
+ Qwen2 flash attention module, following Qwen2 attention module. This module inherits from `Qwen2Attention`
332
+ as the weights of the module stays untouched. The only required change would be on the forward pass
333
+ where it needs to correctly call the public API of flash attention and deal with padding tokens
334
+ in case the input contains any of them. Additionally, for sliding window attention, we apply SWA only to the bottom
335
+ config.max_window_layers layers.
336
+ """
337
+
338
+ # Copied from transformers.models.llama.modeling_llama.LlamaFlashAttention2.__init__
339
+ def __init__(self, *args, **kwargs):
340
+ super().__init__(*args, **kwargs)
341
+
342
+ # TODO: Should be removed once Flash Attention for RoCm is bumped to 2.1.
343
+ # flash_attn<2.1 generates top-left aligned causal mask, while what is needed here is bottom-right alignement, that was made default for flash_attn>=2.1. This attribute is used to handle this difference. Reference: https://github.com/Dao-AILab/flash-attention/releases/tag/v2.1.0.
344
+ # Beware that with flash_attn<2.1, using q_seqlen != k_seqlen (except for the case q_seqlen == 1) produces a wrong mask (top-left).
345
+ self._flash_attn_uses_top_left_mask = not is_flash_attn_greater_or_equal_2_10()
346
+
347
+ def forward(
348
+ self,
349
+ hidden_states: torch.Tensor,
350
+ attention_mask: Optional[torch.Tensor] = None,
351
+ position_ids: Optional[torch.LongTensor] = None,
352
+ past_key_value: Optional[Cache] = None,
353
+ output_attentions: bool = False,
354
+ use_cache: bool = False,
355
+ is_causal: bool = False,
356
+ **kwargs,
357
+ ):
358
+ if "padding_mask" in kwargs:
359
+ warnings.warn(
360
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
361
+ )
362
+
363
+ # overwrite attention_mask with padding_mask
364
+ attention_mask = kwargs.pop("padding_mask")
365
+ bsz, q_len, _ = hidden_states.size()
366
+
367
+ query_states = self.q_proj(hidden_states)
368
+ key_states = self.k_proj(hidden_states)
369
+ value_states = self.v_proj(hidden_states)
370
+
371
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
372
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
373
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
374
+
375
+ kv_seq_len = key_states.shape[-2]
376
+ if past_key_value is not None:
377
+ if self.layer_idx is None:
378
+ raise ValueError(
379
+ f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
380
+ "for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
381
+ "with a layer index."
382
+ )
383
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
384
+
385
+ # Because the input can be padded, the absolute sequence length depends on the max position id.
386
+ rotary_seq_len = max(kv_seq_len, position_ids[:, -1].max().item()) + 1
387
+ cos, sin = self.rotary_emb(value_states, seq_len=rotary_seq_len)
388
+
389
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
390
+
391
+ use_sliding_windows = (
392
+ _flash_supports_window_size
393
+ and getattr(self.config, "sliding_window", None) is not None
394
+ and kv_seq_len > self.config.sliding_window
395
+ and self.config.use_sliding_window
396
+ )
397
+
398
+ if not _flash_supports_window_size:
399
+ logger.warning_once(
400
+ "The current flash attention version does not support sliding window attention, for a more memory efficient implementation"
401
+ " make sure to upgrade flash-attn library."
402
+ )
403
+
404
+ if past_key_value is not None:
405
+ # Activate slicing cache only if the config has a value `sliding_windows` attribute
406
+ cache_has_contents = past_key_value.get_seq_length(self.layer_idx) > 0
407
+ if (
408
+ getattr(self.config, "sliding_window", None) is not None
409
+ and kv_seq_len > self.config.sliding_window
410
+ and cache_has_contents
411
+ ):
412
+ slicing_tokens = 1 - self.config.sliding_window
413
+
414
+ past_key = past_key_value[self.layer_idx][0]
415
+ past_value = past_key_value[self.layer_idx][1]
416
+
417
+ past_key = past_key[:, :, slicing_tokens:, :].contiguous()
418
+ past_value = past_value[:, :, slicing_tokens:, :].contiguous()
419
+
420
+ if past_key.shape[-2] != self.config.sliding_window - 1:
421
+ raise ValueError(
422
+ f"past key must have a shape of (`batch_size, num_heads, self.config.sliding_window-1, head_dim`), got"
423
+ f" {past_key.shape}"
424
+ )
425
+
426
+ if attention_mask is not None:
427
+ attention_mask = attention_mask[:, slicing_tokens:]
428
+ attention_mask = torch.cat([attention_mask, torch.ones_like(attention_mask[:, -1:])], dim=-1)
429
+
430
+ cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
431
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
432
+
433
+ # repeat k/v heads if n_kv_heads < n_heads
434
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
435
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
436
+ dropout_rate = 0.0 if not self.training else self.attention_dropout
437
+
438
+ # In PEFT, usually we cast the layer norms in float32 for training stability reasons
439
+ # therefore the input hidden states gets silently casted in float32. Hence, we need
440
+ # cast them back in float16 just to be sure everything works as expected.
441
+ input_dtype = query_states.dtype
442
+ if input_dtype == torch.float32:
443
+ if torch.is_autocast_enabled():
444
+ target_dtype = torch.get_autocast_gpu_dtype()
445
+ # Handle the case where the model is quantized
446
+ elif hasattr(self.config, "_pre_quantization_dtype"):
447
+ target_dtype = self.config._pre_quantization_dtype
448
+ else:
449
+ target_dtype = self.q_proj.weight.dtype
450
+
451
+ logger.warning_once(
452
+ f"The input hidden states seems to be silently casted in float32, this might be related to"
453
+ f" the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
454
+ f" {target_dtype}."
455
+ )
456
+
457
+ query_states = query_states.to(target_dtype)
458
+ key_states = key_states.to(target_dtype)
459
+ value_states = value_states.to(target_dtype)
460
+
461
+ # Reashape to the expected shape for Flash Attention
462
+ query_states = query_states.transpose(1, 2)
463
+ key_states = key_states.transpose(1, 2)
464
+ value_states = value_states.transpose(1, 2)
465
+
466
+ attn_output = self._flash_attention_forward(
467
+ query_states,
468
+ key_states,
469
+ value_states,
470
+ attention_mask,
471
+ q_len,
472
+ dropout=dropout_rate,
473
+ use_sliding_windows=use_sliding_windows,
474
+ is_causal=is_causal
475
+ )
476
+
477
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size).contiguous()
478
+ attn_output = self.o_proj(attn_output)
479
+
480
+ if not output_attentions:
481
+ attn_weights = None
482
+
483
+ return attn_output, attn_weights, past_key_value
484
+
485
+ def _flash_attention_forward(
486
+ self,
487
+ query_states,
488
+ key_states,
489
+ value_states,
490
+ attention_mask,
491
+ query_length,
492
+ dropout=0.0,
493
+ softmax_scale=None,
494
+ use_sliding_windows=False,
495
+ is_causal=True,
496
+ ):
497
+ """
498
+ Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
499
+ first unpad the input, then computes the attention scores and pad the final attention scores.
500
+
501
+ Args:
502
+ query_states (`torch.Tensor`):
503
+ Input query states to be passed to Flash Attention API
504
+ key_states (`torch.Tensor`):
505
+ Input key states to be passed to Flash Attention API
506
+ value_states (`torch.Tensor`):
507
+ Input value states to be passed to Flash Attention API
508
+ attention_mask (`torch.Tensor`):
509
+ The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
510
+ position of padding tokens and 1 for the position of non-padding tokens.
511
+ dropout (`int`, *optional*):
512
+ Attention dropout
513
+ softmax_scale (`float`, *optional*):
514
+ The scaling of QK^T before applying softmax. Default to 1 / sqrt(head_dim)
515
+ use_sliding_windows (`bool`, *optional*):
516
+ Whether to activate sliding window attention.
517
+ """
518
+ if not self._flash_attn_uses_top_left_mask:
519
+ causal = is_causal
520
+ else:
521
+ # TODO: Remove the `query_length != 1` check once Flash Attention for RoCm is bumped to 2.1. For details, please see the comment in LlamaFlashAttention2 __init__.
522
+ causal = is_causal and query_length != 1
523
+
524
+ # Decide whether to use SWA or not by layer index.
525
+ if use_sliding_windows and self.layer_idx >= self.config.max_window_layers:
526
+ use_sliding_windows = False
527
+
528
+ # Contains at least one padding token in the sequence
529
+ if attention_mask is not None:
530
+ batch_size = query_states.shape[0]
531
+ query_states, key_states, value_states, indices_q, cu_seq_lens, max_seq_lens = self._upad_input(
532
+ query_states, key_states, value_states, attention_mask, query_length
533
+ )
534
+
535
+ cu_seqlens_q, cu_seqlens_k = cu_seq_lens
536
+ max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
537
+
538
+ if not use_sliding_windows:
539
+ attn_output_unpad = flash_attn_varlen_func(
540
+ query_states,
541
+ key_states,
542
+ value_states,
543
+ cu_seqlens_q=cu_seqlens_q,
544
+ cu_seqlens_k=cu_seqlens_k,
545
+ max_seqlen_q=max_seqlen_in_batch_q,
546
+ max_seqlen_k=max_seqlen_in_batch_k,
547
+ dropout_p=dropout,
548
+ softmax_scale=softmax_scale,
549
+ causal=causal,
550
+ )
551
+ else:
552
+ attn_output_unpad = flash_attn_varlen_func(
553
+ query_states,
554
+ key_states,
555
+ value_states,
556
+ cu_seqlens_q=cu_seqlens_q,
557
+ cu_seqlens_k=cu_seqlens_k,
558
+ max_seqlen_q=max_seqlen_in_batch_q,
559
+ max_seqlen_k=max_seqlen_in_batch_k,
560
+ dropout_p=dropout,
561
+ softmax_scale=softmax_scale,
562
+ causal=causal,
563
+ window_size=(self.config.sliding_window, self.config.sliding_window),
564
+ )
565
+
566
+ attn_output = pad_input(attn_output_unpad, indices_q, batch_size, query_length)
567
+ else:
568
+ if not use_sliding_windows:
569
+ attn_output = flash_attn_func(
570
+ query_states,
571
+ key_states,
572
+ value_states,
573
+ dropout,
574
+ softmax_scale=softmax_scale,
575
+ causal=causal,
576
+ )
577
+ else:
578
+ attn_output = flash_attn_func(
579
+ query_states,
580
+ key_states,
581
+ value_states,
582
+ dropout,
583
+ softmax_scale=softmax_scale,
584
+ causal=causal,
585
+ window_size=(self.config.sliding_window, self.config.sliding_window),
586
+ )
587
+
588
+ return attn_output
589
+
590
+ # Copied from transformers.models.mistral.modeling_mistral.MistralFlashAttention2._upad_input
591
+ def _upad_input(self, query_layer, key_layer, value_layer, attention_mask, query_length):
592
+ batch_size, kv_seq_len, num_heads, head_dim = key_layer.shape
593
+
594
+ # On the first iteration we need to properly re-create the padding mask
595
+ # by slicing it on the proper place
596
+ if kv_seq_len != attention_mask.shape[-1]:
597
+ attention_mask_num_tokens = attention_mask.shape[-1]
598
+ attention_mask = attention_mask[:, attention_mask_num_tokens - kv_seq_len :]
599
+
600
+ indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(attention_mask)
601
+
602
+ key_layer = index_first_axis(key_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k)
603
+ value_layer = index_first_axis(value_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k)
604
+
605
+ if query_length == kv_seq_len:
606
+ query_layer = index_first_axis(
607
+ query_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k
608
+ )
609
+ cu_seqlens_q = cu_seqlens_k
610
+ max_seqlen_in_batch_q = max_seqlen_in_batch_k
611
+ indices_q = indices_k
612
+ elif query_length == 1:
613
+ max_seqlen_in_batch_q = 1
614
+ cu_seqlens_q = torch.arange(
615
+ batch_size + 1, dtype=torch.int32, device=query_layer.device
616
+ ) # There is a memcpy here, that is very bad.
617
+ indices_q = cu_seqlens_q[:-1]
618
+ query_layer = query_layer.squeeze(1)
619
+ else:
620
+ # The -q_len: slice assumes left padding.
621
+ attention_mask = attention_mask[:, -query_length:]
622
+ query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(query_layer, attention_mask)
623
+
624
+ return (
625
+ query_layer,
626
+ key_layer,
627
+ value_layer,
628
+ indices_q,
629
+ (cu_seqlens_q, cu_seqlens_k),
630
+ (max_seqlen_in_batch_q, max_seqlen_in_batch_k),
631
+ )
632
+
633
+
634
+ # Copied from transformers.models.mistral.modeling_mistral.MistralSdpaAttention with Mistral->Qwen2
635
+ class Qwen2SdpaAttention(Qwen2Attention):
636
+ """
637
+ Qwen2 attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
638
+ `Qwen2Attention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to
639
+ SDPA API.
640
+ """
641
+
642
+ # Adapted from Qwen2Attention.forward
643
+ def forward(
644
+ self,
645
+ hidden_states: torch.Tensor,
646
+ attention_mask: Optional[torch.Tensor] = None,
647
+ position_ids: Optional[torch.LongTensor] = None,
648
+ past_key_value: Optional[Cache] = None,
649
+ output_attentions: bool = False,
650
+ use_cache: bool = False,
651
+ is_causal: bool = True,
652
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
653
+ if output_attentions:
654
+ # TODO: Improve this warning with e.g. `model.config.attn_implementation = "manual"` once this is implemented.
655
+ logger.warning_once(
656
+ "Qwen2Model is using Qwen2SdpaAttention, but `torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. Falling back to the manual attention implementation, "
657
+ 'but specifying the manual implementation will be required from Transformers version v5.0.0 onwards. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.'
658
+ )
659
+ return super().forward(
660
+ hidden_states=hidden_states,
661
+ attention_mask=attention_mask,
662
+ position_ids=position_ids,
663
+ past_key_value=past_key_value,
664
+ output_attentions=output_attentions,
665
+ use_cache=use_cache,
666
+ is_causal=is_causal
667
+ )
668
+
669
+ bsz, q_len, _ = hidden_states.size()
670
+
671
+ query_states = self.q_proj(hidden_states)
672
+ key_states = self.k_proj(hidden_states)
673
+ value_states = self.v_proj(hidden_states)
674
+
675
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
676
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
677
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
678
+
679
+ kv_seq_len = key_states.shape[-2]
680
+ if past_key_value is not None:
681
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
682
+ cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
683
+
684
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
685
+
686
+ if past_key_value is not None:
687
+ cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
688
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
689
+
690
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
691
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
692
+
693
+ if attention_mask is not None:
694
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
695
+ raise ValueError(
696
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
697
+ )
698
+
699
+ # SDPA with memory-efficient backend is currently (torch==2.1.2) bugged with non-contiguous inputs with custom attn_mask,
700
+ # Reference: https://github.com/pytorch/pytorch/issues/112577.
701
+ if query_states.device.type == "cuda" and attention_mask is not None:
702
+ query_states = query_states.contiguous()
703
+ key_states = key_states.contiguous()
704
+ value_states = value_states.contiguous()
705
+
706
+ attn_output = torch.nn.functional.scaled_dot_product_attention(
707
+ query_states,
708
+ key_states,
709
+ value_states,
710
+ attn_mask=attention_mask,
711
+ dropout_p=self.attention_dropout if self.training else 0.0,
712
+ # The q_len > 1 is necessary to match with AttentionMaskConverter.to_causal_4d that does not create a causal mask in case q_len == 1.
713
+ is_causal=is_causal and attention_mask is None and q_len > 1,
714
+ )
715
+
716
+ attn_output = attn_output.transpose(1, 2).contiguous()
717
+ attn_output = attn_output.view(bsz, q_len, self.hidden_size)
718
+
719
+ attn_output = self.o_proj(attn_output)
720
+
721
+ return attn_output, None, past_key_value
722
+
723
+
724
+ QWEN2_ATTENTION_CLASSES = {
725
+ "eager": Qwen2Attention,
726
+ "flash_attention_2": Qwen2FlashAttention2,
727
+ "sdpa": Qwen2SdpaAttention,
728
+ }
729
+
730
+
731
+ class Qwen2DecoderLayer(nn.Module):
732
+ def __init__(self, config: Qwen2Config, layer_idx: int):
733
+ super().__init__()
734
+ self.hidden_size = config.hidden_size
735
+
736
+ if config.use_sliding_window and config._attn_implementation != "flash_attention_2":
737
+ logger.warning_once(
738
+ f"Sliding Window Attention is enabled but not implemented for `{config._attn_implementation}`; "
739
+ "unexpected results may be encountered."
740
+ )
741
+ self.self_attn = QWEN2_ATTENTION_CLASSES[config._attn_implementation](config, layer_idx)
742
+
743
+ self.mlp = Qwen2MLP(config)
744
+ self.input_layernorm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
745
+ self.post_attention_layernorm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
746
+
747
+ def forward(
748
+ self,
749
+ hidden_states: torch.Tensor,
750
+ attention_mask: Optional[torch.Tensor] = None,
751
+ position_ids: Optional[torch.LongTensor] = None,
752
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
753
+ output_attentions: Optional[bool] = False,
754
+ use_cache: Optional[bool] = False,
755
+ is_causal: Optional[bool] = True,
756
+ **kwargs,
757
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
758
+ if "padding_mask" in kwargs:
759
+ warnings.warn(
760
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. "
761
+ "Please make sure use `attention_mask` instead.`"
762
+ )
763
+ """
764
+ Args:
765
+ hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
766
+ attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
767
+ `(batch, sequence_length)` where padding elements are indicated by 0.
768
+ output_attentions (`bool`, *optional*):
769
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under
770
+ returned tensors for more detail.
771
+ use_cache (`bool`, *optional*):
772
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
773
+ (see `past_key_values`).
774
+ past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
775
+ """
776
+
777
+ residual = hidden_states
778
+
779
+ hidden_states = self.input_layernorm(hidden_states)
780
+
781
+ # Self Attention
782
+ hidden_states, self_attn_weights, present_key_value = self.self_attn(
783
+ hidden_states=hidden_states,
784
+ attention_mask=attention_mask,
785
+ position_ids=position_ids,
786
+ past_key_value=past_key_value,
787
+ output_attentions=output_attentions,
788
+ use_cache=use_cache,
789
+ is_causal=is_causal,
790
+ )
791
+ hidden_states = residual + hidden_states
792
+
793
+ # Fully Connected
794
+ residual = hidden_states
795
+ hidden_states = self.post_attention_layernorm(hidden_states)
796
+ hidden_states = self.mlp(hidden_states)
797
+ hidden_states = residual + hidden_states
798
+
799
+ outputs = (hidden_states,)
800
+
801
+ if output_attentions:
802
+ outputs += (self_attn_weights,)
803
+
804
+ if use_cache:
805
+ outputs += (present_key_value,)
806
+
807
+ return outputs
808
+
809
+
810
+ QWEN2_START_DOCSTRING = r"""
811
+ This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
812
+ library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
813
+ etc.)
814
+
815
+ This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
816
+ Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
817
+ and behavior.
818
+
819
+ Parameters:
820
+ config ([`Qwen2Config`]):
821
+ Model configuration class with all the parameters of the model. Initializing with a config file does not
822
+ load the weights associated with the model, only the configuration. Check out the
823
+ [`~PreTrainedModel.from_pretrained`] method to load the model weights.
824
+ """
825
+
826
+
827
+ @add_start_docstrings(
828
+ "The bare Qwen2 Model outputting raw hidden-states without any specific head on top.",
829
+ QWEN2_START_DOCSTRING,
830
+ )
831
+ class Qwen2PreTrainedModel(PreTrainedModel):
832
+ config_class = Qwen2Config
833
+ base_model_prefix = "model"
834
+ supports_gradient_checkpointing = True
835
+ _no_split_modules = ["Qwen2DecoderLayer"]
836
+ _skip_keys_device_placement = "past_key_values"
837
+ _supports_flash_attn_2 = True
838
+ _supports_sdpa = True
839
+ _supports_cache_class = True
840
+
841
+ def _init_weights(self, module):
842
+ std = self.config.initializer_range
843
+ if isinstance(module, nn.Linear):
844
+ module.weight.data.normal_(mean=0.0, std=std)
845
+ if module.bias is not None:
846
+ module.bias.data.zero_()
847
+ elif isinstance(module, nn.Embedding):
848
+ module.weight.data.normal_(mean=0.0, std=std)
849
+ if module.padding_idx is not None:
850
+ module.weight.data[module.padding_idx].zero_()
851
+
852
+
853
+ QWEN2_INPUTS_DOCSTRING = r"""
854
+ Args:
855
+ input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
856
+ Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
857
+ it.
858
+
859
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
860
+ [`PreTrainedTokenizer.__call__`] for details.
861
+
862
+ [What are input IDs?](../glossary#input-ids)
863
+ attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
864
+ Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
865
+
866
+ - 1 for tokens that are **not masked**,
867
+ - 0 for tokens that are **masked**.
868
+
869
+ [What are attention masks?](../glossary#attention-mask)
870
+
871
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
872
+ [`PreTrainedTokenizer.__call__`] for details.
873
+
874
+ If `past_key_values` is used, optionally only the last `decoder_input_ids` have to be input (see
875
+ `past_key_values`).
876
+
877
+ If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
878
+ and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
879
+ information on the default strategy.
880
+
881
+ - 1 indicates the head is **not masked**,
882
+ - 0 indicates the head is **masked**.
883
+ position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
884
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
885
+ config.n_positions - 1]`.
886
+
887
+ [What are position IDs?](../glossary#position-ids)
888
+ past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
889
+ Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
890
+ blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
891
+ returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.
892
+
893
+ Two formats are allowed:
894
+ - a [`~cache_utils.Cache`] instance;
895
+ - Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
896
+ shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
897
+ cache format.
898
+
899
+ The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
900
+ legacy cache format will be returned.
901
+
902
+ If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
903
+ have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
904
+ of shape `(batch_size, sequence_length)`.
905
+ inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
906
+ Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
907
+ is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
908
+ model's internal embedding lookup matrix.
909
+ use_cache (`bool`, *optional*):
910
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
911
+ `past_key_values`).
912
+ output_attentions (`bool`, *optional*):
913
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
914
+ tensors for more detail.
915
+ output_hidden_states (`bool`, *optional*):
916
+ Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
917
+ more detail.
918
+ return_dict (`bool`, *optional*):
919
+ Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
920
+ """
921
+
922
+
923
+ @add_start_docstrings(
924
+ "The bare Qwen2 Model outputting raw hidden-states without any specific head on top.",
925
+ QWEN2_START_DOCSTRING,
926
+ )
927
+ class Qwen2Model(Qwen2PreTrainedModel):
928
+ """
929
+ Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`Qwen2DecoderLayer`]
930
+
931
+ Args:
932
+ config: Qwen2Config
933
+ """
934
+
935
+ def __init__(self, config: Qwen2Config):
936
+ super().__init__(config)
937
+ self.padding_idx = config.pad_token_id
938
+ self.vocab_size = config.vocab_size
939
+
940
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
941
+ self.layers = nn.ModuleList(
942
+ [Qwen2DecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
943
+ )
944
+ self._attn_implementation = config._attn_implementation
945
+ self.norm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
946
+
947
+ self.gradient_checkpointing = False
948
+ # Initialize weights and apply final processing
949
+ self.post_init()
950
+
951
+ def get_input_embeddings(self):
952
+ return self.embed_tokens
953
+
954
+ def set_input_embeddings(self, value):
955
+ self.embed_tokens = value
956
+
957
+ @add_start_docstrings_to_model_forward(QWEN2_INPUTS_DOCSTRING)
958
+ def forward(
959
+ self,
960
+ input_ids: torch.LongTensor = None,
961
+ attention_mask: Optional[torch.Tensor] = None,
962
+ position_ids: Optional[torch.LongTensor] = None,
963
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
964
+ inputs_embeds: Optional[torch.FloatTensor] = None,
965
+ use_cache: Optional[bool] = None,
966
+ output_attentions: Optional[bool] = None,
967
+ output_hidden_states: Optional[bool] = None,
968
+ return_dict: Optional[bool] = None,
969
+ labels: Optional[torch.LongTensor] = None,
970
+ is_causal: Optional[bool] = False,
971
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
972
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
973
+ output_hidden_states = (
974
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
975
+ )
976
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
977
+
978
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
979
+
980
+ # retrieve input_ids and inputs_embeds
981
+ if input_ids is not None and inputs_embeds is not None:
982
+ raise ValueError("You cannot specify both decoder_input_ids and decoder_inputs_embeds at the same time")
983
+ elif input_ids is not None:
984
+ batch_size, seq_length = input_ids.shape
985
+ elif inputs_embeds is not None:
986
+ batch_size, seq_length, _ = inputs_embeds.shape
987
+ else:
988
+ raise ValueError("You have to specify either decoder_input_ids or decoder_inputs_embeds")
989
+
990
+ if self.gradient_checkpointing and self.training:
991
+ if use_cache:
992
+ logger.warning_once(
993
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
994
+ )
995
+ use_cache = False
996
+
997
+ past_key_values_length = 0
998
+
999
+ if use_cache:
1000
+ use_legacy_cache = not isinstance(past_key_values, Cache)
1001
+ if use_legacy_cache:
1002
+ past_key_values = DynamicCache.from_legacy_cache(past_key_values)
1003
+ past_key_values_length = past_key_values.get_usable_length(seq_length)
1004
+
1005
+ if position_ids is None:
1006
+ device = input_ids.device if input_ids is not None else inputs_embeds.device
1007
+ position_ids = torch.arange(
1008
+ past_key_values_length, seq_length + past_key_values_length, dtype=torch.long, device=device
1009
+ )
1010
+ position_ids = position_ids.unsqueeze(0).view(-1, seq_length)
1011
+ else:
1012
+ position_ids = position_ids.view(-1, seq_length).long()
1013
+
1014
+ if inputs_embeds is None:
1015
+ inputs_embeds = self.embed_tokens(input_ids)
1016
+
1017
+ if attention_mask is not None and self._attn_implementation == "flash_attention_2" and use_cache:
1018
+ is_padding_right = attention_mask[:, -1].sum().item() != batch_size
1019
+ if is_padding_right:
1020
+ raise ValueError(
1021
+ "You are attempting to perform batched generation with padding_side='right'"
1022
+ " this may lead to unexpected behaviour for Flash Attention version of Qwen2. Make sure to "
1023
+ " call `tokenizer.padding_side = 'left'` before tokenizing the input. "
1024
+ )
1025
+
1026
+ if self._attn_implementation == "flash_attention_2":
1027
+ # 2d mask is passed through the layers
1028
+ attention_mask = attention_mask if (attention_mask is not None and 0 in attention_mask) else None
1029
+ elif self._attn_implementation == "sdpa" and not output_attentions:
1030
+ # output_attentions=True can not be supported when using SDPA, and we fall back on
1031
+ # the manual implementation that requires a 4D causal mask in all cases.
1032
+ if is_causal:
1033
+ attention_mask = _prepare_4d_causal_attention_mask_for_sdpa(
1034
+ attention_mask,
1035
+ (batch_size, seq_length),
1036
+ inputs_embeds,
1037
+ past_key_values_length,
1038
+ )
1039
+ else:
1040
+ attention_mask = _prepare_4d_attention_mask_for_sdpa(
1041
+ attention_mask, inputs_embeds.dtype
1042
+ )
1043
+ else:
1044
+ # 4d mask is passed through the layers
1045
+ if is_causal:
1046
+ # Causal mask with -3.3895e+38 where no attention should be
1047
+ attention_mask = _prepare_4d_causal_attention_mask(
1048
+ attention_mask,
1049
+ (batch_size, seq_length),
1050
+ inputs_embeds,
1051
+ past_key_values_length,
1052
+ sliding_window=self.config.sliding_window,
1053
+ )
1054
+ else:
1055
+ # Shape: batch_size, 1, query_length, key_value_length
1056
+ attention_mask = _prepare_4d_attention_mask(
1057
+ attention_mask, inputs_embeds.dtype
1058
+ )
1059
+
1060
+ hidden_states = inputs_embeds
1061
+
1062
+ # decoder layers
1063
+ all_hidden_states = () if output_hidden_states else None
1064
+ all_self_attns = () if output_attentions else None
1065
+ next_decoder_cache = None
1066
+
1067
+ for decoder_layer in self.layers:
1068
+ if output_hidden_states:
1069
+ all_hidden_states += (hidden_states,)
1070
+
1071
+ if self.gradient_checkpointing and self.training:
1072
+ layer_outputs = self._gradient_checkpointing_func(
1073
+ decoder_layer.__call__,
1074
+ hidden_states,
1075
+ attention_mask,
1076
+ position_ids,
1077
+ past_key_values,
1078
+ output_attentions,
1079
+ use_cache,
1080
+ is_causal,
1081
+ )
1082
+ else:
1083
+ layer_outputs = decoder_layer(
1084
+ hidden_states,
1085
+ attention_mask=attention_mask,
1086
+ position_ids=position_ids,
1087
+ past_key_value=past_key_values,
1088
+ output_attentions=output_attentions,
1089
+ use_cache=use_cache,
1090
+ is_causal=is_causal,
1091
+ )
1092
+
1093
+ hidden_states = layer_outputs[0]
1094
+
1095
+ if use_cache:
1096
+ next_decoder_cache = layer_outputs[2 if output_attentions else 1]
1097
+
1098
+ if output_attentions:
1099
+ all_self_attns += (layer_outputs[1],)
1100
+
1101
+ hidden_states = self.norm(hidden_states)
1102
+
1103
+ # add hidden states from the last decoder layer
1104
+ if output_hidden_states:
1105
+ all_hidden_states += (hidden_states,)
1106
+
1107
+ next_cache = None
1108
+ if use_cache:
1109
+ next_cache = next_decoder_cache.to_legacy_cache() if use_legacy_cache else next_decoder_cache
1110
+
1111
+ if not return_dict:
1112
+ return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
1113
+ return BaseModelOutputWithPast(
1114
+ last_hidden_state=hidden_states,
1115
+ past_key_values=next_cache,
1116
+ hidden_states=all_hidden_states,
1117
+ attentions=all_self_attns,
1118
+ )
1119
+
1120
+
1121
+ class Qwen2ForCausalLM(Qwen2PreTrainedModel):
1122
+ _tied_weights_keys = ["lm_head.weight"]
1123
+
1124
+ def __init__(self, config):
1125
+ super().__init__(config)
1126
+ self.model = Qwen2Model(config)
1127
+ self.vocab_size = config.vocab_size
1128
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
1129
+
1130
+ # Initialize weights and apply final processing
1131
+ self.post_init()
1132
+
1133
+ def get_input_embeddings(self):
1134
+ return self.model.embed_tokens
1135
+
1136
+ def set_input_embeddings(self, value):
1137
+ self.model.embed_tokens = value
1138
+
1139
+ def get_output_embeddings(self):
1140
+ return self.lm_head
1141
+
1142
+ def set_output_embeddings(self, new_embeddings):
1143
+ self.lm_head = new_embeddings
1144
+
1145
+ def set_decoder(self, decoder):
1146
+ self.model = decoder
1147
+
1148
+ def get_decoder(self):
1149
+ return self.model
1150
+
1151
+ @add_start_docstrings_to_model_forward(QWEN2_INPUTS_DOCSTRING)
1152
+ @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
1153
+ def forward(
1154
+ self,
1155
+ input_ids: torch.LongTensor = None,
1156
+ attention_mask: Optional[torch.Tensor] = None,
1157
+ position_ids: Optional[torch.LongTensor] = None,
1158
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1159
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1160
+ labels: Optional[torch.LongTensor] = None,
1161
+ use_cache: Optional[bool] = None,
1162
+ output_attentions: Optional[bool] = None,
1163
+ output_hidden_states: Optional[bool] = None,
1164
+ return_dict: Optional[bool] = None,
1165
+ is_causal: Optional[bool] = False,
1166
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
1167
+ r"""
1168
+ Args:
1169
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
1170
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
1171
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
1172
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
1173
+
1174
+ Returns:
1175
+
1176
+ Example:
1177
+
1178
+ ```python
1179
+ >>> from transformers import AutoTokenizer, Qwen2ForCausalLM
1180
+
1181
+ >>> model = Qwen2ForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)
1182
+ >>> tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)
1183
+
1184
+ >>> prompt = "Hey, are you conscious? Can you talk to me?"
1185
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
1186
+
1187
+ >>> # Generate
1188
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
1189
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
1190
+ "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
1191
+ ```"""
1192
+
1193
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1194
+ output_hidden_states = (
1195
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1196
+ )
1197
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1198
+
1199
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
1200
+ outputs = self.model(
1201
+ input_ids=input_ids,
1202
+ attention_mask=attention_mask,
1203
+ position_ids=position_ids,
1204
+ past_key_values=past_key_values,
1205
+ inputs_embeds=inputs_embeds,
1206
+ use_cache=use_cache,
1207
+ output_attentions=output_attentions,
1208
+ output_hidden_states=output_hidden_states,
1209
+ return_dict=return_dict,
1210
+ is_causal=is_causal,
1211
+ )
1212
+
1213
+ hidden_states = outputs[0]
1214
+ logits = self.lm_head(hidden_states)
1215
+ logits = logits.float()
1216
+
1217
+ loss = None
1218
+ if labels is not None:
1219
+ # Shift so that tokens < n predict n
1220
+ shift_logits = logits[..., :-1, :].contiguous()
1221
+ shift_labels = labels[..., 1:].contiguous()
1222
+ # Flatten the tokens
1223
+ loss_fct = CrossEntropyLoss()
1224
+ shift_logits = shift_logits.view(-1, self.config.vocab_size)
1225
+ shift_labels = shift_labels.view(-1)
1226
+ # Enable model parallelism
1227
+ shift_labels = shift_labels.to(shift_logits.device)
1228
+ loss = loss_fct(shift_logits, shift_labels)
1229
+
1230
+ if not return_dict:
1231
+ output = (logits,) + outputs[1:]
1232
+ return (loss,) + output if loss is not None else output
1233
+
1234
+ return CausalLMOutputWithPast(
1235
+ loss=loss,
1236
+ logits=logits,
1237
+ past_key_values=outputs.past_key_values,
1238
+ hidden_states=outputs.hidden_states,
1239
+ attentions=outputs.attentions,
1240
+ )
1241
+
1242
+ def prepare_inputs_for_generation(
1243
+ self, input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, **kwargs
1244
+ ):
1245
+ # Omit tokens covered by past_key_values
1246
+ if past_key_values is not None:
1247
+ if isinstance(past_key_values, Cache):
1248
+ cache_length = past_key_values.get_seq_length()
1249
+ past_length = past_key_values.seen_tokens
1250
+ max_cache_length = past_key_values.get_max_length()
1251
+ else:
1252
+ cache_length = past_length = past_key_values[0][0].shape[2]
1253
+ max_cache_length = None
1254
+
1255
+ # Keep only the unprocessed tokens:
1256
+ # 1 - If the length of the attention_mask exceeds the length of input_ids, then we are in a setting where
1257
+ # some of the inputs are exclusively passed as part of the cache (e.g. when passing input_embeds as
1258
+ # input)
1259
+ if attention_mask is not None and attention_mask.shape[1] > input_ids.shape[1]:
1260
+ input_ids = input_ids[:, -(attention_mask.shape[1] - past_length) :]
1261
+ # 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard
1262
+ # input_ids based on the past_length.
1263
+ elif past_length < input_ids.shape[1]:
1264
+ input_ids = input_ids[:, past_length:]
1265
+ # 3 - Otherwise (past_length >= input_ids.shape[1]), let's assume input_ids only has unprocessed tokens.
1266
+
1267
+ # If we are about to go beyond the maximum cache length, we need to crop the input attention mask.
1268
+ if (
1269
+ max_cache_length is not None
1270
+ and attention_mask is not None
1271
+ and cache_length + input_ids.shape[1] > max_cache_length
1272
+ ):
1273
+ attention_mask = attention_mask[:, -max_cache_length:]
1274
+
1275
+ position_ids = kwargs.get("position_ids", None)
1276
+ if attention_mask is not None and position_ids is None:
1277
+ # create position_ids on the fly for batch generation
1278
+ position_ids = attention_mask.long().cumsum(-1) - 1
1279
+ position_ids.masked_fill_(attention_mask == 0, 1)
1280
+ if past_key_values:
1281
+ position_ids = position_ids[:, -input_ids.shape[1] :]
1282
+
1283
+ # if `inputs_embeds` are passed, we only want to use them in the 1st generation step
1284
+ if inputs_embeds is not None and past_key_values is None:
1285
+ model_inputs = {"inputs_embeds": inputs_embeds}
1286
+ else:
1287
+ model_inputs = {"input_ids": input_ids}
1288
+
1289
+ model_inputs.update(
1290
+ {
1291
+ "position_ids": position_ids,
1292
+ "past_key_values": past_key_values,
1293
+ "use_cache": kwargs.get("use_cache"),
1294
+ "attention_mask": attention_mask,
1295
+ }
1296
+ )
1297
+ return model_inputs
1298
+
1299
+ @staticmethod
1300
+ def _reorder_cache(past_key_values, beam_idx):
1301
+ reordered_past = ()
1302
+ for layer_past in past_key_values:
1303
+ reordered_past += (
1304
+ tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
1305
+ )
1306
+ return reordered_past
1307
+
1308
+
1309
+ @add_start_docstrings(
1310
+ """
1311
+ The Qwen2 Model transformer with a sequence classification head on top (linear layer).
1312
+
1313
+ [`Qwen2ForSequenceClassification`] uses the last token in order to do the classification, as other causal models
1314
+ (e.g. GPT-2) do.
1315
+
1316
+ Since it does classification on the last token, it requires to know the position of the last token. If a
1317
+ `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
1318
+ no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
1319
+ padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
1320
+ each row of the batch).
1321
+ """,
1322
+ QWEN2_START_DOCSTRING,
1323
+ )
1324
+ class Qwen2ForSequenceClassification(Qwen2PreTrainedModel):
1325
+ def __init__(self, config):
1326
+ super().__init__(config)
1327
+ self.num_labels = config.num_labels
1328
+ self.model = Qwen2Model(config)
1329
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
1330
+
1331
+ # Initialize weights and apply final processing
1332
+ self.post_init()
1333
+
1334
+ def get_input_embeddings(self):
1335
+ return self.model.embed_tokens
1336
+
1337
+ def set_input_embeddings(self, value):
1338
+ self.model.embed_tokens = value
1339
+
1340
+ @add_start_docstrings_to_model_forward(QWEN2_INPUTS_DOCSTRING)
1341
+ def forward(
1342
+ self,
1343
+ input_ids: torch.LongTensor = None,
1344
+ attention_mask: Optional[torch.Tensor] = None,
1345
+ position_ids: Optional[torch.LongTensor] = None,
1346
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1347
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1348
+ labels: Optional[torch.LongTensor] = None,
1349
+ use_cache: Optional[bool] = None,
1350
+ output_attentions: Optional[bool] = None,
1351
+ output_hidden_states: Optional[bool] = None,
1352
+ return_dict: Optional[bool] = None,
1353
+ is_causal: Optional[bool] = True,
1354
+ ) -> Union[Tuple, SequenceClassifierOutputWithPast]:
1355
+ r"""
1356
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1357
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1358
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1359
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1360
+ """
1361
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1362
+
1363
+ transformer_outputs = self.model(
1364
+ input_ids,
1365
+ attention_mask=attention_mask,
1366
+ position_ids=position_ids,
1367
+ past_key_values=past_key_values,
1368
+ inputs_embeds=inputs_embeds,
1369
+ use_cache=use_cache,
1370
+ output_attentions=output_attentions,
1371
+ output_hidden_states=output_hidden_states,
1372
+ return_dict=return_dict,
1373
+ is_causal=is_causal,
1374
+ )
1375
+ hidden_states = transformer_outputs[0]
1376
+ logits = self.score(hidden_states)
1377
+
1378
+ if input_ids is not None:
1379
+ batch_size = input_ids.shape[0]
1380
+ else:
1381
+ batch_size = inputs_embeds.shape[0]
1382
+
1383
+ if self.config.pad_token_id is None and batch_size != 1:
1384
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
1385
+ if self.config.pad_token_id is None:
1386
+ sequence_lengths = -1
1387
+ else:
1388
+ if input_ids is not None:
1389
+ # if no pad token found, use modulo instead of reverse indexing for ONNX compatibility
1390
+ sequence_lengths = torch.eq(input_ids, self.config.pad_token_id).int().argmax(-1) - 1
1391
+ sequence_lengths = sequence_lengths % input_ids.shape[-1]
1392
+ sequence_lengths = sequence_lengths.to(logits.device)
1393
+ else:
1394
+ sequence_lengths = -1
1395
+
1396
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
1397
+
1398
+ loss = None
1399
+ if labels is not None:
1400
+ labels = labels.to(logits.device)
1401
+ if self.config.problem_type is None:
1402
+ if self.num_labels == 1:
1403
+ self.config.problem_type = "regression"
1404
+ elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
1405
+ self.config.problem_type = "single_label_classification"
1406
+ else:
1407
+ self.config.problem_type = "multi_label_classification"
1408
+
1409
+ if self.config.problem_type == "regression":
1410
+ loss_fct = MSELoss()
1411
+ if self.num_labels == 1:
1412
+ loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
1413
+ else:
1414
+ loss = loss_fct(pooled_logits, labels)
1415
+ elif self.config.problem_type == "single_label_classification":
1416
+ loss_fct = CrossEntropyLoss()
1417
+ loss = loss_fct(pooled_logits.view(-1, self.num_labels), labels.view(-1))
1418
+ elif self.config.problem_type == "multi_label_classification":
1419
+ loss_fct = BCEWithLogitsLoss()
1420
+ loss = loss_fct(pooled_logits, labels)
1421
+ if not return_dict:
1422
+ output = (pooled_logits,) + transformer_outputs[1:]
1423
+ return ((loss,) + output) if loss is not None else output
1424
+
1425
+ return SequenceClassifierOutputWithPast(
1426
+ loss=loss,
1427
+ logits=pooled_logits,
1428
+ past_key_values=transformer_outputs.past_key_values,
1429
+ hidden_states=transformer_outputs.hidden_states,
1430
+ attentions=transformer_outputs.attentions,
1431
+ )
1432
+
1433
+
1434
+ ####################################################################################################################
1435
+ ####################################################################################################################
1436
+ ####################################################################################################################
1437
+ ####################################################################################################################
1438
+ ### codes for jasper
1439
+ ####################################################################################################################
1440
+ from transformers.models.qwen2_vl import Qwen2VLConfig, Qwen2VLForConditionalGeneration
1441
+ from transformers import PretrainedConfig
1442
+
1443
+ class ColStellaVLConfig(PretrainedConfig):
1444
+ model_type = "colstella_vl"
1445
+ __module__ = "transformers_modules.qwenstella_base.modeling_colqwenstella"
1446
+
1447
+ def __init__(
1448
+ self,
1449
+ # vector_dropout_p: float = 0.2,
1450
+ # num_img_tokens: int = 300,
1451
+ img_start_token_id: int = 151644,
1452
+ img_start_token: str = "<|im_start|>",
1453
+ img_token_id: int = 151646,
1454
+ img_token: str = "<|image_pad|>",
1455
+ img_end_token_id: int = 151645,
1456
+ img_end_token: str = "<|im_end|>",
1457
+ text_config=None,
1458
+ vision_config=None,
1459
+ **kwargs
1460
+ ):
1461
+ super().__init__(**kwargs)
1462
+ # if vector_dim not in (12288, 1024, 512, 256):
1463
+ # raise ValueError("vector_dim must be 12288, 1024, 512, 256")
1464
+ # self.vector_dim = vector_dim
1465
+ # self.vector_dropout_p = vector_dropout_p
1466
+
1467
+ # self.num_img_tokens = num_img_tokens
1468
+
1469
+ self.img_start_token_id = img_start_token_id
1470
+ self.img_start_token = img_start_token
1471
+
1472
+ self.img_token_id = img_token_id
1473
+ self.img_token = img_token
1474
+
1475
+ self.img_end_token_id = img_end_token_id
1476
+ self.img_end_token = img_end_token
1477
+
1478
+ if text_config is None:
1479
+ text_config = {}
1480
+ logger.info("`text_config` is `None`. Initializing the `Qwen2Config` with default values.")
1481
+
1482
+ if vision_config is None:
1483
+ vision_config = {}
1484
+ logger.info("`vision_config` is `None`. initializing the `Qwen2VLConfig` with default values.")
1485
+
1486
+ self.text_config = Qwen2Config(**text_config)
1487
+ self.vision_config = Qwen2VLConfig(**vision_config)
1488
+
1489
+ @classmethod
1490
+ def from_text_vision_configs(cls, text_config: Qwen2Config, vision_config: Qwen2VLConfig, **kwargs):
1491
+ r"""
1492
+ Instantiate a [`SiglipConfig`] (or a derived class) from siglip text model configuration and siglip vision
1493
+ model configuration.
1494
+ Returns:
1495
+ [`SiglipConfig`]: An instance of a configuration object
1496
+ """
1497
+
1498
+ return cls(text_config=text_config.to_dict(), vision_config=vision_config.to_dict(), **kwargs)
1499
+
1500
+
1501
+
1502
+ # ColStellaVLConfig.from_pretrained("/home/nane.saroyan99/colpali/models/stella_transformer")
1503
+
1504
+
1505
+ class ColQwenStella(PreTrainedModel):
1506
+ config_class = ColStellaVLConfig
1507
+ _supports_sdpa = True
1508
+ _supports_flash_attn_2 = True
1509
+ base_model_prefix = "model"
1510
+ supports_gradient_checkpointing = True
1511
+
1512
+ def __init__(self, config: ColStellaVLConfig):
1513
+
1514
+ super().__init__(config)
1515
+ self.model = Qwen2Model(config.text_config)
1516
+ self.config = config
1517
+ # if not config.is_text_encoder:
1518
+ # self.vision_model = Qwen2VLForConditionalGeneration.from_pretrained("Qwen/Qwen2-VL-2B-Instruct").visual
1519
+ # qwen =
1520
+ # print(config.vision_config)
1521
+ self.vision_model = Qwen2VLForConditionalGeneration(config.vision_config).visual
1522
+ # self.get_rope_index = self.vision_model.get_rope_index
1523
+ # self.vision_model = self.vision_model.visual
1524
+ if torch.cuda.is_available():
1525
+ print("deleting all else")
1526
+ torch.cuda.empty_cache()
1527
+ # self.adaptive_avg_pool2d = torch.nn.AdaptiveAvgPool2d(
1528
+ # (self.config.num_img_tokens, config.text_config.hidden_size)
1529
+ # )
1530
+
1531
+ # self.vector_linear_12288 = nn.Linear(config.text_config.hidden_size, 12288, bias=True)
1532
+ self.vector_linear_1024 = nn.Linear(config.text_config.hidden_size, 1024, bias=True)
1533
+ # self.vector_linear_512 = nn.Linear(config.text_config.hidden_size, 512, bias=True)
1534
+ # self.vector_linear_256 = nn.Linear(config.text_config.hidden_size, 256, bias=True)
1535
+ # Initialize weights and apply final processing
1536
+ # self.model.resize_token_embeddings(151647)
1537
+ self.post_init()
1538
+ # self.model.resize_token_embeddings(151647)
1539
+
1540
+ # def get_input_embeddings(self):
1541
+ # return self.model.embed_tokens
1542
+
1543
+ # def set_input_embeddings(self, value):
1544
+ # self.model.embed_tokens = value
1545
+
1546
+ def inner_forward(
1547
+ self,
1548
+ input_ids: torch.LongTensor = None,
1549
+ attention_mask: Optional[torch.Tensor] = None,
1550
+ position_ids: Optional[torch.LongTensor] = None,
1551
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1552
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1553
+ use_cache: Optional[bool] = None,
1554
+ output_attentions: Optional[bool] = None,
1555
+ output_hidden_states: Optional[bool] = None,
1556
+ return_dict: Optional[bool] = None,
1557
+ pixel_values: Optional[torch.Tensor] = None,
1558
+ image_grid_thw: Optional[torch.LongTensor] = None,
1559
+ ) -> torch.Tensor:
1560
+
1561
+ if inputs_embeds is None:
1562
+ inputs_embeds = self.model.embed_tokens(input_ids)
1563
+ if pixel_values is not None:
1564
+ pixel_values = pixel_values.type(self.vision_model.get_dtype())
1565
+ image_embeds = self.vision_model(pixel_values, grid_thw=image_grid_thw)
1566
+ image_mask = (input_ids == self.config.img_token_id).unsqueeze(-1).expand_as(inputs_embeds)
1567
+ image_embeds = image_embeds.to(inputs_embeds.device, inputs_embeds.dtype)
1568
+ inputs_embeds = inputs_embeds.masked_scatter(image_mask, image_embeds)
1569
+
1570
+
1571
+ if attention_mask is not None:
1572
+ attention_mask = attention_mask.to(inputs_embeds.device)
1573
+
1574
+ outputs = self.model(
1575
+ input_ids=None,
1576
+ position_ids=position_ids,
1577
+ attention_mask=attention_mask,
1578
+ past_key_values=past_key_values,
1579
+ inputs_embeds=inputs_embeds,
1580
+ use_cache=use_cache,
1581
+ output_attentions=output_attentions,
1582
+ output_hidden_states=output_hidden_states,
1583
+ return_dict=return_dict,
1584
+ )
1585
+
1586
+ hidden_states = outputs[0]
1587
+ return hidden_states
1588
+
1589
+
1590
+
1591
+ def forward(self,
1592
+ # input_ids: torch.LongTensor = None,
1593
+ # attention_mask: Optional[torch.Tensor] = None,
1594
+ # pixel_values: Optional[torch.Tensor] = None,
1595
+ *args,
1596
+ **kwargs) -> torch.Tensor:
1597
+ # Delete output_hidden_states from kwargs
1598
+ kwargs.pop("output_hidden_states", None)
1599
+
1600
+
1601
+ # The following code is a hack to make sure the scatter in DDP is done correctly when training on multiple GPUs
1602
+ if "pixel_values" in kwargs:
1603
+ # compute pixel_values offsets
1604
+ offsets = kwargs["image_grid_thw"][:, 1] * kwargs["image_grid_thw"][:, 2]
1605
+ kwargs["pixel_values"] = torch.cat(
1606
+ [pv[:o] for pv, o in zip(kwargs["pixel_values"], offsets)],
1607
+ dim=0,
1608
+ )
1609
+ last_hidden_states = self.inner_forward(*args,
1610
+ **kwargs,
1611
+ use_cache=False,
1612
+ output_hidden_states=True) # (batch_size, sequence_length, hidden_size)
1613
+
1614
+ proj = self.vector_linear_1024(last_hidden_states) # (batch_size, sequence_length, dim)
1615
+
1616
+ # L2 normalization
1617
+ proj = proj / proj.norm(dim=-1, keepdim=True) # (batch_size, sequence_length, dim)
1618
+ proj = proj * kwargs["attention_mask"].unsqueeze(-1) # (batch_size, sequence_length, dim)
1619
+
1620
+ return proj
1621
+
1622
+ @property
1623
+ def patch_size(self) -> int:
1624
+ return self.vision_model.config.patch_size
1625
+
1626
+ @property
1627
+ def spatial_merge_size(self) -> int:
1628
+ return self.vision_model.config.spatial_merge_size
1629
+
1630
+
1631
+ # from models.qwenstella_base.modeling_colqwenstella import ColQwenStella, ColStellaVLConfig
1632
+
1633
+ # ColStellaVLConfig.__module__ = "transformers_modules.qwenstella_base.modeling_colqwenstella"
1634
+
1635
+ # AutoConfig.register("colstella_vl", ColStellaVLConfig)
1636
+ # AutoModel.register(ColStellaVLConfig, ColQwenStella)
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": "Qwen2VLProcessor",
22
+ "resample": 3,
23
+ "rescale_factor": 0.00392156862745098,
24
+ "size": {
25
+ "max_pixels": 12845056,
26
+ "min_pixels": 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:091aa7594dc2fcfbfa06b9e3c22a5f0562ac14f30375c13af7309407a0e67b8a
3
+ size 11420371
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