Safetensors
English
Chinese
custom_code
YuanLiuuuuuu commited on
Commit
ab3e620
1 Parent(s): 5873a12

Add files using upload-large-folder tool

Browse files
README.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: []
3
+ library_name: transformers
4
+ tags:
5
+ - mergekit
6
+ - merge
7
+
8
+ ---
9
+ # POINTS-1-5-Qwen-2-5-7B-Chat
10
+
11
+ This is a merge of pre-trained language models created using [mergekit](https://github.com/cg123/mergekit).
12
+
13
+ ## Merge Details
14
+ ### Merge Method
15
+
16
+ This model was merged using the [linear](https://arxiv.org/abs/2203.05482) merge method.
17
+
18
+ ### Models Merged
19
+
20
+ The following models were included in the merge:
21
+ * /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241130e2-sft-pointsv15-hf/
22
+ * /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241127e3-sft-pointsv15-hf/
23
+ * /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241129e2-sft-pointsv15-hf/
24
+ * /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241130e3-sft-pointsv15-hf/
25
+
26
+ ### Configuration
27
+
28
+ The following YAML configuration was used to produce this model:
29
+
30
+ ```yaml
31
+ models:
32
+ # - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241123e2-sft-hf/
33
+ # parameters:
34
+ # weight: 1.0
35
+ # - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241124e2-sft-hf/
36
+ # parameters:
37
+ # weight: 1.0
38
+ # - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241125e1-sft-hf/
39
+ # parameters:
40
+ # weight: 1.0
41
+ # - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241125e3-sft-hf/
42
+ # parameters:
43
+ # weight: 1.0
44
+ # - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241127e1-sft-hf/
45
+ # parameters:
46
+ # weight: 1.0
47
+ # - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241127e2-sft-hf/
48
+ # parameters:
49
+ # weight: 1.0
50
+ - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241127e3-sft-pointsv15-hf/
51
+ parameters:
52
+ weight: 1.0
53
+ - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241129e2-sft-pointsv15-hf/
54
+ parameters:
55
+ weight: 1.0
56
+ - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241130e2-sft-pointsv15-hf/
57
+ parameters:
58
+ weight: 1.0
59
+ - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241130e3-sft-pointsv15-hf/
60
+ parameters:
61
+ weight: 1.0
62
+ merge_method: linear
63
+ parameters:
64
+ normalize: true
65
+ dtype: bfloat16
66
+
67
+ ```
config.json ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_commit_hash": null,
3
+ "architectures": [
4
+ "POINTSV15ChatModel"
5
+ ],
6
+ "auto_map": {
7
+ "AutoConfig": "configuration_pointsv15_chat.POINTSV15ChatConfig",
8
+ "AutoModelForCausalLM": "modeling_pointsv15_chat.POINTSV15ChatModel"
9
+ },
10
+ "llm_config": {
11
+ "_attn_implementation_autoset": true,
12
+ "_name_or_path": "",
13
+ "add_cross_attention": false,
14
+ "architectures": null,
15
+ "auto_map": {
16
+ "AutoConfig": "configuration_llama.CustomLlamaConfig",
17
+ "AutoModelForCausalLM": "modeling_llama.CustomLlamaForCausalLM"
18
+ },
19
+ "bad_words_ids": null,
20
+ "begin_suppress_tokens": null,
21
+ "bos_token_id": 0,
22
+ "chunk_size_feed_forward": 0,
23
+ "cross_attention_hidden_size": null,
24
+ "decoder_start_token_id": null,
25
+ "diversity_penalty": 0.0,
26
+ "do_sample": false,
27
+ "early_stopping": false,
28
+ "encoder_no_repeat_ngram_size": 0,
29
+ "eos_token_id": [
30
+ 2,
31
+ 3
32
+ ],
33
+ "exponential_decay_length_penalty": null,
34
+ "ffn_hidden_size": 18944,
35
+ "finetuning_task": null,
36
+ "forced_bos_token_id": null,
37
+ "forced_eos_token_id": null,
38
+ "hidden_act": "swiglu",
39
+ "hidden_size": 3584,
40
+ "id2label": {
41
+ "0": "LABEL_0",
42
+ "1": "LABEL_1"
43
+ },
44
+ "initializer_range": 0.02,
45
+ "is_decoder": false,
46
+ "is_encoder_decoder": false,
47
+ "label2id": {
48
+ "LABEL_0": 0,
49
+ "LABEL_1": 1
50
+ },
51
+ "layernorm_epsilon": 1e-05,
52
+ "length_penalty": 1.0,
53
+ "max_length": 20,
54
+ "max_position_embeddings": 16384,
55
+ "min_length": 0,
56
+ "mlp_fc1_bias": false,
57
+ "mlp_fc2_bias": false,
58
+ "model_type": "custom_llama",
59
+ "no_repeat_ngram_size": 0,
60
+ "norm_type": "rms_norm",
61
+ "num_attention_heads": 28,
62
+ "num_beam_groups": 1,
63
+ "num_beams": 1,
64
+ "num_hidden_layers": 28,
65
+ "num_kv_heads": 4,
66
+ "num_layers": 28,
67
+ "num_return_sequences": 1,
68
+ "out_proj_bias": false,
69
+ "output_attentions": false,
70
+ "output_hidden_states": false,
71
+ "output_scores": false,
72
+ "pad_token_id": null,
73
+ "prefix": null,
74
+ "problem_type": null,
75
+ "pruned_heads": {},
76
+ "qkv_proj_bias": true,
77
+ "remove_invalid_values": false,
78
+ "repetition_penalty": 1.0,
79
+ "return_dict": true,
80
+ "return_dict_in_generate": false,
81
+ "rotary_compress": 1.0,
82
+ "rotary_emb_base": 1000000.0,
83
+ "rotary_pct": 1.0,
84
+ "sep_token_id": null,
85
+ "share_kv_num_layers": 1,
86
+ "sliding_window_size": -1,
87
+ "sliding_window_type": null,
88
+ "suppress_tokens": null,
89
+ "task_specific_params": null,
90
+ "temperature": 1.0,
91
+ "tf_legacy_loss": false,
92
+ "tie_encoder_decoder": false,
93
+ "tie_word_embeddings": false,
94
+ "tokenizer_class": null,
95
+ "top_k": 50,
96
+ "top_p": 1.0,
97
+ "torch_dtype": null,
98
+ "torchscript": false,
99
+ "transformers_version": "4.46.3",
100
+ "typical_p": 1.0,
101
+ "use_bfloat16": false,
102
+ "use_cache": true,
103
+ "use_gqa": true,
104
+ "vocab_size": 152064
105
+ },
106
+ "torch_dtype": "bfloat16",
107
+ "transformers_version": null,
108
+ "vision_config": {
109
+ "_attn_implementation_autoset": false,
110
+ "_name_or_path": "",
111
+ "add_cross_attention": false,
112
+ "architectures": null,
113
+ "bad_words_ids": null,
114
+ "begin_suppress_tokens": null,
115
+ "bos_token_id": null,
116
+ "chunk_size_feed_forward": 0,
117
+ "cross_attention_hidden_size": null,
118
+ "decoder_start_token_id": null,
119
+ "depth": 32,
120
+ "diversity_penalty": 0.0,
121
+ "do_sample": false,
122
+ "early_stopping": false,
123
+ "embed_dim": 1280,
124
+ "encoder_no_repeat_ngram_size": 0,
125
+ "eos_token_id": null,
126
+ "exponential_decay_length_penalty": null,
127
+ "finetuning_task": null,
128
+ "forced_bos_token_id": null,
129
+ "forced_eos_token_id": null,
130
+ "hidden_act": "quick_gelu",
131
+ "hidden_size": 3584,
132
+ "id2label": {
133
+ "0": "LABEL_0",
134
+ "1": "LABEL_1"
135
+ },
136
+ "in_channels": 3,
137
+ "in_chans": 3,
138
+ "is_decoder": false,
139
+ "is_encoder_decoder": false,
140
+ "label2id": {
141
+ "LABEL_0": 0,
142
+ "LABEL_1": 1
143
+ },
144
+ "length_penalty": 1.0,
145
+ "max_length": 20,
146
+ "min_length": 0,
147
+ "mlp_ratio": 4,
148
+ "model_type": "qwen2_vl",
149
+ "no_repeat_ngram_size": 0,
150
+ "num_beam_groups": 1,
151
+ "num_beams": 1,
152
+ "num_heads": 16,
153
+ "num_return_sequences": 1,
154
+ "output_attentions": false,
155
+ "output_hidden_states": false,
156
+ "output_scores": false,
157
+ "pad_token_id": null,
158
+ "patch_size": 14,
159
+ "prefix": null,
160
+ "problem_type": null,
161
+ "pruned_heads": {},
162
+ "remove_invalid_values": false,
163
+ "repetition_penalty": 1.0,
164
+ "return_dict": true,
165
+ "return_dict_in_generate": false,
166
+ "sep_token_id": null,
167
+ "spatial_merge_size": 2,
168
+ "spatial_patch_size": 14,
169
+ "suppress_tokens": null,
170
+ "task_specific_params": null,
171
+ "temperature": 1.0,
172
+ "temporal_patch_size": 2,
173
+ "tf_legacy_loss": false,
174
+ "tie_encoder_decoder": false,
175
+ "tie_word_embeddings": true,
176
+ "tokenizer_class": null,
177
+ "top_k": 50,
178
+ "top_p": 1.0,
179
+ "torch_dtype": "bfloat16",
180
+ "torchscript": false,
181
+ "transformers_version": "4.46.3",
182
+ "typical_p": 1.0,
183
+ "use_bfloat16": false
184
+ }
185
+ }
configuration_llama.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Modify the original configuration_llama.py to
2
+ # be compatiable with our training framework.
3
+
4
+
5
+ from transformers.configuration_utils import PretrainedConfig
6
+ from transformers.utils import logging
7
+
8
+ logger = logging.get_logger(__name__)
9
+
10
+
11
+ class CustomLlamaConfig(PretrainedConfig):
12
+ """
13
+ Args:
14
+ vocab_size (`int`, *optional*, defaults to 50432):
15
+ Vocabulary size of the WeLMV3 model. Defines the number of
16
+ different tokens that can be represented by the
17
+ `inputs_ids` passed when calling [`WeLMV3Model`].
18
+ hidden_size (`int`, *optional*, defaults to 6144):
19
+ Dimension of the encoder layers and the pooler layer.
20
+ num_hidden_layers (`int`, *optional*, defaults to 44):
21
+ Number of hidden layers in the Transformer encoder.
22
+ num_attention_heads (`int`, *optional*, defaults to 64):
23
+ Number of attention heads for each attention layer in the
24
+ Transformer encoder.
25
+ num_kv_heads (`int`, *optional*, defaults to 4):
26
+ Number of GQA groups.
27
+ intermediate_size (`int`, *optional*, defaults to 24576):
28
+ Dimension of the "intermediate" (i.e., feed-forward) layer in the
29
+ Transformer encoder.
30
+ hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
31
+ The non-linear activation function (function or string) in the
32
+ encoder and pooler. If string, `"gelu"`,
33
+ `"relu"`, `"selu"` and `"gelu_new"` are supported.
34
+ rotary_pct (`float`, *optional*, defaults to 0.25):
35
+ percentage of hidden dimensions to allocate to rotary embeddings
36
+ rotary_emb_base (`int`, *optional*, defaults to 10000)
37
+ base for computing rotary embeddings frequency
38
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
39
+ The maximum sequence length that this model might ever be used
40
+ with. Typically set this to something large just in case
41
+ (e.g., 512 or 1024 or 2048).
42
+ initializer_range (`float`, *optional*, defaults to 1e-5):
43
+ The standard deviation of the truncated_normal_initializer for
44
+ initializing all weight matrices.
45
+ layer_norm_eps (`float`, *optional*, defaults to 1e-12):
46
+ The epsilon used by the layer normalization layers.
47
+ use_cache (`bool`, *optional*, defaults to `True`):
48
+ Whether or not the model should return the last key/values
49
+ attentions (not used by all models). Only relevant if
50
+ `config.is_decoder=True`.
51
+ """
52
+ model_type = "custom_llama"
53
+
54
+ def __init__(
55
+ self,
56
+ vocab_size=102400,
57
+ hidden_size=2560,
58
+ num_layers=32,
59
+ num_attention_heads=20,
60
+ num_kv_heads=4,
61
+ ffn_hidden_size=2560 * 4,
62
+ hidden_act="swiglu",
63
+ rotary_pct=1.0,
64
+ rotary_emb_base=10000,
65
+ rotary_compress=1.0,
66
+ max_position_embeddings=4096,
67
+ initializer_range=0.02,
68
+ layernorm_epsilon=1e-5,
69
+ use_cache=True,
70
+ bos_token_id=0,
71
+ eos_token_id=2,
72
+ rms_norm=None,
73
+ norm_type='layer_norm',
74
+ qkv_proj_bias=True,
75
+ out_proj_bias=True,
76
+ mlp_fc1_bias=True,
77
+ mlp_fc2_bias=True,
78
+ **kwargs,
79
+ ):
80
+ super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
81
+ self.vocab_size = vocab_size
82
+ self.max_position_embeddings = max_position_embeddings
83
+ self.hidden_size = hidden_size
84
+ self.num_layers = num_layers
85
+ self.num_attention_heads = num_attention_heads
86
+ self.num_kv_heads = num_kv_heads
87
+ self.ffn_hidden_size = ffn_hidden_size
88
+ self.hidden_act = hidden_act
89
+ self.rotary_pct = rotary_pct
90
+ self.rotary_emb_base = rotary_emb_base
91
+ self.rotary_compress = rotary_compress
92
+ self.initializer_range = initializer_range
93
+ self.layernorm_epsilon = layernorm_epsilon
94
+ self.use_cache = use_cache
95
+ if rms_norm is not None:
96
+ self.norm_type = 'rms_norm' if rms_norm else 'layer_norm'
97
+ else:
98
+ self.norm_type = norm_type
99
+ self.qkv_proj_bias = qkv_proj_bias
100
+ self.out_proj_bias = out_proj_bias
101
+ self.mlp_fc1_bias = mlp_fc1_bias
102
+ self.mlp_fc2_bias = mlp_fc2_bias
103
+ self.num_hidden_layers = num_layers
configuration_pointsv15_chat.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import copy
2
+ from typing import Any, Dict
3
+
4
+ from transformers import PretrainedConfig
5
+
6
+ try:
7
+ from transformers.models.qwen2_vl.configuration_qwen2_vl import Qwen2VLVisionConfig
8
+ except ImportError:
9
+ print('Please upgrade transformers to version 4.46.3 or higher')
10
+
11
+ from .configuration_llama import CustomLlamaConfig
12
+
13
+
14
+ class POINTSV15ChatConfig(PretrainedConfig):
15
+ model_type = "pointsv1.5_chat"
16
+ is_composition = True
17
+ """Configuration class for `POINTSV1.5`."""
18
+
19
+ def __init__(self,
20
+ **kwargs) -> None:
21
+ super().__init__(**kwargs)
22
+ vision_config = kwargs.pop("vision_config", None)
23
+ llm_config = kwargs.pop("llm_config", None)
24
+ if isinstance(vision_config, dict):
25
+ self.vision_config = Qwen2VLVisionConfig(**vision_config)
26
+ else:
27
+ self.vision_config = vision_config
28
+ if isinstance(llm_config, dict):
29
+ self.llm_config = CustomLlamaConfig(**llm_config)
30
+ else:
31
+ self.llm_config = llm_config
32
+
33
+ def to_dict(self) -> Dict[str, Any]:
34
+ output = copy.deepcopy(self.__dict__)
35
+ output["vision_config"] = self.vision_config.to_dict()
36
+ output["llm_config"] = self.llm_config.to_dict()
37
+ return output
generation_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "transformers_version": "4.46.3"
4
+ }
mergekit_config.yml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ models:
2
+ # - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241123e2-sft-hf/
3
+ # parameters:
4
+ # weight: 1.0
5
+ # - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241124e2-sft-hf/
6
+ # parameters:
7
+ # weight: 1.0
8
+ # - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241125e1-sft-hf/
9
+ # parameters:
10
+ # weight: 1.0
11
+ # - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241125e3-sft-hf/
12
+ # parameters:
13
+ # weight: 1.0
14
+ # - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241127e1-sft-hf/
15
+ # parameters:
16
+ # weight: 1.0
17
+ # - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241127e2-sft-hf/
18
+ # parameters:
19
+ # weight: 1.0
20
+ - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241127e3-sft-pointsv15-hf/
21
+ parameters:
22
+ weight: 1.0
23
+ - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241129e2-sft-pointsv15-hf/
24
+ parameters:
25
+ weight: 1.0
26
+ - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241130e2-sft-pointsv15-hf/
27
+ parameters:
28
+ weight: 1.0
29
+ - model: /mnt/cephfs/bensenliu/wfs/weights/mm/mmq-llava-20241130e3-sft-pointsv15-hf/
30
+ parameters:
31
+ weight: 1.0
32
+ merge_method: linear
33
+ parameters:
34
+ normalize: true
35
+ dtype: bfloat16
model-00001-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:641cdc6784233944a3f74da9763571cfe72055357844295c820671157d7a4fc5
3
+ size 4976697008
model-00002-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d7bf302712686e2d0021597965f44f00b6eaafd85af6c87b0ad6e79bf0621ea4
3
+ size 4855694728
model-00003-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e36a0ae119dd49cb23c01663c390bc8cd9bbb11e4b920141ffab0c12677760d9
3
+ size 4991492584
model-00004-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8cacb4c38bd350bf39e93259fd934b3d09e3acaed679ab65dea70b873879ff20
3
+ size 1848093520
model.safetensors.index.json ADDED
@@ -0,0 +1,659 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 16671902720
4
+ },
5
+ "weight_map": {
6
+ "llm.embed_out.weight": "model-00004-of-00004.safetensors",
7
+ "llm.lm.embed_in.weight": "model-00001-of-00004.safetensors",
8
+ "llm.lm.final_layer_norm.weight": "model-00003-of-00004.safetensors",
9
+ "llm.lm.layers.0.attention.dense.weight": "model-00001-of-00004.safetensors",
10
+ "llm.lm.layers.0.attention.key_value_dense.bias": "model-00001-of-00004.safetensors",
11
+ "llm.lm.layers.0.attention.key_value_dense.weight": "model-00001-of-00004.safetensors",
12
+ "llm.lm.layers.0.attention.query_dense.bias": "model-00001-of-00004.safetensors",
13
+ "llm.lm.layers.0.attention.query_dense.weight": "model-00001-of-00004.safetensors",
14
+ "llm.lm.layers.0.input_layernorm.weight": "model-00001-of-00004.safetensors",
15
+ "llm.lm.layers.0.mlp.dense_4h_to_h.weight": "model-00001-of-00004.safetensors",
16
+ "llm.lm.layers.0.mlp.dense_h_to_4h.weight": "model-00001-of-00004.safetensors",
17
+ "llm.lm.layers.0.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
18
+ "llm.lm.layers.1.attention.dense.weight": "model-00001-of-00004.safetensors",
19
+ "llm.lm.layers.1.attention.key_value_dense.bias": "model-00001-of-00004.safetensors",
20
+ "llm.lm.layers.1.attention.key_value_dense.weight": "model-00001-of-00004.safetensors",
21
+ "llm.lm.layers.1.attention.query_dense.bias": "model-00001-of-00004.safetensors",
22
+ "llm.lm.layers.1.attention.query_dense.weight": "model-00001-of-00004.safetensors",
23
+ "llm.lm.layers.1.input_layernorm.weight": "model-00001-of-00004.safetensors",
24
+ "llm.lm.layers.1.mlp.dense_4h_to_h.weight": "model-00001-of-00004.safetensors",
25
+ "llm.lm.layers.1.mlp.dense_h_to_4h.weight": "model-00001-of-00004.safetensors",
26
+ "llm.lm.layers.1.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
27
+ "llm.lm.layers.10.attention.dense.weight": "model-00002-of-00004.safetensors",
28
+ "llm.lm.layers.10.attention.key_value_dense.bias": "model-00002-of-00004.safetensors",
29
+ "llm.lm.layers.10.attention.key_value_dense.weight": "model-00002-of-00004.safetensors",
30
+ "llm.lm.layers.10.attention.query_dense.bias": "model-00002-of-00004.safetensors",
31
+ "llm.lm.layers.10.attention.query_dense.weight": "model-00002-of-00004.safetensors",
32
+ "llm.lm.layers.10.input_layernorm.weight": "model-00002-of-00004.safetensors",
33
+ "llm.lm.layers.10.mlp.dense_4h_to_h.weight": "model-00002-of-00004.safetensors",
34
+ "llm.lm.layers.10.mlp.dense_h_to_4h.weight": "model-00002-of-00004.safetensors",
35
+ "llm.lm.layers.10.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
36
+ "llm.lm.layers.11.attention.dense.weight": "model-00002-of-00004.safetensors",
37
+ "llm.lm.layers.11.attention.key_value_dense.bias": "model-00002-of-00004.safetensors",
38
+ "llm.lm.layers.11.attention.key_value_dense.weight": "model-00002-of-00004.safetensors",
39
+ "llm.lm.layers.11.attention.query_dense.bias": "model-00002-of-00004.safetensors",
40
+ "llm.lm.layers.11.attention.query_dense.weight": "model-00002-of-00004.safetensors",
41
+ "llm.lm.layers.11.input_layernorm.weight": "model-00002-of-00004.safetensors",
42
+ "llm.lm.layers.11.mlp.dense_4h_to_h.weight": "model-00002-of-00004.safetensors",
43
+ "llm.lm.layers.11.mlp.dense_h_to_4h.weight": "model-00002-of-00004.safetensors",
44
+ "llm.lm.layers.11.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
45
+ "llm.lm.layers.12.attention.dense.weight": "model-00002-of-00004.safetensors",
46
+ "llm.lm.layers.12.attention.key_value_dense.bias": "model-00002-of-00004.safetensors",
47
+ "llm.lm.layers.12.attention.key_value_dense.weight": "model-00002-of-00004.safetensors",
48
+ "llm.lm.layers.12.attention.query_dense.bias": "model-00002-of-00004.safetensors",
49
+ "llm.lm.layers.12.attention.query_dense.weight": "model-00002-of-00004.safetensors",
50
+ "llm.lm.layers.12.input_layernorm.weight": "model-00002-of-00004.safetensors",
51
+ "llm.lm.layers.12.mlp.dense_4h_to_h.weight": "model-00002-of-00004.safetensors",
52
+ "llm.lm.layers.12.mlp.dense_h_to_4h.weight": "model-00002-of-00004.safetensors",
53
+ "llm.lm.layers.12.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
54
+ "llm.lm.layers.13.attention.dense.weight": "model-00002-of-00004.safetensors",
55
+ "llm.lm.layers.13.attention.key_value_dense.bias": "model-00002-of-00004.safetensors",
56
+ "llm.lm.layers.13.attention.key_value_dense.weight": "model-00002-of-00004.safetensors",
57
+ "llm.lm.layers.13.attention.query_dense.bias": "model-00002-of-00004.safetensors",
58
+ "llm.lm.layers.13.attention.query_dense.weight": "model-00002-of-00004.safetensors",
59
+ "llm.lm.layers.13.input_layernorm.weight": "model-00002-of-00004.safetensors",
60
+ "llm.lm.layers.13.mlp.dense_4h_to_h.weight": "model-00002-of-00004.safetensors",
61
+ "llm.lm.layers.13.mlp.dense_h_to_4h.weight": "model-00002-of-00004.safetensors",
62
+ "llm.lm.layers.13.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
63
+ "llm.lm.layers.14.attention.dense.weight": "model-00002-of-00004.safetensors",
64
+ "llm.lm.layers.14.attention.key_value_dense.bias": "model-00002-of-00004.safetensors",
65
+ "llm.lm.layers.14.attention.key_value_dense.weight": "model-00002-of-00004.safetensors",
66
+ "llm.lm.layers.14.attention.query_dense.bias": "model-00002-of-00004.safetensors",
67
+ "llm.lm.layers.14.attention.query_dense.weight": "model-00002-of-00004.safetensors",
68
+ "llm.lm.layers.14.input_layernorm.weight": "model-00002-of-00004.safetensors",
69
+ "llm.lm.layers.14.mlp.dense_4h_to_h.weight": "model-00002-of-00004.safetensors",
70
+ "llm.lm.layers.14.mlp.dense_h_to_4h.weight": "model-00002-of-00004.safetensors",
71
+ "llm.lm.layers.14.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
72
+ "llm.lm.layers.15.attention.dense.weight": "model-00002-of-00004.safetensors",
73
+ "llm.lm.layers.15.attention.key_value_dense.bias": "model-00002-of-00004.safetensors",
74
+ "llm.lm.layers.15.attention.key_value_dense.weight": "model-00002-of-00004.safetensors",
75
+ "llm.lm.layers.15.attention.query_dense.bias": "model-00002-of-00004.safetensors",
76
+ "llm.lm.layers.15.attention.query_dense.weight": "model-00002-of-00004.safetensors",
77
+ "llm.lm.layers.15.input_layernorm.weight": "model-00002-of-00004.safetensors",
78
+ "llm.lm.layers.15.mlp.dense_4h_to_h.weight": "model-00002-of-00004.safetensors",
79
+ "llm.lm.layers.15.mlp.dense_h_to_4h.weight": "model-00002-of-00004.safetensors",
80
+ "llm.lm.layers.15.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
81
+ "llm.lm.layers.16.attention.dense.weight": "model-00002-of-00004.safetensors",
82
+ "llm.lm.layers.16.attention.key_value_dense.bias": "model-00002-of-00004.safetensors",
83
+ "llm.lm.layers.16.attention.key_value_dense.weight": "model-00002-of-00004.safetensors",
84
+ "llm.lm.layers.16.attention.query_dense.bias": "model-00002-of-00004.safetensors",
85
+ "llm.lm.layers.16.attention.query_dense.weight": "model-00002-of-00004.safetensors",
86
+ "llm.lm.layers.16.input_layernorm.weight": "model-00002-of-00004.safetensors",
87
+ "llm.lm.layers.16.mlp.dense_4h_to_h.weight": "model-00002-of-00004.safetensors",
88
+ "llm.lm.layers.16.mlp.dense_h_to_4h.weight": "model-00002-of-00004.safetensors",
89
+ "llm.lm.layers.16.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
90
+ "llm.lm.layers.17.attention.dense.weight": "model-00002-of-00004.safetensors",
91
+ "llm.lm.layers.17.attention.key_value_dense.bias": "model-00002-of-00004.safetensors",
92
+ "llm.lm.layers.17.attention.key_value_dense.weight": "model-00002-of-00004.safetensors",
93
+ "llm.lm.layers.17.attention.query_dense.bias": "model-00002-of-00004.safetensors",
94
+ "llm.lm.layers.17.attention.query_dense.weight": "model-00002-of-00004.safetensors",
95
+ "llm.lm.layers.17.input_layernorm.weight": "model-00002-of-00004.safetensors",
96
+ "llm.lm.layers.17.mlp.dense_4h_to_h.weight": "model-00002-of-00004.safetensors",
97
+ "llm.lm.layers.17.mlp.dense_h_to_4h.weight": "model-00002-of-00004.safetensors",
98
+ "llm.lm.layers.17.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
99
+ "llm.lm.layers.18.attention.dense.weight": "model-00002-of-00004.safetensors",
100
+ "llm.lm.layers.18.attention.key_value_dense.bias": "model-00002-of-00004.safetensors",
101
+ "llm.lm.layers.18.attention.key_value_dense.weight": "model-00002-of-00004.safetensors",
102
+ "llm.lm.layers.18.attention.query_dense.bias": "model-00002-of-00004.safetensors",
103
+ "llm.lm.layers.18.attention.query_dense.weight": "model-00002-of-00004.safetensors",
104
+ "llm.lm.layers.18.input_layernorm.weight": "model-00002-of-00004.safetensors",
105
+ "llm.lm.layers.18.mlp.dense_4h_to_h.weight": "model-00003-of-00004.safetensors",
106
+ "llm.lm.layers.18.mlp.dense_h_to_4h.weight": "model-00002-of-00004.safetensors",
107
+ "llm.lm.layers.18.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
108
+ "llm.lm.layers.19.attention.dense.weight": "model-00003-of-00004.safetensors",
109
+ "llm.lm.layers.19.attention.key_value_dense.bias": "model-00003-of-00004.safetensors",
110
+ "llm.lm.layers.19.attention.key_value_dense.weight": "model-00003-of-00004.safetensors",
111
+ "llm.lm.layers.19.attention.query_dense.bias": "model-00003-of-00004.safetensors",
112
+ "llm.lm.layers.19.attention.query_dense.weight": "model-00003-of-00004.safetensors",
113
+ "llm.lm.layers.19.input_layernorm.weight": "model-00003-of-00004.safetensors",
114
+ "llm.lm.layers.19.mlp.dense_4h_to_h.weight": "model-00003-of-00004.safetensors",
115
+ "llm.lm.layers.19.mlp.dense_h_to_4h.weight": "model-00003-of-00004.safetensors",
116
+ "llm.lm.layers.19.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
117
+ "llm.lm.layers.2.attention.dense.weight": "model-00001-of-00004.safetensors",
118
+ "llm.lm.layers.2.attention.key_value_dense.bias": "model-00001-of-00004.safetensors",
119
+ "llm.lm.layers.2.attention.key_value_dense.weight": "model-00001-of-00004.safetensors",
120
+ "llm.lm.layers.2.attention.query_dense.bias": "model-00001-of-00004.safetensors",
121
+ "llm.lm.layers.2.attention.query_dense.weight": "model-00001-of-00004.safetensors",
122
+ "llm.lm.layers.2.input_layernorm.weight": "model-00001-of-00004.safetensors",
123
+ "llm.lm.layers.2.mlp.dense_4h_to_h.weight": "model-00001-of-00004.safetensors",
124
+ "llm.lm.layers.2.mlp.dense_h_to_4h.weight": "model-00001-of-00004.safetensors",
125
+ "llm.lm.layers.2.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
126
+ "llm.lm.layers.20.attention.dense.weight": "model-00003-of-00004.safetensors",
127
+ "llm.lm.layers.20.attention.key_value_dense.bias": "model-00003-of-00004.safetensors",
128
+ "llm.lm.layers.20.attention.key_value_dense.weight": "model-00003-of-00004.safetensors",
129
+ "llm.lm.layers.20.attention.query_dense.bias": "model-00003-of-00004.safetensors",
130
+ "llm.lm.layers.20.attention.query_dense.weight": "model-00003-of-00004.safetensors",
131
+ "llm.lm.layers.20.input_layernorm.weight": "model-00003-of-00004.safetensors",
132
+ "llm.lm.layers.20.mlp.dense_4h_to_h.weight": "model-00003-of-00004.safetensors",
133
+ "llm.lm.layers.20.mlp.dense_h_to_4h.weight": "model-00003-of-00004.safetensors",
134
+ "llm.lm.layers.20.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
135
+ "llm.lm.layers.21.attention.dense.weight": "model-00003-of-00004.safetensors",
136
+ "llm.lm.layers.21.attention.key_value_dense.bias": "model-00003-of-00004.safetensors",
137
+ "llm.lm.layers.21.attention.key_value_dense.weight": "model-00003-of-00004.safetensors",
138
+ "llm.lm.layers.21.attention.query_dense.bias": "model-00003-of-00004.safetensors",
139
+ "llm.lm.layers.21.attention.query_dense.weight": "model-00003-of-00004.safetensors",
140
+ "llm.lm.layers.21.input_layernorm.weight": "model-00003-of-00004.safetensors",
141
+ "llm.lm.layers.21.mlp.dense_4h_to_h.weight": "model-00003-of-00004.safetensors",
142
+ "llm.lm.layers.21.mlp.dense_h_to_4h.weight": "model-00003-of-00004.safetensors",
143
+ "llm.lm.layers.21.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
144
+ "llm.lm.layers.22.attention.dense.weight": "model-00003-of-00004.safetensors",
145
+ "llm.lm.layers.22.attention.key_value_dense.bias": "model-00003-of-00004.safetensors",
146
+ "llm.lm.layers.22.attention.key_value_dense.weight": "model-00003-of-00004.safetensors",
147
+ "llm.lm.layers.22.attention.query_dense.bias": "model-00003-of-00004.safetensors",
148
+ "llm.lm.layers.22.attention.query_dense.weight": "model-00003-of-00004.safetensors",
149
+ "llm.lm.layers.22.input_layernorm.weight": "model-00003-of-00004.safetensors",
150
+ "llm.lm.layers.22.mlp.dense_4h_to_h.weight": "model-00003-of-00004.safetensors",
151
+ "llm.lm.layers.22.mlp.dense_h_to_4h.weight": "model-00003-of-00004.safetensors",
152
+ "llm.lm.layers.22.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
153
+ "llm.lm.layers.23.attention.dense.weight": "model-00003-of-00004.safetensors",
154
+ "llm.lm.layers.23.attention.key_value_dense.bias": "model-00003-of-00004.safetensors",
155
+ "llm.lm.layers.23.attention.key_value_dense.weight": "model-00003-of-00004.safetensors",
156
+ "llm.lm.layers.23.attention.query_dense.bias": "model-00003-of-00004.safetensors",
157
+ "llm.lm.layers.23.attention.query_dense.weight": "model-00003-of-00004.safetensors",
158
+ "llm.lm.layers.23.input_layernorm.weight": "model-00003-of-00004.safetensors",
159
+ "llm.lm.layers.23.mlp.dense_4h_to_h.weight": "model-00003-of-00004.safetensors",
160
+ "llm.lm.layers.23.mlp.dense_h_to_4h.weight": "model-00003-of-00004.safetensors",
161
+ "llm.lm.layers.23.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
162
+ "llm.lm.layers.24.attention.dense.weight": "model-00003-of-00004.safetensors",
163
+ "llm.lm.layers.24.attention.key_value_dense.bias": "model-00003-of-00004.safetensors",
164
+ "llm.lm.layers.24.attention.key_value_dense.weight": "model-00003-of-00004.safetensors",
165
+ "llm.lm.layers.24.attention.query_dense.bias": "model-00003-of-00004.safetensors",
166
+ "llm.lm.layers.24.attention.query_dense.weight": "model-00003-of-00004.safetensors",
167
+ "llm.lm.layers.24.input_layernorm.weight": "model-00003-of-00004.safetensors",
168
+ "llm.lm.layers.24.mlp.dense_4h_to_h.weight": "model-00003-of-00004.safetensors",
169
+ "llm.lm.layers.24.mlp.dense_h_to_4h.weight": "model-00003-of-00004.safetensors",
170
+ "llm.lm.layers.24.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
171
+ "llm.lm.layers.25.attention.dense.weight": "model-00003-of-00004.safetensors",
172
+ "llm.lm.layers.25.attention.key_value_dense.bias": "model-00003-of-00004.safetensors",
173
+ "llm.lm.layers.25.attention.key_value_dense.weight": "model-00003-of-00004.safetensors",
174
+ "llm.lm.layers.25.attention.query_dense.bias": "model-00003-of-00004.safetensors",
175
+ "llm.lm.layers.25.attention.query_dense.weight": "model-00003-of-00004.safetensors",
176
+ "llm.lm.layers.25.input_layernorm.weight": "model-00003-of-00004.safetensors",
177
+ "llm.lm.layers.25.mlp.dense_4h_to_h.weight": "model-00003-of-00004.safetensors",
178
+ "llm.lm.layers.25.mlp.dense_h_to_4h.weight": "model-00003-of-00004.safetensors",
179
+ "llm.lm.layers.25.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
180
+ "llm.lm.layers.26.attention.dense.weight": "model-00003-of-00004.safetensors",
181
+ "llm.lm.layers.26.attention.key_value_dense.bias": "model-00003-of-00004.safetensors",
182
+ "llm.lm.layers.26.attention.key_value_dense.weight": "model-00003-of-00004.safetensors",
183
+ "llm.lm.layers.26.attention.query_dense.bias": "model-00003-of-00004.safetensors",
184
+ "llm.lm.layers.26.attention.query_dense.weight": "model-00003-of-00004.safetensors",
185
+ "llm.lm.layers.26.input_layernorm.weight": "model-00003-of-00004.safetensors",
186
+ "llm.lm.layers.26.mlp.dense_4h_to_h.weight": "model-00003-of-00004.safetensors",
187
+ "llm.lm.layers.26.mlp.dense_h_to_4h.weight": "model-00003-of-00004.safetensors",
188
+ "llm.lm.layers.26.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
189
+ "llm.lm.layers.27.attention.dense.weight": "model-00003-of-00004.safetensors",
190
+ "llm.lm.layers.27.attention.key_value_dense.bias": "model-00003-of-00004.safetensors",
191
+ "llm.lm.layers.27.attention.key_value_dense.weight": "model-00003-of-00004.safetensors",
192
+ "llm.lm.layers.27.attention.query_dense.bias": "model-00003-of-00004.safetensors",
193
+ "llm.lm.layers.27.attention.query_dense.weight": "model-00003-of-00004.safetensors",
194
+ "llm.lm.layers.27.input_layernorm.weight": "model-00003-of-00004.safetensors",
195
+ "llm.lm.layers.27.mlp.dense_4h_to_h.weight": "model-00003-of-00004.safetensors",
196
+ "llm.lm.layers.27.mlp.dense_h_to_4h.weight": "model-00003-of-00004.safetensors",
197
+ "llm.lm.layers.27.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
198
+ "llm.lm.layers.3.attention.dense.weight": "model-00001-of-00004.safetensors",
199
+ "llm.lm.layers.3.attention.key_value_dense.bias": "model-00001-of-00004.safetensors",
200
+ "llm.lm.layers.3.attention.key_value_dense.weight": "model-00001-of-00004.safetensors",
201
+ "llm.lm.layers.3.attention.query_dense.bias": "model-00001-of-00004.safetensors",
202
+ "llm.lm.layers.3.attention.query_dense.weight": "model-00001-of-00004.safetensors",
203
+ "llm.lm.layers.3.input_layernorm.weight": "model-00001-of-00004.safetensors",
204
+ "llm.lm.layers.3.mlp.dense_4h_to_h.weight": "model-00001-of-00004.safetensors",
205
+ "llm.lm.layers.3.mlp.dense_h_to_4h.weight": "model-00001-of-00004.safetensors",
206
+ "llm.lm.layers.3.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
207
+ "llm.lm.layers.4.attention.dense.weight": "model-00001-of-00004.safetensors",
208
+ "llm.lm.layers.4.attention.key_value_dense.bias": "model-00001-of-00004.safetensors",
209
+ "llm.lm.layers.4.attention.key_value_dense.weight": "model-00001-of-00004.safetensors",
210
+ "llm.lm.layers.4.attention.query_dense.bias": "model-00001-of-00004.safetensors",
211
+ "llm.lm.layers.4.attention.query_dense.weight": "model-00001-of-00004.safetensors",
212
+ "llm.lm.layers.4.input_layernorm.weight": "model-00001-of-00004.safetensors",
213
+ "llm.lm.layers.4.mlp.dense_4h_to_h.weight": "model-00001-of-00004.safetensors",
214
+ "llm.lm.layers.4.mlp.dense_h_to_4h.weight": "model-00001-of-00004.safetensors",
215
+ "llm.lm.layers.4.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
216
+ "llm.lm.layers.5.attention.dense.weight": "model-00001-of-00004.safetensors",
217
+ "llm.lm.layers.5.attention.key_value_dense.bias": "model-00001-of-00004.safetensors",
218
+ "llm.lm.layers.5.attention.key_value_dense.weight": "model-00001-of-00004.safetensors",
219
+ "llm.lm.layers.5.attention.query_dense.bias": "model-00001-of-00004.safetensors",
220
+ "llm.lm.layers.5.attention.query_dense.weight": "model-00001-of-00004.safetensors",
221
+ "llm.lm.layers.5.input_layernorm.weight": "model-00001-of-00004.safetensors",
222
+ "llm.lm.layers.5.mlp.dense_4h_to_h.weight": "model-00001-of-00004.safetensors",
223
+ "llm.lm.layers.5.mlp.dense_h_to_4h.weight": "model-00001-of-00004.safetensors",
224
+ "llm.lm.layers.5.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
225
+ "llm.lm.layers.6.attention.dense.weight": "model-00001-of-00004.safetensors",
226
+ "llm.lm.layers.6.attention.key_value_dense.bias": "model-00001-of-00004.safetensors",
227
+ "llm.lm.layers.6.attention.key_value_dense.weight": "model-00001-of-00004.safetensors",
228
+ "llm.lm.layers.6.attention.query_dense.bias": "model-00001-of-00004.safetensors",
229
+ "llm.lm.layers.6.attention.query_dense.weight": "model-00001-of-00004.safetensors",
230
+ "llm.lm.layers.6.input_layernorm.weight": "model-00001-of-00004.safetensors",
231
+ "llm.lm.layers.6.mlp.dense_4h_to_h.weight": "model-00001-of-00004.safetensors",
232
+ "llm.lm.layers.6.mlp.dense_h_to_4h.weight": "model-00001-of-00004.safetensors",
233
+ "llm.lm.layers.6.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
234
+ "llm.lm.layers.7.attention.dense.weight": "model-00001-of-00004.safetensors",
235
+ "llm.lm.layers.7.attention.key_value_dense.bias": "model-00001-of-00004.safetensors",
236
+ "llm.lm.layers.7.attention.key_value_dense.weight": "model-00001-of-00004.safetensors",
237
+ "llm.lm.layers.7.attention.query_dense.bias": "model-00001-of-00004.safetensors",
238
+ "llm.lm.layers.7.attention.query_dense.weight": "model-00001-of-00004.safetensors",
239
+ "llm.lm.layers.7.input_layernorm.weight": "model-00001-of-00004.safetensors",
240
+ "llm.lm.layers.7.mlp.dense_4h_to_h.weight": "model-00001-of-00004.safetensors",
241
+ "llm.lm.layers.7.mlp.dense_h_to_4h.weight": "model-00001-of-00004.safetensors",
242
+ "llm.lm.layers.7.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
243
+ "llm.lm.layers.8.attention.dense.weight": "model-00001-of-00004.safetensors",
244
+ "llm.lm.layers.8.attention.key_value_dense.bias": "model-00001-of-00004.safetensors",
245
+ "llm.lm.layers.8.attention.key_value_dense.weight": "model-00001-of-00004.safetensors",
246
+ "llm.lm.layers.8.attention.query_dense.bias": "model-00001-of-00004.safetensors",
247
+ "llm.lm.layers.8.attention.query_dense.weight": "model-00001-of-00004.safetensors",
248
+ "llm.lm.layers.8.input_layernorm.weight": "model-00001-of-00004.safetensors",
249
+ "llm.lm.layers.8.mlp.dense_4h_to_h.weight": "model-00002-of-00004.safetensors",
250
+ "llm.lm.layers.8.mlp.dense_h_to_4h.weight": "model-00002-of-00004.safetensors",
251
+ "llm.lm.layers.8.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
252
+ "llm.lm.layers.9.attention.dense.weight": "model-00002-of-00004.safetensors",
253
+ "llm.lm.layers.9.attention.key_value_dense.bias": "model-00002-of-00004.safetensors",
254
+ "llm.lm.layers.9.attention.key_value_dense.weight": "model-00002-of-00004.safetensors",
255
+ "llm.lm.layers.9.attention.query_dense.bias": "model-00002-of-00004.safetensors",
256
+ "llm.lm.layers.9.attention.query_dense.weight": "model-00002-of-00004.safetensors",
257
+ "llm.lm.layers.9.input_layernorm.weight": "model-00002-of-00004.safetensors",
258
+ "llm.lm.layers.9.mlp.dense_4h_to_h.weight": "model-00002-of-00004.safetensors",
259
+ "llm.lm.layers.9.mlp.dense_h_to_4h.weight": "model-00002-of-00004.safetensors",
260
+ "llm.lm.layers.9.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
261
+ "vision_encoder.blocks.0.attn.proj.bias": "model-00004-of-00004.safetensors",
262
+ "vision_encoder.blocks.0.attn.proj.weight": "model-00004-of-00004.safetensors",
263
+ "vision_encoder.blocks.0.attn.qkv.bias": "model-00004-of-00004.safetensors",
264
+ "vision_encoder.blocks.0.attn.qkv.weight": "model-00004-of-00004.safetensors",
265
+ "vision_encoder.blocks.0.mlp.fc1.bias": "model-00004-of-00004.safetensors",
266
+ "vision_encoder.blocks.0.mlp.fc1.weight": "model-00004-of-00004.safetensors",
267
+ "vision_encoder.blocks.0.mlp.fc2.bias": "model-00004-of-00004.safetensors",
268
+ "vision_encoder.blocks.0.mlp.fc2.weight": "model-00004-of-00004.safetensors",
269
+ "vision_encoder.blocks.0.norm1.bias": "model-00004-of-00004.safetensors",
270
+ "vision_encoder.blocks.0.norm1.weight": "model-00004-of-00004.safetensors",
271
+ "vision_encoder.blocks.0.norm2.bias": "model-00004-of-00004.safetensors",
272
+ "vision_encoder.blocks.0.norm2.weight": "model-00004-of-00004.safetensors",
273
+ "vision_encoder.blocks.1.attn.proj.bias": "model-00004-of-00004.safetensors",
274
+ "vision_encoder.blocks.1.attn.proj.weight": "model-00004-of-00004.safetensors",
275
+ "vision_encoder.blocks.1.attn.qkv.bias": "model-00004-of-00004.safetensors",
276
+ "vision_encoder.blocks.1.attn.qkv.weight": "model-00004-of-00004.safetensors",
277
+ "vision_encoder.blocks.1.mlp.fc1.bias": "model-00004-of-00004.safetensors",
278
+ "vision_encoder.blocks.1.mlp.fc1.weight": "model-00004-of-00004.safetensors",
279
+ "vision_encoder.blocks.1.mlp.fc2.bias": "model-00004-of-00004.safetensors",
280
+ "vision_encoder.blocks.1.mlp.fc2.weight": "model-00004-of-00004.safetensors",
281
+ "vision_encoder.blocks.1.norm1.bias": "model-00004-of-00004.safetensors",
282
+ "vision_encoder.blocks.1.norm1.weight": "model-00004-of-00004.safetensors",
283
+ "vision_encoder.blocks.1.norm2.bias": "model-00004-of-00004.safetensors",
284
+ "vision_encoder.blocks.1.norm2.weight": "model-00004-of-00004.safetensors",
285
+ "vision_encoder.blocks.10.attn.proj.bias": "model-00004-of-00004.safetensors",
286
+ "vision_encoder.blocks.10.attn.proj.weight": "model-00004-of-00004.safetensors",
287
+ "vision_encoder.blocks.10.attn.qkv.bias": "model-00004-of-00004.safetensors",
288
+ "vision_encoder.blocks.10.attn.qkv.weight": "model-00004-of-00004.safetensors",
289
+ "vision_encoder.blocks.10.mlp.fc1.bias": "model-00004-of-00004.safetensors",
290
+ "vision_encoder.blocks.10.mlp.fc1.weight": "model-00004-of-00004.safetensors",
291
+ "vision_encoder.blocks.10.mlp.fc2.bias": "model-00004-of-00004.safetensors",
292
+ "vision_encoder.blocks.10.mlp.fc2.weight": "model-00004-of-00004.safetensors",
293
+ "vision_encoder.blocks.10.norm1.bias": "model-00004-of-00004.safetensors",
294
+ "vision_encoder.blocks.10.norm1.weight": "model-00004-of-00004.safetensors",
295
+ "vision_encoder.blocks.10.norm2.bias": "model-00004-of-00004.safetensors",
296
+ "vision_encoder.blocks.10.norm2.weight": "model-00004-of-00004.safetensors",
297
+ "vision_encoder.blocks.11.attn.proj.bias": "model-00004-of-00004.safetensors",
298
+ "vision_encoder.blocks.11.attn.proj.weight": "model-00004-of-00004.safetensors",
299
+ "vision_encoder.blocks.11.attn.qkv.bias": "model-00004-of-00004.safetensors",
300
+ "vision_encoder.blocks.11.attn.qkv.weight": "model-00004-of-00004.safetensors",
301
+ "vision_encoder.blocks.11.mlp.fc1.bias": "model-00004-of-00004.safetensors",
302
+ "vision_encoder.blocks.11.mlp.fc1.weight": "model-00004-of-00004.safetensors",
303
+ "vision_encoder.blocks.11.mlp.fc2.bias": "model-00004-of-00004.safetensors",
304
+ "vision_encoder.blocks.11.mlp.fc2.weight": "model-00004-of-00004.safetensors",
305
+ "vision_encoder.blocks.11.norm1.bias": "model-00004-of-00004.safetensors",
306
+ "vision_encoder.blocks.11.norm1.weight": "model-00004-of-00004.safetensors",
307
+ "vision_encoder.blocks.11.norm2.bias": "model-00004-of-00004.safetensors",
308
+ "vision_encoder.blocks.11.norm2.weight": "model-00004-of-00004.safetensors",
309
+ "vision_encoder.blocks.12.attn.proj.bias": "model-00004-of-00004.safetensors",
310
+ "vision_encoder.blocks.12.attn.proj.weight": "model-00004-of-00004.safetensors",
311
+ "vision_encoder.blocks.12.attn.qkv.bias": "model-00004-of-00004.safetensors",
312
+ "vision_encoder.blocks.12.attn.qkv.weight": "model-00004-of-00004.safetensors",
313
+ "vision_encoder.blocks.12.mlp.fc1.bias": "model-00004-of-00004.safetensors",
314
+ "vision_encoder.blocks.12.mlp.fc1.weight": "model-00004-of-00004.safetensors",
315
+ "vision_encoder.blocks.12.mlp.fc2.bias": "model-00004-of-00004.safetensors",
316
+ "vision_encoder.blocks.12.mlp.fc2.weight": "model-00004-of-00004.safetensors",
317
+ "vision_encoder.blocks.12.norm1.bias": "model-00004-of-00004.safetensors",
318
+ "vision_encoder.blocks.12.norm1.weight": "model-00004-of-00004.safetensors",
319
+ "vision_encoder.blocks.12.norm2.bias": "model-00004-of-00004.safetensors",
320
+ "vision_encoder.blocks.12.norm2.weight": "model-00004-of-00004.safetensors",
321
+ "vision_encoder.blocks.13.attn.proj.bias": "model-00004-of-00004.safetensors",
322
+ "vision_encoder.blocks.13.attn.proj.weight": "model-00004-of-00004.safetensors",
323
+ "vision_encoder.blocks.13.attn.qkv.bias": "model-00004-of-00004.safetensors",
324
+ "vision_encoder.blocks.13.attn.qkv.weight": "model-00004-of-00004.safetensors",
325
+ "vision_encoder.blocks.13.mlp.fc1.bias": "model-00004-of-00004.safetensors",
326
+ "vision_encoder.blocks.13.mlp.fc1.weight": "model-00004-of-00004.safetensors",
327
+ "vision_encoder.blocks.13.mlp.fc2.bias": "model-00004-of-00004.safetensors",
328
+ "vision_encoder.blocks.13.mlp.fc2.weight": "model-00004-of-00004.safetensors",
329
+ "vision_encoder.blocks.13.norm1.bias": "model-00004-of-00004.safetensors",
330
+ "vision_encoder.blocks.13.norm1.weight": "model-00004-of-00004.safetensors",
331
+ "vision_encoder.blocks.13.norm2.bias": "model-00004-of-00004.safetensors",
332
+ "vision_encoder.blocks.13.norm2.weight": "model-00004-of-00004.safetensors",
333
+ "vision_encoder.blocks.14.attn.proj.bias": "model-00004-of-00004.safetensors",
334
+ "vision_encoder.blocks.14.attn.proj.weight": "model-00004-of-00004.safetensors",
335
+ "vision_encoder.blocks.14.attn.qkv.bias": "model-00004-of-00004.safetensors",
336
+ "vision_encoder.blocks.14.attn.qkv.weight": "model-00004-of-00004.safetensors",
337
+ "vision_encoder.blocks.14.mlp.fc1.bias": "model-00004-of-00004.safetensors",
338
+ "vision_encoder.blocks.14.mlp.fc1.weight": "model-00004-of-00004.safetensors",
339
+ "vision_encoder.blocks.14.mlp.fc2.bias": "model-00004-of-00004.safetensors",
340
+ "vision_encoder.blocks.14.mlp.fc2.weight": "model-00004-of-00004.safetensors",
341
+ "vision_encoder.blocks.14.norm1.bias": "model-00004-of-00004.safetensors",
342
+ "vision_encoder.blocks.14.norm1.weight": "model-00004-of-00004.safetensors",
343
+ "vision_encoder.blocks.14.norm2.bias": "model-00004-of-00004.safetensors",
344
+ "vision_encoder.blocks.14.norm2.weight": "model-00004-of-00004.safetensors",
345
+ "vision_encoder.blocks.15.attn.proj.bias": "model-00004-of-00004.safetensors",
346
+ "vision_encoder.blocks.15.attn.proj.weight": "model-00004-of-00004.safetensors",
347
+ "vision_encoder.blocks.15.attn.qkv.bias": "model-00004-of-00004.safetensors",
348
+ "vision_encoder.blocks.15.attn.qkv.weight": "model-00004-of-00004.safetensors",
349
+ "vision_encoder.blocks.15.mlp.fc1.bias": "model-00004-of-00004.safetensors",
350
+ "vision_encoder.blocks.15.mlp.fc1.weight": "model-00004-of-00004.safetensors",
351
+ "vision_encoder.blocks.15.mlp.fc2.bias": "model-00004-of-00004.safetensors",
352
+ "vision_encoder.blocks.15.mlp.fc2.weight": "model-00004-of-00004.safetensors",
353
+ "vision_encoder.blocks.15.norm1.bias": "model-00004-of-00004.safetensors",
354
+ "vision_encoder.blocks.15.norm1.weight": "model-00004-of-00004.safetensors",
355
+ "vision_encoder.blocks.15.norm2.bias": "model-00004-of-00004.safetensors",
356
+ "vision_encoder.blocks.15.norm2.weight": "model-00004-of-00004.safetensors",
357
+ "vision_encoder.blocks.16.attn.proj.bias": "model-00004-of-00004.safetensors",
358
+ "vision_encoder.blocks.16.attn.proj.weight": "model-00004-of-00004.safetensors",
359
+ "vision_encoder.blocks.16.attn.qkv.bias": "model-00004-of-00004.safetensors",
360
+ "vision_encoder.blocks.16.attn.qkv.weight": "model-00004-of-00004.safetensors",
361
+ "vision_encoder.blocks.16.mlp.fc1.bias": "model-00004-of-00004.safetensors",
362
+ "vision_encoder.blocks.16.mlp.fc1.weight": "model-00004-of-00004.safetensors",
363
+ "vision_encoder.blocks.16.mlp.fc2.bias": "model-00004-of-00004.safetensors",
364
+ "vision_encoder.blocks.16.mlp.fc2.weight": "model-00004-of-00004.safetensors",
365
+ "vision_encoder.blocks.16.norm1.bias": "model-00004-of-00004.safetensors",
366
+ "vision_encoder.blocks.16.norm1.weight": "model-00004-of-00004.safetensors",
367
+ "vision_encoder.blocks.16.norm2.bias": "model-00004-of-00004.safetensors",
368
+ "vision_encoder.blocks.16.norm2.weight": "model-00004-of-00004.safetensors",
369
+ "vision_encoder.blocks.17.attn.proj.bias": "model-00004-of-00004.safetensors",
370
+ "vision_encoder.blocks.17.attn.proj.weight": "model-00004-of-00004.safetensors",
371
+ "vision_encoder.blocks.17.attn.qkv.bias": "model-00004-of-00004.safetensors",
372
+ "vision_encoder.blocks.17.attn.qkv.weight": "model-00004-of-00004.safetensors",
373
+ "vision_encoder.blocks.17.mlp.fc1.bias": "model-00004-of-00004.safetensors",
374
+ "vision_encoder.blocks.17.mlp.fc1.weight": "model-00004-of-00004.safetensors",
375
+ "vision_encoder.blocks.17.mlp.fc2.bias": "model-00004-of-00004.safetensors",
376
+ "vision_encoder.blocks.17.mlp.fc2.weight": "model-00004-of-00004.safetensors",
377
+ "vision_encoder.blocks.17.norm1.bias": "model-00004-of-00004.safetensors",
378
+ "vision_encoder.blocks.17.norm1.weight": "model-00004-of-00004.safetensors",
379
+ "vision_encoder.blocks.17.norm2.bias": "model-00004-of-00004.safetensors",
380
+ "vision_encoder.blocks.17.norm2.weight": "model-00004-of-00004.safetensors",
381
+ "vision_encoder.blocks.18.attn.proj.bias": "model-00004-of-00004.safetensors",
382
+ "vision_encoder.blocks.18.attn.proj.weight": "model-00004-of-00004.safetensors",
383
+ "vision_encoder.blocks.18.attn.qkv.bias": "model-00004-of-00004.safetensors",
384
+ "vision_encoder.blocks.18.attn.qkv.weight": "model-00004-of-00004.safetensors",
385
+ "vision_encoder.blocks.18.mlp.fc1.bias": "model-00004-of-00004.safetensors",
386
+ "vision_encoder.blocks.18.mlp.fc1.weight": "model-00004-of-00004.safetensors",
387
+ "vision_encoder.blocks.18.mlp.fc2.bias": "model-00004-of-00004.safetensors",
388
+ "vision_encoder.blocks.18.mlp.fc2.weight": "model-00004-of-00004.safetensors",
389
+ "vision_encoder.blocks.18.norm1.bias": "model-00004-of-00004.safetensors",
390
+ "vision_encoder.blocks.18.norm1.weight": "model-00004-of-00004.safetensors",
391
+ "vision_encoder.blocks.18.norm2.bias": "model-00004-of-00004.safetensors",
392
+ "vision_encoder.blocks.18.norm2.weight": "model-00004-of-00004.safetensors",
393
+ "vision_encoder.blocks.19.attn.proj.bias": "model-00004-of-00004.safetensors",
394
+ "vision_encoder.blocks.19.attn.proj.weight": "model-00004-of-00004.safetensors",
395
+ "vision_encoder.blocks.19.attn.qkv.bias": "model-00004-of-00004.safetensors",
396
+ "vision_encoder.blocks.19.attn.qkv.weight": "model-00004-of-00004.safetensors",
397
+ "vision_encoder.blocks.19.mlp.fc1.bias": "model-00004-of-00004.safetensors",
398
+ "vision_encoder.blocks.19.mlp.fc1.weight": "model-00004-of-00004.safetensors",
399
+ "vision_encoder.blocks.19.mlp.fc2.bias": "model-00004-of-00004.safetensors",
400
+ "vision_encoder.blocks.19.mlp.fc2.weight": "model-00004-of-00004.safetensors",
401
+ "vision_encoder.blocks.19.norm1.bias": "model-00004-of-00004.safetensors",
402
+ "vision_encoder.blocks.19.norm1.weight": "model-00004-of-00004.safetensors",
403
+ "vision_encoder.blocks.19.norm2.bias": "model-00004-of-00004.safetensors",
404
+ "vision_encoder.blocks.19.norm2.weight": "model-00004-of-00004.safetensors",
405
+ "vision_encoder.blocks.2.attn.proj.bias": "model-00004-of-00004.safetensors",
406
+ "vision_encoder.blocks.2.attn.proj.weight": "model-00004-of-00004.safetensors",
407
+ "vision_encoder.blocks.2.attn.qkv.bias": "model-00004-of-00004.safetensors",
408
+ "vision_encoder.blocks.2.attn.qkv.weight": "model-00004-of-00004.safetensors",
409
+ "vision_encoder.blocks.2.mlp.fc1.bias": "model-00004-of-00004.safetensors",
410
+ "vision_encoder.blocks.2.mlp.fc1.weight": "model-00004-of-00004.safetensors",
411
+ "vision_encoder.blocks.2.mlp.fc2.bias": "model-00004-of-00004.safetensors",
412
+ "vision_encoder.blocks.2.mlp.fc2.weight": "model-00004-of-00004.safetensors",
413
+ "vision_encoder.blocks.2.norm1.bias": "model-00004-of-00004.safetensors",
414
+ "vision_encoder.blocks.2.norm1.weight": "model-00004-of-00004.safetensors",
415
+ "vision_encoder.blocks.2.norm2.bias": "model-00004-of-00004.safetensors",
416
+ "vision_encoder.blocks.2.norm2.weight": "model-00004-of-00004.safetensors",
417
+ "vision_encoder.blocks.20.attn.proj.bias": "model-00004-of-00004.safetensors",
418
+ "vision_encoder.blocks.20.attn.proj.weight": "model-00004-of-00004.safetensors",
419
+ "vision_encoder.blocks.20.attn.qkv.bias": "model-00004-of-00004.safetensors",
420
+ "vision_encoder.blocks.20.attn.qkv.weight": "model-00004-of-00004.safetensors",
421
+ "vision_encoder.blocks.20.mlp.fc1.bias": "model-00004-of-00004.safetensors",
422
+ "vision_encoder.blocks.20.mlp.fc1.weight": "model-00004-of-00004.safetensors",
423
+ "vision_encoder.blocks.20.mlp.fc2.bias": "model-00004-of-00004.safetensors",
424
+ "vision_encoder.blocks.20.mlp.fc2.weight": "model-00004-of-00004.safetensors",
425
+ "vision_encoder.blocks.20.norm1.bias": "model-00004-of-00004.safetensors",
426
+ "vision_encoder.blocks.20.norm1.weight": "model-00004-of-00004.safetensors",
427
+ "vision_encoder.blocks.20.norm2.bias": "model-00004-of-00004.safetensors",
428
+ "vision_encoder.blocks.20.norm2.weight": "model-00004-of-00004.safetensors",
429
+ "vision_encoder.blocks.21.attn.proj.bias": "model-00004-of-00004.safetensors",
430
+ "vision_encoder.blocks.21.attn.proj.weight": "model-00004-of-00004.safetensors",
431
+ "vision_encoder.blocks.21.attn.qkv.bias": "model-00004-of-00004.safetensors",
432
+ "vision_encoder.blocks.21.attn.qkv.weight": "model-00004-of-00004.safetensors",
433
+ "vision_encoder.blocks.21.mlp.fc1.bias": "model-00004-of-00004.safetensors",
434
+ "vision_encoder.blocks.21.mlp.fc1.weight": "model-00004-of-00004.safetensors",
435
+ "vision_encoder.blocks.21.mlp.fc2.bias": "model-00004-of-00004.safetensors",
436
+ "vision_encoder.blocks.21.mlp.fc2.weight": "model-00004-of-00004.safetensors",
437
+ "vision_encoder.blocks.21.norm1.bias": "model-00004-of-00004.safetensors",
438
+ "vision_encoder.blocks.21.norm1.weight": "model-00004-of-00004.safetensors",
439
+ "vision_encoder.blocks.21.norm2.bias": "model-00004-of-00004.safetensors",
440
+ "vision_encoder.blocks.21.norm2.weight": "model-00004-of-00004.safetensors",
441
+ "vision_encoder.blocks.22.attn.proj.bias": "model-00004-of-00004.safetensors",
442
+ "vision_encoder.blocks.22.attn.proj.weight": "model-00004-of-00004.safetensors",
443
+ "vision_encoder.blocks.22.attn.qkv.bias": "model-00004-of-00004.safetensors",
444
+ "vision_encoder.blocks.22.attn.qkv.weight": "model-00004-of-00004.safetensors",
445
+ "vision_encoder.blocks.22.mlp.fc1.bias": "model-00004-of-00004.safetensors",
446
+ "vision_encoder.blocks.22.mlp.fc1.weight": "model-00004-of-00004.safetensors",
447
+ "vision_encoder.blocks.22.mlp.fc2.bias": "model-00004-of-00004.safetensors",
448
+ "vision_encoder.blocks.22.mlp.fc2.weight": "model-00004-of-00004.safetensors",
449
+ "vision_encoder.blocks.22.norm1.bias": "model-00004-of-00004.safetensors",
450
+ "vision_encoder.blocks.22.norm1.weight": "model-00004-of-00004.safetensors",
451
+ "vision_encoder.blocks.22.norm2.bias": "model-00004-of-00004.safetensors",
452
+ "vision_encoder.blocks.22.norm2.weight": "model-00004-of-00004.safetensors",
453
+ "vision_encoder.blocks.23.attn.proj.bias": "model-00004-of-00004.safetensors",
454
+ "vision_encoder.blocks.23.attn.proj.weight": "model-00004-of-00004.safetensors",
455
+ "vision_encoder.blocks.23.attn.qkv.bias": "model-00004-of-00004.safetensors",
456
+ "vision_encoder.blocks.23.attn.qkv.weight": "model-00004-of-00004.safetensors",
457
+ "vision_encoder.blocks.23.mlp.fc1.bias": "model-00004-of-00004.safetensors",
458
+ "vision_encoder.blocks.23.mlp.fc1.weight": "model-00004-of-00004.safetensors",
459
+ "vision_encoder.blocks.23.mlp.fc2.bias": "model-00004-of-00004.safetensors",
460
+ "vision_encoder.blocks.23.mlp.fc2.weight": "model-00004-of-00004.safetensors",
461
+ "vision_encoder.blocks.23.norm1.bias": "model-00004-of-00004.safetensors",
462
+ "vision_encoder.blocks.23.norm1.weight": "model-00004-of-00004.safetensors",
463
+ "vision_encoder.blocks.23.norm2.bias": "model-00004-of-00004.safetensors",
464
+ "vision_encoder.blocks.23.norm2.weight": "model-00004-of-00004.safetensors",
465
+ "vision_encoder.blocks.24.attn.proj.bias": "model-00004-of-00004.safetensors",
466
+ "vision_encoder.blocks.24.attn.proj.weight": "model-00004-of-00004.safetensors",
467
+ "vision_encoder.blocks.24.attn.qkv.bias": "model-00004-of-00004.safetensors",
468
+ "vision_encoder.blocks.24.attn.qkv.weight": "model-00004-of-00004.safetensors",
469
+ "vision_encoder.blocks.24.mlp.fc1.bias": "model-00004-of-00004.safetensors",
470
+ "vision_encoder.blocks.24.mlp.fc1.weight": "model-00004-of-00004.safetensors",
471
+ "vision_encoder.blocks.24.mlp.fc2.bias": "model-00004-of-00004.safetensors",
472
+ "vision_encoder.blocks.24.mlp.fc2.weight": "model-00004-of-00004.safetensors",
473
+ "vision_encoder.blocks.24.norm1.bias": "model-00004-of-00004.safetensors",
474
+ "vision_encoder.blocks.24.norm1.weight": "model-00004-of-00004.safetensors",
475
+ "vision_encoder.blocks.24.norm2.bias": "model-00004-of-00004.safetensors",
476
+ "vision_encoder.blocks.24.norm2.weight": "model-00004-of-00004.safetensors",
477
+ "vision_encoder.blocks.25.attn.proj.bias": "model-00004-of-00004.safetensors",
478
+ "vision_encoder.blocks.25.attn.proj.weight": "model-00004-of-00004.safetensors",
479
+ "vision_encoder.blocks.25.attn.qkv.bias": "model-00004-of-00004.safetensors",
480
+ "vision_encoder.blocks.25.attn.qkv.weight": "model-00004-of-00004.safetensors",
481
+ "vision_encoder.blocks.25.mlp.fc1.bias": "model-00004-of-00004.safetensors",
482
+ "vision_encoder.blocks.25.mlp.fc1.weight": "model-00004-of-00004.safetensors",
483
+ "vision_encoder.blocks.25.mlp.fc2.bias": "model-00004-of-00004.safetensors",
484
+ "vision_encoder.blocks.25.mlp.fc2.weight": "model-00004-of-00004.safetensors",
485
+ "vision_encoder.blocks.25.norm1.bias": "model-00004-of-00004.safetensors",
486
+ "vision_encoder.blocks.25.norm1.weight": "model-00004-of-00004.safetensors",
487
+ "vision_encoder.blocks.25.norm2.bias": "model-00004-of-00004.safetensors",
488
+ "vision_encoder.blocks.25.norm2.weight": "model-00004-of-00004.safetensors",
489
+ "vision_encoder.blocks.26.attn.proj.bias": "model-00004-of-00004.safetensors",
490
+ "vision_encoder.blocks.26.attn.proj.weight": "model-00004-of-00004.safetensors",
491
+ "vision_encoder.blocks.26.attn.qkv.bias": "model-00004-of-00004.safetensors",
492
+ "vision_encoder.blocks.26.attn.qkv.weight": "model-00004-of-00004.safetensors",
493
+ "vision_encoder.blocks.26.mlp.fc1.bias": "model-00004-of-00004.safetensors",
494
+ "vision_encoder.blocks.26.mlp.fc1.weight": "model-00004-of-00004.safetensors",
495
+ "vision_encoder.blocks.26.mlp.fc2.bias": "model-00004-of-00004.safetensors",
496
+ "vision_encoder.blocks.26.mlp.fc2.weight": "model-00004-of-00004.safetensors",
497
+ "vision_encoder.blocks.26.norm1.bias": "model-00004-of-00004.safetensors",
498
+ "vision_encoder.blocks.26.norm1.weight": "model-00004-of-00004.safetensors",
499
+ "vision_encoder.blocks.26.norm2.bias": "model-00004-of-00004.safetensors",
500
+ "vision_encoder.blocks.26.norm2.weight": "model-00004-of-00004.safetensors",
501
+ "vision_encoder.blocks.27.attn.proj.bias": "model-00004-of-00004.safetensors",
502
+ "vision_encoder.blocks.27.attn.proj.weight": "model-00004-of-00004.safetensors",
503
+ "vision_encoder.blocks.27.attn.qkv.bias": "model-00004-of-00004.safetensors",
504
+ "vision_encoder.blocks.27.attn.qkv.weight": "model-00004-of-00004.safetensors",
505
+ "vision_encoder.blocks.27.mlp.fc1.bias": "model-00004-of-00004.safetensors",
506
+ "vision_encoder.blocks.27.mlp.fc1.weight": "model-00004-of-00004.safetensors",
507
+ "vision_encoder.blocks.27.mlp.fc2.bias": "model-00004-of-00004.safetensors",
508
+ "vision_encoder.blocks.27.mlp.fc2.weight": "model-00004-of-00004.safetensors",
509
+ "vision_encoder.blocks.27.norm1.bias": "model-00004-of-00004.safetensors",
510
+ "vision_encoder.blocks.27.norm1.weight": "model-00004-of-00004.safetensors",
511
+ "vision_encoder.blocks.27.norm2.bias": "model-00004-of-00004.safetensors",
512
+ "vision_encoder.blocks.27.norm2.weight": "model-00004-of-00004.safetensors",
513
+ "vision_encoder.blocks.28.attn.proj.bias": "model-00004-of-00004.safetensors",
514
+ "vision_encoder.blocks.28.attn.proj.weight": "model-00004-of-00004.safetensors",
515
+ "vision_encoder.blocks.28.attn.qkv.bias": "model-00004-of-00004.safetensors",
516
+ "vision_encoder.blocks.28.attn.qkv.weight": "model-00004-of-00004.safetensors",
517
+ "vision_encoder.blocks.28.mlp.fc1.bias": "model-00004-of-00004.safetensors",
518
+ "vision_encoder.blocks.28.mlp.fc1.weight": "model-00004-of-00004.safetensors",
519
+ "vision_encoder.blocks.28.mlp.fc2.bias": "model-00004-of-00004.safetensors",
520
+ "vision_encoder.blocks.28.mlp.fc2.weight": "model-00004-of-00004.safetensors",
521
+ "vision_encoder.blocks.28.norm1.bias": "model-00004-of-00004.safetensors",
522
+ "vision_encoder.blocks.28.norm1.weight": "model-00004-of-00004.safetensors",
523
+ "vision_encoder.blocks.28.norm2.bias": "model-00004-of-00004.safetensors",
524
+ "vision_encoder.blocks.28.norm2.weight": "model-00004-of-00004.safetensors",
525
+ "vision_encoder.blocks.29.attn.proj.bias": "model-00004-of-00004.safetensors",
526
+ "vision_encoder.blocks.29.attn.proj.weight": "model-00004-of-00004.safetensors",
527
+ "vision_encoder.blocks.29.attn.qkv.bias": "model-00004-of-00004.safetensors",
528
+ "vision_encoder.blocks.29.attn.qkv.weight": "model-00004-of-00004.safetensors",
529
+ "vision_encoder.blocks.29.mlp.fc1.bias": "model-00004-of-00004.safetensors",
530
+ "vision_encoder.blocks.29.mlp.fc1.weight": "model-00004-of-00004.safetensors",
531
+ "vision_encoder.blocks.29.mlp.fc2.bias": "model-00004-of-00004.safetensors",
532
+ "vision_encoder.blocks.29.mlp.fc2.weight": "model-00004-of-00004.safetensors",
533
+ "vision_encoder.blocks.29.norm1.bias": "model-00004-of-00004.safetensors",
534
+ "vision_encoder.blocks.29.norm1.weight": "model-00004-of-00004.safetensors",
535
+ "vision_encoder.blocks.29.norm2.bias": "model-00004-of-00004.safetensors",
536
+ "vision_encoder.blocks.29.norm2.weight": "model-00004-of-00004.safetensors",
537
+ "vision_encoder.blocks.3.attn.proj.bias": "model-00004-of-00004.safetensors",
538
+ "vision_encoder.blocks.3.attn.proj.weight": "model-00004-of-00004.safetensors",
539
+ "vision_encoder.blocks.3.attn.qkv.bias": "model-00004-of-00004.safetensors",
540
+ "vision_encoder.blocks.3.attn.qkv.weight": "model-00004-of-00004.safetensors",
541
+ "vision_encoder.blocks.3.mlp.fc1.bias": "model-00004-of-00004.safetensors",
542
+ "vision_encoder.blocks.3.mlp.fc1.weight": "model-00004-of-00004.safetensors",
543
+ "vision_encoder.blocks.3.mlp.fc2.bias": "model-00004-of-00004.safetensors",
544
+ "vision_encoder.blocks.3.mlp.fc2.weight": "model-00004-of-00004.safetensors",
545
+ "vision_encoder.blocks.3.norm1.bias": "model-00004-of-00004.safetensors",
546
+ "vision_encoder.blocks.3.norm1.weight": "model-00004-of-00004.safetensors",
547
+ "vision_encoder.blocks.3.norm2.bias": "model-00004-of-00004.safetensors",
548
+ "vision_encoder.blocks.3.norm2.weight": "model-00004-of-00004.safetensors",
549
+ "vision_encoder.blocks.30.attn.proj.bias": "model-00004-of-00004.safetensors",
550
+ "vision_encoder.blocks.30.attn.proj.weight": "model-00004-of-00004.safetensors",
551
+ "vision_encoder.blocks.30.attn.qkv.bias": "model-00004-of-00004.safetensors",
552
+ "vision_encoder.blocks.30.attn.qkv.weight": "model-00004-of-00004.safetensors",
553
+ "vision_encoder.blocks.30.mlp.fc1.bias": "model-00004-of-00004.safetensors",
554
+ "vision_encoder.blocks.30.mlp.fc1.weight": "model-00004-of-00004.safetensors",
555
+ "vision_encoder.blocks.30.mlp.fc2.bias": "model-00004-of-00004.safetensors",
556
+ "vision_encoder.blocks.30.mlp.fc2.weight": "model-00004-of-00004.safetensors",
557
+ "vision_encoder.blocks.30.norm1.bias": "model-00004-of-00004.safetensors",
558
+ "vision_encoder.blocks.30.norm1.weight": "model-00004-of-00004.safetensors",
559
+ "vision_encoder.blocks.30.norm2.bias": "model-00004-of-00004.safetensors",
560
+ "vision_encoder.blocks.30.norm2.weight": "model-00004-of-00004.safetensors",
561
+ "vision_encoder.blocks.31.attn.proj.bias": "model-00004-of-00004.safetensors",
562
+ "vision_encoder.blocks.31.attn.proj.weight": "model-00004-of-00004.safetensors",
563
+ "vision_encoder.blocks.31.attn.qkv.bias": "model-00004-of-00004.safetensors",
564
+ "vision_encoder.blocks.31.attn.qkv.weight": "model-00004-of-00004.safetensors",
565
+ "vision_encoder.blocks.31.mlp.fc1.bias": "model-00004-of-00004.safetensors",
566
+ "vision_encoder.blocks.31.mlp.fc1.weight": "model-00004-of-00004.safetensors",
567
+ "vision_encoder.blocks.31.mlp.fc2.bias": "model-00004-of-00004.safetensors",
568
+ "vision_encoder.blocks.31.mlp.fc2.weight": "model-00004-of-00004.safetensors",
569
+ "vision_encoder.blocks.31.norm1.bias": "model-00004-of-00004.safetensors",
570
+ "vision_encoder.blocks.31.norm1.weight": "model-00004-of-00004.safetensors",
571
+ "vision_encoder.blocks.31.norm2.bias": "model-00004-of-00004.safetensors",
572
+ "vision_encoder.blocks.31.norm2.weight": "model-00004-of-00004.safetensors",
573
+ "vision_encoder.blocks.4.attn.proj.bias": "model-00004-of-00004.safetensors",
574
+ "vision_encoder.blocks.4.attn.proj.weight": "model-00004-of-00004.safetensors",
575
+ "vision_encoder.blocks.4.attn.qkv.bias": "model-00004-of-00004.safetensors",
576
+ "vision_encoder.blocks.4.attn.qkv.weight": "model-00004-of-00004.safetensors",
577
+ "vision_encoder.blocks.4.mlp.fc1.bias": "model-00004-of-00004.safetensors",
578
+ "vision_encoder.blocks.4.mlp.fc1.weight": "model-00004-of-00004.safetensors",
579
+ "vision_encoder.blocks.4.mlp.fc2.bias": "model-00004-of-00004.safetensors",
580
+ "vision_encoder.blocks.4.mlp.fc2.weight": "model-00004-of-00004.safetensors",
581
+ "vision_encoder.blocks.4.norm1.bias": "model-00004-of-00004.safetensors",
582
+ "vision_encoder.blocks.4.norm1.weight": "model-00004-of-00004.safetensors",
583
+ "vision_encoder.blocks.4.norm2.bias": "model-00004-of-00004.safetensors",
584
+ "vision_encoder.blocks.4.norm2.weight": "model-00004-of-00004.safetensors",
585
+ "vision_encoder.blocks.5.attn.proj.bias": "model-00004-of-00004.safetensors",
586
+ "vision_encoder.blocks.5.attn.proj.weight": "model-00004-of-00004.safetensors",
587
+ "vision_encoder.blocks.5.attn.qkv.bias": "model-00004-of-00004.safetensors",
588
+ "vision_encoder.blocks.5.attn.qkv.weight": "model-00004-of-00004.safetensors",
589
+ "vision_encoder.blocks.5.mlp.fc1.bias": "model-00004-of-00004.safetensors",
590
+ "vision_encoder.blocks.5.mlp.fc1.weight": "model-00004-of-00004.safetensors",
591
+ "vision_encoder.blocks.5.mlp.fc2.bias": "model-00004-of-00004.safetensors",
592
+ "vision_encoder.blocks.5.mlp.fc2.weight": "model-00004-of-00004.safetensors",
593
+ "vision_encoder.blocks.5.norm1.bias": "model-00004-of-00004.safetensors",
594
+ "vision_encoder.blocks.5.norm1.weight": "model-00004-of-00004.safetensors",
595
+ "vision_encoder.blocks.5.norm2.bias": "model-00004-of-00004.safetensors",
596
+ "vision_encoder.blocks.5.norm2.weight": "model-00004-of-00004.safetensors",
597
+ "vision_encoder.blocks.6.attn.proj.bias": "model-00004-of-00004.safetensors",
598
+ "vision_encoder.blocks.6.attn.proj.weight": "model-00004-of-00004.safetensors",
599
+ "vision_encoder.blocks.6.attn.qkv.bias": "model-00004-of-00004.safetensors",
600
+ "vision_encoder.blocks.6.attn.qkv.weight": "model-00004-of-00004.safetensors",
601
+ "vision_encoder.blocks.6.mlp.fc1.bias": "model-00004-of-00004.safetensors",
602
+ "vision_encoder.blocks.6.mlp.fc1.weight": "model-00004-of-00004.safetensors",
603
+ "vision_encoder.blocks.6.mlp.fc2.bias": "model-00004-of-00004.safetensors",
604
+ "vision_encoder.blocks.6.mlp.fc2.weight": "model-00004-of-00004.safetensors",
605
+ "vision_encoder.blocks.6.norm1.bias": "model-00004-of-00004.safetensors",
606
+ "vision_encoder.blocks.6.norm1.weight": "model-00004-of-00004.safetensors",
607
+ "vision_encoder.blocks.6.norm2.bias": "model-00004-of-00004.safetensors",
608
+ "vision_encoder.blocks.6.norm2.weight": "model-00004-of-00004.safetensors",
609
+ "vision_encoder.blocks.7.attn.proj.bias": "model-00004-of-00004.safetensors",
610
+ "vision_encoder.blocks.7.attn.proj.weight": "model-00004-of-00004.safetensors",
611
+ "vision_encoder.blocks.7.attn.qkv.bias": "model-00004-of-00004.safetensors",
612
+ "vision_encoder.blocks.7.attn.qkv.weight": "model-00004-of-00004.safetensors",
613
+ "vision_encoder.blocks.7.mlp.fc1.bias": "model-00004-of-00004.safetensors",
614
+ "vision_encoder.blocks.7.mlp.fc1.weight": "model-00004-of-00004.safetensors",
615
+ "vision_encoder.blocks.7.mlp.fc2.bias": "model-00004-of-00004.safetensors",
616
+ "vision_encoder.blocks.7.mlp.fc2.weight": "model-00004-of-00004.safetensors",
617
+ "vision_encoder.blocks.7.norm1.bias": "model-00004-of-00004.safetensors",
618
+ "vision_encoder.blocks.7.norm1.weight": "model-00004-of-00004.safetensors",
619
+ "vision_encoder.blocks.7.norm2.bias": "model-00004-of-00004.safetensors",
620
+ "vision_encoder.blocks.7.norm2.weight": "model-00004-of-00004.safetensors",
621
+ "vision_encoder.blocks.8.attn.proj.bias": "model-00004-of-00004.safetensors",
622
+ "vision_encoder.blocks.8.attn.proj.weight": "model-00004-of-00004.safetensors",
623
+ "vision_encoder.blocks.8.attn.qkv.bias": "model-00004-of-00004.safetensors",
624
+ "vision_encoder.blocks.8.attn.qkv.weight": "model-00004-of-00004.safetensors",
625
+ "vision_encoder.blocks.8.mlp.fc1.bias": "model-00004-of-00004.safetensors",
626
+ "vision_encoder.blocks.8.mlp.fc1.weight": "model-00004-of-00004.safetensors",
627
+ "vision_encoder.blocks.8.mlp.fc2.bias": "model-00004-of-00004.safetensors",
628
+ "vision_encoder.blocks.8.mlp.fc2.weight": "model-00004-of-00004.safetensors",
629
+ "vision_encoder.blocks.8.norm1.bias": "model-00004-of-00004.safetensors",
630
+ "vision_encoder.blocks.8.norm1.weight": "model-00004-of-00004.safetensors",
631
+ "vision_encoder.blocks.8.norm2.bias": "model-00004-of-00004.safetensors",
632
+ "vision_encoder.blocks.8.norm2.weight": "model-00004-of-00004.safetensors",
633
+ "vision_encoder.blocks.9.attn.proj.bias": "model-00004-of-00004.safetensors",
634
+ "vision_encoder.blocks.9.attn.proj.weight": "model-00004-of-00004.safetensors",
635
+ "vision_encoder.blocks.9.attn.qkv.bias": "model-00004-of-00004.safetensors",
636
+ "vision_encoder.blocks.9.attn.qkv.weight": "model-00004-of-00004.safetensors",
637
+ "vision_encoder.blocks.9.mlp.fc1.bias": "model-00004-of-00004.safetensors",
638
+ "vision_encoder.blocks.9.mlp.fc1.weight": "model-00004-of-00004.safetensors",
639
+ "vision_encoder.blocks.9.mlp.fc2.bias": "model-00004-of-00004.safetensors",
640
+ "vision_encoder.blocks.9.mlp.fc2.weight": "model-00004-of-00004.safetensors",
641
+ "vision_encoder.blocks.9.norm1.bias": "model-00004-of-00004.safetensors",
642
+ "vision_encoder.blocks.9.norm1.weight": "model-00004-of-00004.safetensors",
643
+ "vision_encoder.blocks.9.norm2.bias": "model-00004-of-00004.safetensors",
644
+ "vision_encoder.blocks.9.norm2.weight": "model-00004-of-00004.safetensors",
645
+ "vision_encoder.merger.ln_q.bias": "model-00004-of-00004.safetensors",
646
+ "vision_encoder.merger.ln_q.weight": "model-00004-of-00004.safetensors",
647
+ "vision_encoder.merger.mlp.0.bias": "model-00004-of-00004.safetensors",
648
+ "vision_encoder.merger.mlp.0.weight": "model-00004-of-00004.safetensors",
649
+ "vision_encoder.merger.mlp.2.bias": "model-00004-of-00004.safetensors",
650
+ "vision_encoder.merger.mlp.2.weight": "model-00004-of-00004.safetensors",
651
+ "vision_encoder.patch_embed.proj.weight": "model-00004-of-00004.safetensors",
652
+ "vision_projector.ln_q.bias": "model-00004-of-00004.safetensors",
653
+ "vision_projector.ln_q.weight": "model-00004-of-00004.safetensors",
654
+ "vision_projector.mlp.0.bias": "model-00004-of-00004.safetensors",
655
+ "vision_projector.mlp.0.weight": "model-00004-of-00004.safetensors",
656
+ "vision_projector.mlp.2.bias": "model-00004-of-00004.safetensors",
657
+ "vision_projector.mlp.2.weight": "model-00004-of-00004.safetensors"
658
+ }
659
+ }
modeling_llama.py ADDED
@@ -0,0 +1,978 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from functools import partial
2
+ from typing import Optional, Tuple, Union
3
+
4
+ import torch
5
+ import torch.nn.functional as F
6
+ import torch.utils.checkpoint
7
+ from packaging import version
8
+ from torch import nn
9
+ from torch.nn import CrossEntropyLoss
10
+ from transformers.activations import ACT2FN
11
+ from transformers.modeling_outputs import (
12
+ BaseModelOutputWithPast,
13
+ CausalLMOutputWithPast,
14
+ )
15
+ from transformers.modeling_utils import PreTrainedModel
16
+ from transformers.utils import logging
17
+
18
+ from .configuration_llama import CustomLlamaConfig
19
+
20
+ try:
21
+ from apex.megatron_layer_norm import MixedFusedLayerNorm as LayerNorm
22
+ except ImportError:
23
+ from torch.nn import LayerNorm
24
+
25
+ USE_FLASH_ATTN = False
26
+ try:
27
+ import flash_attn
28
+ if version.parse(flash_attn.__version__) >= version.parse("2.1.0"):
29
+ USE_FLASH_ATTN = True
30
+ from flash_attn import flash_attn_func, flash_attn_varlen_func
31
+ from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input
32
+ except ImportError:
33
+ pass
34
+
35
+ logger = logging.get_logger(__name__)
36
+
37
+
38
+ def _get_unpad_data(attention_mask):
39
+ seqlens_in_batch = (attention_mask).sum(dim=-1, dtype=torch.int32)
40
+ indices = torch.nonzero(attention_mask.flatten(), as_tuple=False).flatten()
41
+ max_seqlen_in_batch = seqlens_in_batch.max().item()
42
+ cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0,
43
+ dtype=torch.torch.int32), (1, 0))
44
+ return (
45
+ indices,
46
+ cu_seqlens,
47
+ max_seqlen_in_batch,
48
+ )
49
+
50
+
51
+ class RMSNorm(torch.nn.Module):
52
+ def __init__(self, dim: int, eps: float = 1e-6):
53
+ """
54
+ Initialize the RMSNorm normalization layer.
55
+
56
+ Args:
57
+ dim (int): The dimension of the input tensor.
58
+ eps (float, optional): A small value added to the denominator for numerical stability. Default is 1e-6.
59
+
60
+ Attributes:
61
+ eps (float): A small value added to the denominator for numerical stability.
62
+ weight (nn.Parameter): Learnable scaling parameter.
63
+
64
+ """
65
+ super().__init__()
66
+ self.eps = eps
67
+ self.weight = nn.Parameter(torch.ones(dim))
68
+
69
+ def _norm(self, x):
70
+ """
71
+ Apply the RMSNorm normalization to the input tensor.
72
+
73
+ Args:
74
+ x (torch.Tensor): The input tensor.
75
+
76
+ Returns:
77
+ torch.Tensor: The normalized tensor.
78
+
79
+ """
80
+ return x * torch.rsqrt(x.pow(2).mean(-1, keepdim=True) + self.eps)
81
+
82
+ def forward(self, x):
83
+ """
84
+ Forward pass through the RMSNorm layer.
85
+
86
+ Args:
87
+ x (torch.Tensor): The input tensor.
88
+
89
+ Returns:
90
+ torch.Tensor: The output tensor after applying RMSNorm.
91
+
92
+ """
93
+ output = self._norm(x.float()).type_as(x)
94
+ return output * self.weight
95
+
96
+
97
+ def get_norm(config: CustomLlamaConfig):
98
+ norm_type = config.norm_type
99
+ if norm_type == 'rms_norm':
100
+ return partial(RMSNorm, eps=config.layernorm_epsilon)
101
+ elif norm_type == 'layer_norm':
102
+ return partial(LayerNorm, eps=config.layernorm_epsilon)
103
+ else:
104
+ raise ValueError(f'Unsupported norm type: {norm_type}')
105
+
106
+
107
+ # Copied from transformers.models.bart.modeling_bart._make_causal_mask
108
+ def _make_causal_mask(
109
+ input_ids_shape: torch.Size,
110
+ dtype: torch.dtype,
111
+ device: torch.device,
112
+ past_key_values_length: int = 0,
113
+ ):
114
+ """
115
+ Make causal mask used for bi-directional self-attention.
116
+ """
117
+ bsz, tgt_len = input_ids_shape
118
+ mask = torch.full((tgt_len, tgt_len),
119
+ torch.finfo(dtype).min, device=device)
120
+ mask_cond = torch.arange(mask.size(-1), device=device)
121
+ mask.masked_fill_(mask_cond < (mask_cond + 1).view(mask.size(-1), 1), 0)
122
+ mask = mask.to(dtype)
123
+
124
+ if past_key_values_length > 0:
125
+ mask = torch.cat(
126
+ [
127
+ torch.zeros(
128
+ tgt_len, past_key_values_length, dtype=dtype, device=device
129
+ ),
130
+ mask,
131
+ ],
132
+ dim=-1,
133
+ )
134
+ return mask[None, None, :, :].expand(
135
+ bsz, 1, tgt_len, tgt_len + past_key_values_length
136
+ )
137
+
138
+
139
+ # Copied from transformers.models.bart.modeling_bart._expand_mask
140
+ def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None):
141
+ """
142
+ Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
143
+ """
144
+ bsz, src_len = mask.size()
145
+ tgt_len = tgt_len if tgt_len is not None else src_len
146
+
147
+ expanded_mask = mask[:, None, None, :].expand(
148
+ bsz, 1, tgt_len, src_len).to(dtype)
149
+
150
+ inverted_mask = 1.0 - expanded_mask
151
+
152
+ return inverted_mask.masked_fill(
153
+ inverted_mask.to(torch.bool), torch.finfo(dtype).min
154
+ )
155
+
156
+
157
+ class RotaryEmbedding(torch.nn.Module):
158
+ def __init__(self, dim, base=10000, compress=1.0):
159
+ super().__init__()
160
+ self.inv_freq = 1.0 / (base ** (torch.arange(0, dim, 2).float() / dim))
161
+ self.seq_len_cached = 0
162
+ self.cos_cached = None
163
+ self.sin_cached = None
164
+ self.compress = compress
165
+
166
+ def forward(self, x, seq_len):
167
+ if seq_len > self.seq_len_cached:
168
+ self.seq_len_cached = seq_len
169
+ self.inv_freq = self.inv_freq.to(x.device)
170
+ t = (
171
+ torch.arange(seq_len, device=self.inv_freq.device,
172
+ dtype=self.inv_freq.dtype)
173
+ * self.compress
174
+ )
175
+ freqs = torch.einsum("i,j->ij", t, self.inv_freq)
176
+ emb = torch.cat((freqs, freqs), dim=-1).to(x.device)
177
+ self.cos_cached = emb.cos()[None, None, :, :]
178
+ self.sin_cached = emb.sin()[None, None, :, :]
179
+ return self.cos_cached[:seq_len, ...], self.sin_cached[:seq_len, ...]
180
+
181
+
182
+ # rotary pos emb helpers:
183
+
184
+
185
+ def rotate_half(x):
186
+ x1, x2 = x[..., : x.shape[-1] // 2], x[..., x.shape[-1] // 2:]
187
+ return torch.cat((-x2, x1), dim=-1)
188
+
189
+
190
+ @torch.jit.script
191
+ def apply_rotary_pos_emb(q, k, cos, sin, offset: int = 0):
192
+ cos, sin = (
193
+ cos[..., offset: q.shape[-2] + offset, :],
194
+ sin[..., offset: q.shape[-2] + offset, :],
195
+ )
196
+ q_embed = (q.float() * cos) + (rotate_half(q.float()) * sin)
197
+ k_embed = (k.float() * cos) + (rotate_half(k.float()) * sin)
198
+ return q_embed.to(q.dtype), k_embed.to(k.dtype)
199
+
200
+
201
+ def apply_rotary_pos_emb_torch(
202
+ q, k, cos, sin, offset: int = 0
203
+ ): # jitting fails with bf16
204
+ cos, sin = (
205
+ cos[..., offset: q.shape[-2] + offset, :],
206
+ sin[..., offset: q.shape[-2] + offset, :],
207
+ )
208
+ q_embed = (q.float() * cos) + (rotate_half(q.float()) * sin)
209
+ k_embed = (k.float() * cos) + (rotate_half(k.float()) * sin)
210
+ return q_embed.to(q.dtype), k_embed.to(k.dtype)
211
+
212
+
213
+ class CustomLlamaAttention(nn.Module):
214
+ def __init__(self, config: CustomLlamaConfig):
215
+ super().__init__()
216
+ self.num_attention_heads = config.num_attention_heads
217
+ self.num_kv_heads = config.num_kv_heads
218
+ self.hidden_size = config.hidden_size
219
+ self.head_size = self.hidden_size // self.num_attention_heads
220
+ self.rotary_ndims = int(self.head_size * config.rotary_pct)
221
+ self.max_positions = config.max_position_embeddings
222
+ self.rotary_emb = RotaryEmbedding(
223
+ self.rotary_ndims,
224
+ base=config.rotary_emb_base,
225
+ compress=config.rotary_compress,
226
+ )
227
+ self.norm_factor = torch.sqrt(
228
+ torch.tensor(self.head_size, dtype=torch.float32)
229
+ ).to(torch.get_default_dtype())
230
+
231
+ if self.use_gqa:
232
+ self.query_dense = nn.Linear(
233
+ config.hidden_size,
234
+ config.hidden_size,
235
+ bias=getattr(config, "qkv_proj_bias", True)
236
+ )
237
+ self.key_value_dense = nn.Linear(
238
+ config.hidden_size,
239
+ self.head_size * 2 * config.num_kv_heads,
240
+ bias=getattr(config, "qkv_proj_bias", True),
241
+ )
242
+ else:
243
+ self.query_key_value = nn.Linear(
244
+ config.hidden_size,
245
+ 3 * config.hidden_size,
246
+ bias=getattr(config, "qkv_proj_bias", True),
247
+ )
248
+
249
+ self.dense = nn.Linear(
250
+ config.hidden_size,
251
+ config.hidden_size,
252
+ bias=getattr(config, "out_proj_bias", True),
253
+ )
254
+ self.apply_rotary_fn = (
255
+ apply_rotary_pos_emb_torch
256
+ if config.torch_dtype == torch.bfloat16
257
+ else apply_rotary_pos_emb
258
+ )
259
+
260
+ @property
261
+ def use_gqa(self):
262
+ return self.num_kv_heads < self.num_attention_heads
263
+
264
+ def forward(
265
+ self,
266
+ hidden_states,
267
+ attention_mask,
268
+ head_mask=None,
269
+ layer_past=None,
270
+ use_cache=False,
271
+ output_attentions=False,
272
+ ):
273
+ has_layer_past = layer_past is not None
274
+
275
+ if self.use_gqa:
276
+ # Compute Q
277
+ # [batch, seq_len, hidden_size] --> [batch_size, seq_len, (num_heads * head_size)]
278
+ q = self.query_dense(hidden_states)
279
+
280
+ # [batch_size, seq_len, (num_heads * head_size)]
281
+ # --> [batch, seq_len, num_attention_heads, head_size]
282
+ new_q_shape = q.size()[:-1] + \
283
+ (self.num_attention_heads, self.head_size)
284
+ q = q.view(*new_q_shape)
285
+
286
+ # Compute KV
287
+ # [batch, seq_len, hidden_size] --> [batch_size, seq_len, (num_attention_groups * 2 * head_size)]
288
+ kv = self.key_value_dense(hidden_states)
289
+
290
+ # [batch, seq_len, (num_attention_groups * 2 * head_size)]
291
+ # --> [batch, seq_len, num_attention_groups, 2 * head_size]
292
+ new_kv_shape = kv.size()[:-1] + (
293
+ self.num_kv_heads,
294
+ 2 * self.head_size,
295
+ )
296
+ kv = kv.view(*new_kv_shape)
297
+
298
+ # [batch, num_attention_heads, seq_len, head_size]
299
+ query = q.permute(0, 2, 1, 3)
300
+ # [batch, num_attention_groups, seq_len, head_size]
301
+ key = kv[..., : self.head_size].permute(0, 2, 1, 3)
302
+ value = kv[..., self.head_size:].permute(0, 2, 1, 3)
303
+ else:
304
+ # Compute QKV
305
+ # Attention heads [batch, seq_len, hidden_size]
306
+ # --> [batch, seq_len, (np * 3 * head_size)]
307
+ qkv = self.query_key_value(hidden_states)
308
+
309
+ # [batch, seq_len, (num_heads * 3 * head_size)]
310
+ # --> [batch, seq_len, num_heads, 3 * head_size]
311
+ new_qkv_shape = qkv.size()[:-1] + (
312
+ self.num_attention_heads,
313
+ 3 * self.head_size,
314
+ )
315
+ qkv = qkv.view(*new_qkv_shape)
316
+
317
+ # [batch, seq_len, num_attention_heads, 3 * head_size] --> 3 [batch, num_attention_heads, seq_len, head_size]
318
+ query = qkv[..., : self.head_size].permute(0, 2, 1, 3)
319
+ key = qkv[..., self.head_size: 2 *
320
+ self.head_size].permute(0, 2, 1, 3)
321
+ value = qkv[..., 2 * self.head_size:].permute(0, 2, 1, 3)
322
+
323
+ # Compute rotary embeddings on rotary_ndims
324
+ query_rot = query[..., : self.rotary_ndims]
325
+ query_pass = query[..., self.rotary_ndims:]
326
+ key_rot = key[..., : self.rotary_ndims]
327
+ key_pass = key[..., self.rotary_ndims:]
328
+
329
+ # Compute token offset for rotary embeddings (when decoding)
330
+ seq_len = key.shape[-2]
331
+ offset = 0
332
+ if has_layer_past:
333
+ offset = layer_past[0].shape[-2]
334
+ seq_len += offset
335
+ cos, sin = self.rotary_emb(value, seq_len=seq_len)
336
+ query, key = self.apply_rotary_fn(
337
+ query_rot, key_rot, cos, sin, offset=offset)
338
+ query = torch.cat((query, query_pass), dim=-1)
339
+ key = torch.cat((key, key_pass), dim=-1)
340
+
341
+ # Cache QKV values
342
+ if has_layer_past:
343
+ past_key = layer_past[0]
344
+ past_value = layer_past[1]
345
+ key = torch.cat((past_key, key), dim=-2)
346
+ value = torch.cat((past_value, value), dim=-2)
347
+ present = (key, value) if use_cache else None
348
+
349
+ if USE_FLASH_ATTN:
350
+ # Compute attention
351
+ attn_output, attn_weights = self._flash_attn(
352
+ query, key, value, attention_mask, head_mask
353
+ )
354
+
355
+ # from [batch_size, ]
356
+ attn_output = attn_output.reshape(
357
+ attn_output.size(0), attn_output.size(1), self.hidden_size).contiguous()
358
+ else:
359
+ # Compute attention
360
+ attn_output, attn_weights = self._attn(
361
+ query, key, value, attention_mask, head_mask
362
+ )
363
+
364
+ # Reshape outputs
365
+ attn_output = self._merge_heads(
366
+ attn_output, self.num_attention_heads, self.head_size
367
+ )
368
+ attn_output = self.dense(attn_output)
369
+
370
+ outputs = (attn_output, present)
371
+ if output_attentions:
372
+ outputs += (attn_weights,)
373
+
374
+ return outputs
375
+
376
+ @classmethod
377
+ def _split_heads(cls, tensor, num_attention_heads, attn_head_size):
378
+ """
379
+ Splits hidden dim into attn_head_size and num_attention_heads
380
+ """
381
+ # tensor: [bs, seq_len, hidden_size]
382
+ new_shape = tensor.size()[:-1] + (num_attention_heads, attn_head_size)
383
+ # -> [bs, seq_len, num_attention_heads, attn_head_size]
384
+ tensor = tensor.view(new_shape)
385
+ # -> [bs, num_attention_heads, seq_len, attn_head_size]
386
+ tensor = tensor.permute(0, 2, 1, 3)
387
+ return tensor
388
+
389
+ @classmethod
390
+ def _merge_heads(cls, tensor, num_attention_heads, attn_head_size):
391
+ """
392
+ Merges attn_head_size dim and num_attn_heads dim into hidden dim
393
+ """
394
+ # tensor [bs, num_attention_heads, seq_len, attn_head_size]
395
+ tensor = tensor.permute(0, 2, 1, 3).contiguous()
396
+ # -> [bs, seq_len, num_attention_heads, attn_head_size]
397
+ tensor = tensor.view(
398
+ tensor.size(0), tensor.size(
399
+ 1), num_attention_heads * attn_head_size
400
+ )
401
+ # -> [bs, seq_len, hidden_size]
402
+ return tensor
403
+
404
+ def _attn(self, query, key, value, attention_mask=None, head_mask=None):
405
+ # q: [bs, num_attention_heads, seq_len, attn_head_size]
406
+ # k,v: [bs, num_attention_groups, seq_len, attn_head_size]
407
+ # compute causal mask from causal mask buffer
408
+ batch_size, num_attention_heads, query_length, attn_head_size = query.size()
409
+ _, num_attention_groups, key_length, _ = key.size()
410
+
411
+ group_size = num_attention_heads // num_attention_groups
412
+
413
+ if not self.use_gqa:
414
+ assert group_size == 1
415
+
416
+ # repeat key and value, so we can use normal MHA algorithm
417
+ key = (
418
+ key.view(batch_size, num_attention_groups,
419
+ 1, key_length, attn_head_size)
420
+ .repeat(1, 1, group_size, 1, 1)
421
+ .view(batch_size, num_attention_heads, key_length, attn_head_size)
422
+ )
423
+ value = (
424
+ value.view(batch_size, num_attention_groups,
425
+ 1, key_length, attn_head_size)
426
+ .repeat(1, 1, group_size, 1, 1)
427
+ .view(batch_size, num_attention_heads, key_length, attn_head_size)
428
+ )
429
+
430
+ query = query.view(
431
+ batch_size * num_attention_heads, query_length, attn_head_size
432
+ )
433
+ key = key.view(batch_size * num_attention_heads,
434
+ key_length, attn_head_size)
435
+ attn_scores = torch.zeros(
436
+ batch_size * num_attention_heads,
437
+ query_length,
438
+ key_length,
439
+ dtype=query.dtype,
440
+ device=key.device,
441
+ )
442
+ attn_scores = torch.baddbmm(
443
+ attn_scores,
444
+ query,
445
+ key.transpose(1, 2),
446
+ beta=1.0,
447
+ alpha=(
448
+ torch.tensor(
449
+ 1.0, dtype=self.norm_factor.dtype, device=self.norm_factor.device
450
+ )
451
+ / self.norm_factor
452
+ ),
453
+ )
454
+ attn_scores = attn_scores.view(
455
+ batch_size, num_attention_heads, query_length, key_length
456
+ )
457
+
458
+ mask_value = torch.finfo(attn_scores.dtype).min
459
+ # Need to be a tensor, otherwise we get error: `RuntimeError: expected scalar type float but found double`.
460
+ # Need to be on the same device, otherwise `RuntimeError: ..., x and y to be on the same device`
461
+ mask_value = torch.tensor(mask_value, dtype=attn_scores.dtype).to(
462
+ attn_scores.device
463
+ )
464
+
465
+ if attention_mask is not None:
466
+ # Apply the attention mask
467
+ attn_scores = attn_scores + attention_mask
468
+
469
+ attn_weights = nn.functional.softmax(attn_scores, dim=-1)
470
+ attn_weights = attn_weights.to(value.dtype)
471
+
472
+ # Mask heads if we want to
473
+ if head_mask is not None:
474
+ attn_weights = attn_weights * head_mask
475
+
476
+ attn_output = torch.matmul(attn_weights, value)
477
+ return attn_output, attn_weights
478
+
479
+ def _flash_attn(self, query, key, value, attention_mask=None, head_mask=None):
480
+ assert head_mask is None, "head_mask is not supported in _flash_attn"
481
+ # q: [bs, num_attention_heads, seq_len, attn_head_size]
482
+ # k,v: [bs, num_attention_groups, seq_len, attn_head_size]
483
+
484
+ # flash_attn need the layout to be [batch_size, sequence_length, num_heads, head_dim]
485
+ query = query.transpose(1, 2)
486
+ key = key.transpose(1, 2)
487
+ value = value.transpose(1, 2)
488
+
489
+ query_length = query.size(1)
490
+ causal = query_length != 1
491
+
492
+ if attention_mask is not None:
493
+ batch_size = query.size(0)
494
+ query, key, value, indices_q, cu_seq_lens, max_seq_lens = self._upad_input(
495
+ query, key, value, attention_mask, query_length
496
+ )
497
+
498
+ cu_seqlens_q, cu_seqlens_k = cu_seq_lens
499
+ max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
500
+
501
+ attn_output_unpad = flash_attn_varlen_func(
502
+ query,
503
+ key,
504
+ value,
505
+ cu_seqlens_q=cu_seqlens_q,
506
+ cu_seqlens_k=cu_seqlens_k,
507
+ max_seqlen_q=max_seqlen_in_batch_q,
508
+ max_seqlen_k=max_seqlen_in_batch_k,
509
+ dropout_p=0,
510
+ causal=causal,
511
+ )
512
+
513
+ attn_output = pad_input(
514
+ attn_output_unpad, indices_q, batch_size, query_length)
515
+ else:
516
+ attn_output = flash_attn_func(
517
+ query, key, value, 0, causal=causal
518
+ )
519
+
520
+ return attn_output, None
521
+
522
+ def _upad_input(self, query_layer, key_layer, value_layer, attention_mask, query_length):
523
+ indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(
524
+ attention_mask)
525
+ batch_size, kv_seq_len, num_key_value_heads, head_dim = key_layer.shape
526
+ num_attention_heads = query_layer.shape[2]
527
+
528
+ key_layer = index_first_axis(
529
+ key_layer.reshape(batch_size * kv_seq_len,
530
+ num_key_value_heads, head_dim), indices_k
531
+ )
532
+ value_layer = index_first_axis(
533
+ value_layer.reshape(batch_size * kv_seq_len,
534
+ num_key_value_heads, head_dim), indices_k
535
+ )
536
+ if query_length == kv_seq_len:
537
+ query_layer = index_first_axis(
538
+ query_layer.reshape(batch_size * kv_seq_len,
539
+ num_attention_heads, head_dim), indices_k
540
+ )
541
+ cu_seqlens_q = cu_seqlens_k
542
+ max_seqlen_in_batch_q = max_seqlen_in_batch_k
543
+ indices_q = indices_k
544
+ elif query_length == 1:
545
+ max_seqlen_in_batch_q = 1
546
+ cu_seqlens_q = torch.arange(
547
+ batch_size + 1, dtype=torch.int32, device=query_layer.device
548
+ ) # There is a memcpy here, that is very bad.
549
+ indices_q = cu_seqlens_q[:-1]
550
+ query_layer = query_layer.squeeze(1)
551
+ else:
552
+ # The -q_len: slice assumes left padding.
553
+ attention_mask = attention_mask[:, -query_length:]
554
+ query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(
555
+ query_layer, attention_mask)
556
+
557
+ return (
558
+ query_layer,
559
+ key_layer,
560
+ value_layer,
561
+ indices_q,
562
+ (cu_seqlens_q, cu_seqlens_k),
563
+ (max_seqlen_in_batch_q, max_seqlen_in_batch_k),
564
+ )
565
+
566
+
567
+ def swiglu(x):
568
+ x1, x2 = x.chunk(2, dim=(x.ndim - 1))
569
+ return x1 * torch.nn.functional.silu(x2)
570
+
571
+
572
+ def get_activation(act_name: str):
573
+ if act_name == "gelu":
574
+ return ACT2FN["gelu_new"]
575
+ elif act_name == "swiglu":
576
+ return swiglu
577
+ else:
578
+ return ACT2FN[act_name]
579
+
580
+
581
+ class CustomLlamaMLP(nn.Module):
582
+ def __init__(self, config):
583
+ super().__init__()
584
+ h_to_4h_out_channels = (
585
+ config.ffn_hidden_size * 2
586
+ if config.hidden_act == "swiglu"
587
+ else config.ffn_hidden_size
588
+ )
589
+ self.dense_h_to_4h = nn.Linear(
590
+ config.hidden_size,
591
+ h_to_4h_out_channels,
592
+ bias=getattr(config, "mlp_fc1_bias", True)
593
+ )
594
+ self.dense_4h_to_h = nn.Linear(
595
+ config.ffn_hidden_size,
596
+ config.hidden_size,
597
+ bias=getattr(config, "mlp_fc2_bias", True)
598
+ )
599
+ self.act = get_activation(config.hidden_act)
600
+
601
+ def forward(self, hidden_states):
602
+ hidden_states = self.dense_h_to_4h(hidden_states)
603
+ hidden_states = self.act(hidden_states)
604
+ hidden_states = self.dense_4h_to_h(hidden_states)
605
+ return hidden_states
606
+
607
+
608
+ class CustomLlamaLayer(nn.Module):
609
+ def __init__(self, config):
610
+ super().__init__()
611
+
612
+ norm_func = get_norm(config)
613
+ self.input_layernorm = norm_func(config.hidden_size)
614
+ self.post_attention_layernorm = norm_func(config.hidden_size)
615
+ self.attention = CustomLlamaAttention(config)
616
+ self.mlp = CustomLlamaMLP(config)
617
+
618
+ def forward(
619
+ self,
620
+ hidden_states,
621
+ attention_mask=None,
622
+ head_mask=None,
623
+ use_cache=False,
624
+ layer_past=None,
625
+ output_attentions=False,
626
+ ):
627
+ attn_in = self.input_layernorm(hidden_states)
628
+ attention_layer_outputs = self.attention(
629
+ attn_in,
630
+ attention_mask=attention_mask,
631
+ layer_past=layer_past,
632
+ head_mask=head_mask,
633
+ use_cache=use_cache,
634
+ output_attentions=output_attentions,
635
+ )
636
+ attn_output = attention_layer_outputs[
637
+ 0
638
+ ] # output_attn: attn_output, present, (attn_weights)
639
+ outputs = attention_layer_outputs[1:]
640
+ # pseudocode:
641
+ # x = x + attn(ln1(x))
642
+ # x = x + mlp(ln2(x))
643
+ attn_output = attn_output + hidden_states
644
+ mlp_input = self.post_attention_layernorm(attn_output)
645
+ mlp_output = self.mlp(mlp_input)
646
+ hidden_states = mlp_output + attn_output
647
+
648
+ if use_cache:
649
+ outputs = (
650
+ hidden_states,
651
+ ) + outputs # hidden_states, present, (attn_weights)
652
+ else:
653
+ # hidden_states, (attn_weights)
654
+ outputs = (hidden_states,) + outputs[1:]
655
+
656
+ return outputs
657
+
658
+
659
+ class CustomLlamaPreTrainedModel(PreTrainedModel):
660
+ config_class = CustomLlamaConfig
661
+ base_model_prefix = "lm"
662
+ _no_split_modules = ["CustomLlamaLayer"]
663
+
664
+
665
+ class CustomLlamaModel(CustomLlamaPreTrainedModel):
666
+ def __init__(self, config):
667
+ super().__init__(config)
668
+ self.config = config
669
+
670
+ self.embed_in = nn.Embedding(config.vocab_size, config.hidden_size)
671
+ self.layers = nn.ModuleList(
672
+ [CustomLlamaLayer(config) for _ in range(config.num_layers)]
673
+ )
674
+
675
+ norm_func = get_norm(config)
676
+ self.final_layer_norm = norm_func(config.hidden_size)
677
+ # Initialize weights and apply final processing
678
+ self.post_init()
679
+
680
+ def get_input_embeddings(self):
681
+ return self.embed_in
682
+
683
+ def set_input_embeddings(self, value):
684
+ self.embed_in = value
685
+
686
+ # Copied from transformers.models.bart.modeling_bart.BartDecoder._prepare_decoder_attention_mask
687
+ def _prepare_decoder_attention_mask(
688
+ self, attention_mask, input_shape, inputs_embeds, past_key_values_length
689
+ ):
690
+ # create causal mask
691
+ # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
692
+ combined_attention_mask = None
693
+ if input_shape[-1] > 1:
694
+ combined_attention_mask = _make_causal_mask(
695
+ input_shape,
696
+ inputs_embeds.dtype,
697
+ device=inputs_embeds.device,
698
+ past_key_values_length=past_key_values_length,
699
+ )
700
+
701
+ if attention_mask is not None:
702
+ # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
703
+ expanded_attn_mask = _expand_mask(
704
+ attention_mask, inputs_embeds.dtype, tgt_len=input_shape[-1]
705
+ ).to(inputs_embeds.device)
706
+ combined_attention_mask = (
707
+ expanded_attn_mask
708
+ if combined_attention_mask is None
709
+ else expanded_attn_mask + combined_attention_mask
710
+ )
711
+
712
+ return combined_attention_mask
713
+
714
+ def forward(
715
+ self,
716
+ input_ids: Optional[torch.LongTensor] = None,
717
+ attention_mask: Optional[torch.FloatTensor] = None,
718
+ head_mask: Optional[torch.FloatTensor] = None,
719
+ inputs_embeds: Optional[torch.FloatTensor] = None,
720
+ past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
721
+ use_cache: Optional[bool] = None,
722
+ output_attentions: Optional[bool] = None,
723
+ output_hidden_states: Optional[bool] = None,
724
+ return_dict: Optional[bool] = None,
725
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
726
+ r"""
727
+ past_key_values (`tuple(tuple(torch.FloatTensor))` of length `config.n_layers` with each tuple having 4 tensors of shape `(batch_size, num_heads, sequence_length - 1, embed_size_per_head)`):
728
+ Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.
729
+ If `past_key_values` are used, the user can optionally input only the last `decoder_input_ids` (those that
730
+ don't have their past key value states given to this model) of shape `(batch_size, 1)` instead of all
731
+ `decoder_input_ids` of shape `(batch_size, sequence_length)`.
732
+ use_cache (`bool`, *optional*):
733
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
734
+ `past_key_values`).
735
+ """
736
+ output_attentions = (
737
+ output_attentions
738
+ if output_attentions is not None
739
+ else self.config.output_attentions
740
+ )
741
+ output_hidden_states = (
742
+ output_hidden_states
743
+ if output_hidden_states is not None
744
+ else self.config.output_hidden_states
745
+ )
746
+ return_dict = (
747
+ return_dict if return_dict is not None else self.config.use_return_dict
748
+ )
749
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
750
+
751
+ if input_ids is not None and inputs_embeds is not None:
752
+ raise ValueError(
753
+ "You cannot specify both input_ids and inputs_embeds at the same time"
754
+ )
755
+ elif input_ids is not None:
756
+ input_shape = input_ids.size()
757
+ elif inputs_embeds is not None:
758
+ input_shape = inputs_embeds.size()[:-1]
759
+ else:
760
+ raise ValueError(
761
+ "You have to specify either input_ids or inputs_embeds")
762
+
763
+ batch_size, seq_length = input_shape
764
+ seq_length_with_past = seq_length
765
+ past_key_values_length = 0
766
+
767
+ if past_key_values is not None:
768
+ past_key_values_length = past_key_values[0][0].shape[2]
769
+ seq_length_with_past = seq_length_with_past + past_key_values_length
770
+ else:
771
+ past_key_values = tuple([None] * self.config.num_layers)
772
+
773
+ if inputs_embeds is None:
774
+ inputs_embeds = self.embed_in(input_ids)
775
+ # Attention mask.
776
+ if attention_mask is None:
777
+ attention_mask = torch.ones(
778
+ (batch_size, seq_length_with_past),
779
+ dtype=torch.bool,
780
+ device=inputs_embeds.device,
781
+ )
782
+
783
+ # Prepare head mask if needed
784
+ # 1.0 in head_mask indicate we keep the head
785
+ # attention_probs has shape bsz x n_heads x N x N
786
+ # input head_mask has shape [num_heads] or [num_layers x num_heads]
787
+ # and head_mask is converted to shape [num_layers x batch x num_heads x seq_length x seq_length]
788
+ head_mask = self.get_head_mask(head_mask, self.config.num_layers)
789
+
790
+ if USE_FLASH_ATTN:
791
+ attention_mask = attention_mask if (
792
+ attention_mask is not None and 0 in attention_mask) else None
793
+ else:
794
+ attention_mask = self._prepare_decoder_attention_mask(
795
+ attention_mask,
796
+ (batch_size, seq_length),
797
+ inputs_embeds,
798
+ past_key_values_length,
799
+ )
800
+
801
+ hidden_states = inputs_embeds
802
+ presents = () if use_cache else None
803
+ all_attentions = () if output_attentions else None
804
+ all_hidden_states = () if output_hidden_states else None
805
+ for i, (layer, layer_past) in enumerate(zip(self.layers, past_key_values)):
806
+ if output_hidden_states:
807
+ all_hidden_states = all_hidden_states + (hidden_states,)
808
+ outputs = layer(
809
+ hidden_states,
810
+ attention_mask=attention_mask,
811
+ head_mask=head_mask[i],
812
+ layer_past=layer_past,
813
+ use_cache=use_cache,
814
+ output_attentions=output_attentions,
815
+ )
816
+ hidden_states = outputs[0]
817
+ if use_cache is True:
818
+ presents = presents + (outputs[1],)
819
+ if output_attentions:
820
+ all_attentions = all_attentions + \
821
+ (outputs[2 if use_cache else 1],)
822
+
823
+ hidden_states = self.final_layer_norm(hidden_states)
824
+ # Add last hidden state
825
+ if output_hidden_states:
826
+ all_hidden_states = all_hidden_states + (hidden_states,)
827
+
828
+ if not return_dict:
829
+ return tuple(
830
+ v
831
+ for v in [hidden_states, presents, all_hidden_states, all_attentions]
832
+ if v is not None
833
+ )
834
+
835
+ return BaseModelOutputWithPast(
836
+ last_hidden_state=hidden_states,
837
+ past_key_values=presents,
838
+ hidden_states=all_hidden_states,
839
+ attentions=all_attentions,
840
+ )
841
+
842
+
843
+ class CustomLlamaForCausalLM(CustomLlamaPreTrainedModel):
844
+ _tied_weights_keys = ["embed_out.weight"]
845
+ _keys_to_ignore_on_load_unexpected = [
846
+ r"lm.layers.\d+.attention.rotary_emb.inv_freq"
847
+ ]
848
+
849
+ def __init__(self, config):
850
+ super().__init__(config)
851
+
852
+ self.lm = CustomLlamaModel(config)
853
+ self.embed_out = nn.Linear(
854
+ config.hidden_size, config.vocab_size, bias=False)
855
+
856
+ # Initialize weights and apply final processing
857
+ self.post_init()
858
+
859
+ def get_output_embeddings(self):
860
+ return self.embed_out
861
+
862
+ def set_output_embeddings(self, new_embeddings):
863
+ self.embed_out = new_embeddings
864
+
865
+ def forward(
866
+ self,
867
+ input_ids: Optional[torch.LongTensor] = None,
868
+ attention_mask: Optional[torch.FloatTensor] = None,
869
+ inputs_embeds: Optional[torch.FloatTensor] = None,
870
+ head_mask: Optional[torch.FloatTensor] = None,
871
+ past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
872
+ labels: Optional[torch.LongTensor] = None,
873
+ use_cache: Optional[bool] = None,
874
+ output_attentions: Optional[bool] = None,
875
+ output_hidden_states: Optional[bool] = None,
876
+ return_dict: Optional[bool] = None,
877
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
878
+ r"""
879
+ past_key_values (`tuple(tuple(torch.FloatTensor))`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
880
+ Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
881
+ `(batch_size, num_heads, sequence_length, embed_size_per_head)`) and 2 additional tensors of shape
882
+ `(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)`. The two additional tensors are
883
+ only required when the model is used as a decoder in a Sequence to Sequence model.
884
+
885
+ Contains pre-computed hidden-states (key and values in the self-attention blocks that can be used (see
886
+ `past_key_values` input) to speed up sequential decoding.
887
+
888
+ If `past_key_values` are used, the user can optionally input only the last `decoder_input_ids` (those that
889
+ don't have their past key value states given to this model) of shape `(batch_size, 1)` instead of all
890
+ `decoder_input_ids` of shape `(batch_size, sequence_length)`.
891
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
892
+ Labels for computing the left-to-right language modeling loss (next word prediction). Indices should be in
893
+ `[-100, 0, ..., config.vocab_size]` (see `input_ids` docstring) Tokens with indices set to `-100` are
894
+ ignored (masked), the loss is only computed for the tokens with labels n `[0, ..., config.vocab_size]`.
895
+ use_cache (`bool`, *optional*):
896
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
897
+ `past_key_values`).
898
+
899
+ ```"""
900
+ return_dict = (
901
+ return_dict if return_dict is not None else self.config.use_return_dict
902
+ )
903
+
904
+ outputs = self.lm(
905
+ input_ids,
906
+ attention_mask=attention_mask,
907
+ head_mask=head_mask,
908
+ inputs_embeds=inputs_embeds,
909
+ past_key_values=past_key_values,
910
+ use_cache=use_cache,
911
+ output_attentions=output_attentions,
912
+ output_hidden_states=output_hidden_states,
913
+ return_dict=return_dict,
914
+ )
915
+
916
+ hidden_states = outputs[0]
917
+ lm_logits = self.embed_out(hidden_states)
918
+
919
+ lm_loss = None
920
+ if labels is not None:
921
+ # we are doing next-token prediction; shift prediction scores and input ids by one
922
+ shift_logits = lm_logits[:, :-1, :].contiguous()
923
+ labels = labels[:, 1:].contiguous()
924
+ loss_fct = CrossEntropyLoss()
925
+ lm_loss = loss_fct(
926
+ shift_logits.view(-1, shift_logits.size(-1)), labels.view(-1)
927
+ )
928
+
929
+ if not return_dict:
930
+ output = (lm_logits,) + outputs[1:]
931
+ return ((lm_loss,) + output) if lm_loss is not None else output
932
+
933
+ return CausalLMOutputWithPast(
934
+ loss=lm_loss,
935
+ logits=lm_logits,
936
+ past_key_values=outputs.past_key_values,
937
+ hidden_states=outputs.hidden_states,
938
+ attentions=outputs.attentions,
939
+ )
940
+
941
+ def prepare_inputs_for_generation(
942
+ self, input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, **model_kwargs
943
+ ):
944
+ input_shape = input_ids.shape
945
+
946
+ # if model is used as a decoder in encoder-decoder model, the decoder attention mask is created on the fly
947
+ if attention_mask is None:
948
+ attention_mask = input_ids.new_ones(input_shape)
949
+
950
+ # cut decoder_input_ids if past is used
951
+ if past_key_values and past_key_values[0] is not None:
952
+ input_ids = input_ids[:, -1:]
953
+
954
+ if inputs_embeds is not None and past_key_values is None:
955
+ model_inputs = {"inputs_embeds": inputs_embeds}
956
+ else:
957
+ model_inputs = {"input_ids": input_ids}
958
+
959
+ model_inputs.update(
960
+ {
961
+ "attention_mask": attention_mask,
962
+ "past_key_values": past_key_values
963
+ }
964
+ )
965
+
966
+ return model_inputs
967
+
968
+ def _reorder_cache(self, past_key_values, beam_idx):
969
+ reordered_past = ()
970
+ for layer_past in past_key_values:
971
+ reordered_past += (
972
+ tuple(
973
+ past_state.index_select(0, beam_idx)
974
+ for past_state in layer_past[:2]
975
+ )
976
+ + layer_past[2:],
977
+ )
978
+ return reordered_past
modeling_pointsv15_chat.py ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List, Optional, Tuple
2
+
3
+ import numpy as np
4
+ import torch
5
+ from PIL import Image
6
+ from transformers import GenerationMixin, PreTrainedModel, PreTrainedTokenizer
7
+
8
+ try:
9
+ from transformers.models.qwen2_vl.image_processing_qwen2_vl import ( # noqa
10
+ Qwen2VLImageProcessor,
11
+ )
12
+ from transformers.models.qwen2_vl.modeling_qwen2_vl import PatchMerger
13
+ except ImportError:
14
+ print('Please upgrade transformers to version 4.46.3 or higher')
15
+
16
+ from .configuration_pointsv15_chat import POINTSV15ChatConfig
17
+ from .modeling_llama import CustomLlamaForCausalLM
18
+
19
+ try:
20
+ from wepoints.models import Qwen2VisionTransformerForNavitPOINTS
21
+ except ImportError:
22
+ print('Please install WePOINTS, and refer to https://github.com/WePOINTS/WePOINTS')
23
+
24
+
25
+ class POINTSV15ChatModel(PreTrainedModel, GenerationMixin):
26
+ config_class = POINTSV15ChatConfig
27
+ _no_split_modules = ["CustomLlamaLayer",
28
+ "Qwen2VisionTransformerPretrainedModel"]
29
+
30
+ """Chat model for POINTSv1.5.
31
+
32
+ Args:
33
+ config (POINTSChatConfigV15): The model config.
34
+ """
35
+
36
+ def __init__(self, config: POINTSV15ChatConfig) -> None:
37
+ super().__init__(config)
38
+ self.llm = CustomLlamaForCausalLM(config.llm_config)
39
+ self.vision_encoder = Qwen2VisionTransformerForNavitPOINTS._from_config( # noqa
40
+ config.vision_config, attn_implementation="flash_attention_2"
41
+ )
42
+ self.vision_projector = PatchMerger(config.llm_config.hidden_size,
43
+ context_dim=1280)
44
+
45
+ def process_images(self, images: torch.Tensor,
46
+ image_grid_thws: List[list]) -> torch.Tensor:
47
+ """Obtain image features from the vision encoder.
48
+
49
+ Args:
50
+ images (torch.Tensor): The input images.
51
+ image_grid_thws (List[list]): The grid thresholds for the images.
52
+
53
+ Returns:
54
+ torch.Tensor: The image features.
55
+ """
56
+ image_features = self.vision_encoder(images, grid_thw=image_grid_thws)
57
+ image_features = self.vision_projector(image_features)
58
+ return image_features
59
+
60
+ def construct_prompt(self, messages: List[dict],
61
+ image_processor: Qwen2VLImageProcessor) -> Tuple[str, List[Image.Image], List[list]]: # noqa
62
+ """Construct the prompt for the chat model.
63
+
64
+ Args:
65
+ messages (List[dict]): The input messages.
66
+
67
+ Returns:
68
+ Tuple[str, List[Image.Image], List[list]]:
69
+ The prompt, images, and image grid shape.
70
+ """
71
+ images = []
72
+ image_grid_thws = []
73
+ reconstructed_messages = []
74
+ for message in messages:
75
+ role = message['role']
76
+ content_from_role = ''
77
+ for item in message['content']:
78
+ if item['type'] == 'text':
79
+ content_from_role += item['text']
80
+ elif item['type'] == 'image':
81
+ image_path = item['image']
82
+ image = Image.open(image_path).convert('RGB')
83
+ image_data = image_processor(images=image)
84
+ pixel_values = image_data['pixel_values']
85
+ image_grid_thw = image_data['image_grid_thw']
86
+ images.extend(pixel_values)
87
+ image_grid_thws.append(image_grid_thw)
88
+ seq_len = int(image_grid_thw[0][1] * image_grid_thw[0][2] / 4) # noqa
89
+ content_from_role += '<|vision_start|>' + '<|image_pad|>' * seq_len + '<|vision_end|>' + '\n' # noqa
90
+ reconstructed_messages.append({
91
+ 'role': role,
92
+ 'content': content_from_role
93
+ })
94
+ prompt = self.apply_chat_template(reconstructed_messages)
95
+ return prompt, images, image_grid_thws
96
+
97
+ def apply_chat_template(self, messages: List[dict]) -> str:
98
+ """Apply the chat template to the input messages.
99
+
100
+ Args:
101
+ messages (List[dict]): The input messages.
102
+
103
+ Returns:
104
+ str: The prompt.
105
+ """
106
+ role_prefix_mapping = {
107
+ 'user': '<|im_start|>user\n',
108
+ 'assistant': '<|im_start|>assistant\n'
109
+ }
110
+ role = 'user'
111
+ prompt = ''
112
+ for message in messages:
113
+ role = message['role']
114
+ content = message['content']
115
+ prompt += role_prefix_mapping[role] + content + '<|im_end|>\n'
116
+ if role == 'user':
117
+ prompt += '<|im_start|>assistant\n'
118
+ return prompt
119
+
120
+ @torch.no_grad()
121
+ def chat(self,
122
+ messages: List[dict],
123
+ tokenizer: PreTrainedTokenizer,
124
+ image_processor: object,
125
+ generation_config: dict = None) -> str:
126
+ """Generate a response to the input prompt.
127
+
128
+ Args:
129
+ messages (List[dict]): The input messages.
130
+ tokenizer (PreTrainedTokenizer): The tokenizer to use.
131
+ image_processor (object): The image processor to use.
132
+ generation_config (dict, optional): The generation config.
133
+ Defaults to None.
134
+ Returns:
135
+ str: The generated response.
136
+ """
137
+ prompt, images, image_grid_thws = self.construct_prompt(
138
+ messages, image_processor
139
+ )
140
+ images = np.array(images)
141
+ images = torch.from_numpy(images).to(self.vision_encoder.device).to(self.vision_encoder.dtype) # noqa
142
+ image_grid_thws = np.concatenate(image_grid_thws, axis=0)
143
+ image_grid_thws = (
144
+ torch.from_numpy(image_grid_thws)
145
+ .cuda()
146
+ .long()
147
+ )
148
+ image_features = self.vision_encoder(images, grid_thw=image_grid_thws)
149
+ image_features = self.vision_projector(image_features)
150
+ model_inputs = tokenizer(prompt, return_tensors='pt')
151
+ input_ids = model_inputs['input_ids'].to(self.device)
152
+ attention_mask = model_inputs['attention_mask'].to(self.device)
153
+ # stop token
154
+ eos_token_id = tokenizer.convert_tokens_to_ids("<|im_end|>")
155
+ # image token
156
+ image_token_id = tokenizer.convert_tokens_to_ids("<|image_pad|>")
157
+ generation_config.update(
158
+ {
159
+ 'eos_token_id': eos_token_id,
160
+ }
161
+ )
162
+ outputs = self.generate(
163
+ input_ids=input_ids,
164
+ image_grid_thws=image_grid_thws,
165
+ attention_mask=attention_mask,
166
+ image_features=[image_features],
167
+ image_token_id=image_token_id,
168
+ **generation_config
169
+ )
170
+ response = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
171
+ return response
172
+
173
+ def _split_input_ids(self, input_ids, special_token):
174
+ special_pos = input_ids == special_token
175
+ pos = (special_pos[:-1] != special_pos[1:]).nonzero() + 1
176
+ if pos.shape[0] % 2 != 0:
177
+ pos = torch.cat([torch.tensor([[0]]).to(pos.device), pos])
178
+ pos = pos.reshape(-1, 2).tolist()
179
+ return pos
180
+
181
+ def generate(self,
182
+ input_ids: torch.LongTensor,
183
+ image_grid_thws: torch.LongTensor,
184
+ attention_mask: torch.LongTensor,
185
+ image_features: List[torch.Tensor],
186
+ image_token_id: int,
187
+ generation_config: Optional[dict] = None,
188
+ output_hidden_states: Optional[bool] = None,
189
+ return_dict: Optional[bool] = None,
190
+ **generate_kwargs) -> torch.LongTensor:
191
+ input_embeddings = self.llm.lm.embed_in(input_ids)
192
+ batch_size = input_ids.shape[0]
193
+ assert len(image_features) == batch_size
194
+ for i in range(batch_size):
195
+ pos = self._split_input_ids(input_ids[i], image_token_id)
196
+ assert len(pos) == len(image_grid_thws)
197
+ image_pos = [
198
+ int(image_grid_thw[1] * image_grid_thw[2] / 4)
199
+ for image_grid_thw in image_grid_thws
200
+ ]
201
+ image_pos.insert(0, 0)
202
+ image_pos = np.cumsum(image_pos)
203
+ for j, (start, end) in enumerate(pos):
204
+ input_embeddings[i, start:end] = \
205
+ image_features[i][image_pos[j]:image_pos[j+1]]
206
+ outputs = self.llm.generate(
207
+ inputs_embeds=input_embeddings,
208
+ attention_mask=attention_mask,
209
+ generation_config=generation_config,
210
+ output_hidden_states=output_hidden_states,
211
+ return_dict=return_dict,
212
+ use_cache=True,
213
+ **generate_kwargs
214
+ )
215
+ return outputs
preprocessor_config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "resample": 3,
22
+ "rescale_factor": 0.00392156862745098,
23
+ "size": {
24
+ "max_pixels": 12845056,
25
+ "min_pixels": 3136
26
+ },
27
+ "temporal_patch_size": 2
28
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ }
181
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0]['role'] == 'system' %}\n {{- messages[0]['content'] }}\n {%- else %}\n {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}\n {%- endif %}\n {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0]['role'] == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + message.content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n",
199
+ "clean_up_tokenization_spaces": false,
200
+ "eos_token": "<|im_end|>",
201
+ "errors": "replace",
202
+ "model_max_length": 131072,
203
+ "pad_token": "<|endoftext|>",
204
+ "split_special_tokens": false,
205
+ "tokenizer_class": "Qwen2Tokenizer",
206
+ "unk_token": null
207
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff