guanwenyu1995 commited on
Commit
ac7dbbf
·
verified ·
1 Parent(s): 46937b3

Upload 12 files

Browse files
added_tokens.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "<|execute_end|>": 73444,
3
+ "<|execute_start|>": 73443,
4
+ "<|fim_middle|>": 73446,
5
+ "<|fim_prefix|>": 73445,
6
+ "<|fim_suffix|>": 73447,
7
+ "<|im_end|>": 73440,
8
+ "<|im_start|>": 73441,
9
+ "<|tool_call|>": 73442
10
+ }
chat_template.jinja ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {% for message in messages %}{{'<|im_start|>' + message['role'] + '
2
+ ' + message['content'] + '<|im_end|>' + '
3
+ '}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant
4
+ ' }}{% if enable_thinking is defined and enable_thinking is false %}{{ '<think>
5
+
6
+ </think>
7
+ ' }}{% endif %}{% endif %}
config.json ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "MiniCPMForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_minicpm.MiniCPMConfig",
9
+ "AutoModel": "modeling_minicpm.MiniCPMModel",
10
+ "AutoModelForCausalLM": "modeling_minicpm.MiniCPMForCausalLM",
11
+ "AutoModelForSeq2SeqLM": "modeling_minicpm.MiniCPMForCausalLM",
12
+ "AutoModelForSequenceClassification": "modeling_minicpm.MiniCPMForSequenceClassification"
13
+ },
14
+ "bos_token_id": 1,
15
+ "dim_model_base": 256,
16
+ "eos_token_id": 73440,
17
+ "head_dim": 128,
18
+ "hidden_act": "silu",
19
+ "hidden_size": 4096,
20
+ "initializer_range": 0.1,
21
+ "intermediate_size": 16384,
22
+ "max_position_embeddings": 65536,
23
+ "mlp_bias": false,
24
+ "model_type": "minicpm",
25
+ "num_attention_heads": 32,
26
+ "num_hidden_layers": 32,
27
+ "num_key_value_heads": 2,
28
+ "pad_token_id": 73440,
29
+ "pretraining_tp": 1,
30
+ "quantization": {
31
+ "group_size": 64,
32
+ "bits": 4
33
+ },
34
+ "quantization_config": {
35
+ "group_size": 64,
36
+ "bits": 4
37
+ },
38
+ "rms_norm_eps": 1e-06,
39
+ "rope_scaling": {
40
+ "factor": 1.0,
41
+ "long_factor": [
42
+ 0.9982316082870437,
43
+ 1.033048153422584,
44
+ 1.0749920956484724,
45
+ 1.1255096879436193,
46
+ 1.1863348602111476,
47
+ 1.259543828902579,
48
+ 1.3476188888731149,
49
+ 1.4535223827776373,
50
+ 1.5807816745852985,
51
+ 1.7335856049489526,
52
+ 1.9168922912975785,
53
+ 2.1365471404135326,
54
+ 2.3994084200118646,
55
+ 2.713475511863602,
56
+ 3.0880118452194134,
57
+ 3.533650295140154,
58
+ 4.062463396503134,
59
+ 4.687974098908333,
60
+ 5.425075306704039,
61
+ 6.289818967956352,
62
+ 7.29902962722721,
63
+ 8.469695779093664,
64
+ 9.81809877306655,
65
+ 11.358657902065282,
66
+ 13.102505860712087,
67
+ 15.055862949967128,
68
+ 17.218348131364184,
69
+ 19.581439255386453,
70
+ 22.127353314656723,
71
+ 24.828633849376587,
72
+ 27.6486820771775,
73
+ 30.54334096108829,
74
+ 33.46345345363812,
75
+ 36.358112337548896,
76
+ 39.17816056534983,
77
+ 41.879441100069684,
78
+ 44.425355159339965,
79
+ 46.78844628336223,
80
+ 48.95093146475928,
81
+ 50.90428855401433,
82
+ 52.648136512661125,
83
+ 54.18869564165987,
84
+ 55.537098635632745,
85
+ 56.7077647874992,
86
+ 57.71697544677006,
87
+ 58.58171910802236,
88
+ 59.31882031581807,
89
+ 59.94433101822328,
90
+ 60.47314411958625,
91
+ 60.918782569507,
92
+ 61.29331890286281,
93
+ 61.60738599471455,
94
+ 61.87024727431288,
95
+ 62.089902123428836,
96
+ 62.27320880977746,
97
+ 62.42601274014111,
98
+ 62.55327203194878,
99
+ 62.65917552585329,
100
+ 62.74725058582382,
101
+ 62.82045955451526,
102
+ 62.88128472678279,
103
+ 62.931802319077946,
104
+ 62.97374626130382,
105
+ 63.008562806439365
106
+ ],
107
+ "original_max_position_embeddings": 65536,
108
+ "rope_type": "longrope",
109
+ "short_factor": [
110
+ 0.9982316082870437,
111
+ 1.033048153422584,
112
+ 1.0749920956484724,
113
+ 1.1255096879436193,
114
+ 1.1863348602111476,
115
+ 1.259543828902579,
116
+ 1.3476188888731149,
117
+ 1.4535223827776373,
118
+ 1.5807816745852985,
119
+ 1.7335856049489526,
120
+ 1.9168922912975785,
121
+ 2.1365471404135326,
122
+ 2.3994084200118646,
123
+ 2.713475511863602,
124
+ 3.0880118452194134,
125
+ 3.533650295140154,
126
+ 4.062463396503134,
127
+ 4.687974098908333,
128
+ 5.425075306704039,
129
+ 6.289818967956352,
130
+ 7.29902962722721,
131
+ 8.469695779093664,
132
+ 9.81809877306655,
133
+ 11.358657902065282,
134
+ 13.102505860712087,
135
+ 15.055862949967128,
136
+ 17.218348131364184,
137
+ 19.581439255386453,
138
+ 22.127353314656723,
139
+ 24.828633849376587,
140
+ 27.6486820771775,
141
+ 30.54334096108829,
142
+ 33.46345345363812,
143
+ 36.358112337548896,
144
+ 39.17816056534983,
145
+ 41.879441100069684,
146
+ 44.425355159339965,
147
+ 46.78844628336223,
148
+ 48.95093146475928,
149
+ 50.90428855401433,
150
+ 52.648136512661125,
151
+ 54.18869564165987,
152
+ 55.537098635632745,
153
+ 56.7077647874992,
154
+ 57.71697544677006,
155
+ 58.58171910802236,
156
+ 59.31882031581807,
157
+ 59.94433101822328,
158
+ 60.47314411958625,
159
+ 60.918782569507,
160
+ 61.29331890286281,
161
+ 61.60738599471455,
162
+ 61.87024727431288,
163
+ 62.089902123428836,
164
+ 62.27320880977746,
165
+ 62.42601274014111,
166
+ 62.55327203194878,
167
+ 62.65917552585329,
168
+ 62.74725058582382,
169
+ 62.82045955451526,
170
+ 62.88128472678279,
171
+ 62.931802319077946,
172
+ 62.97374626130382,
173
+ 63.008562806439365
174
+ ],
175
+ "type": "longrope"
176
+ },
177
+ "rope_theta": 10000.0,
178
+ "scale_depth": 1.4,
179
+ "scale_emb": 12,
180
+ "tie_word_embeddings": false,
181
+ "torch_dtype": "bfloat16",
182
+ "transformers_version": "4.53.3",
183
+ "use_cache": true,
184
+ "vocab_size": 73448
185
+ }
configuration_minicpm.py ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
5
+ # and OPT implementations in this library. It has been modified from its
6
+ # original forms to accommodate minor architectural differences compared
7
+ # to GPT-NeoX and OPT used by the Meta AI team that trained the model.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ """ MiniCPM model configuration"""
21
+
22
+ from transformers.configuration_utils import PretrainedConfig
23
+ from transformers.utils import logging
24
+
25
+
26
+ logger = logging.get_logger(__name__)
27
+
28
+ MINICPM_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
29
+
30
+
31
+ class MiniCPMConfig(PretrainedConfig):
32
+ r"""
33
+ This is the configuration class to store the configuration of a [`MiniCPMModel`]. It is used to instantiate an MiniCPM
34
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
35
+ defaults will yield a similar configuration to that of the MiniCPM-7B.
36
+
37
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
38
+ documentation from [`PretrainedConfig`] for more information.
39
+
40
+
41
+ Args:
42
+ vocab_size (`int`, *optional*, defaults to 32000):
43
+ Vocabulary size of the MiniCPM model. Defines the number of different tokens that can be represented by the
44
+ `inputs_ids` passed when calling [`MiniCPMModel`]
45
+ hidden_size (`int`, *optional*, defaults to 4096):
46
+ Dimension of the hidden representations.
47
+ intermediate_size (`int`, *optional*, defaults to 11008):
48
+ Dimension of the MLP representations.
49
+ num_hidden_layers (`int`, *optional*, defaults to 32):
50
+ Number of hidden layers in the Transformer decoder.
51
+ num_attention_heads (`int`, *optional*, defaults to 32):
52
+ Number of attention heads for each attention layer in the Transformer decoder.
53
+ num_key_value_heads (`int`, *optional*):
54
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
55
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
56
+ `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
57
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
58
+ by meanpooling all the original heads within that group. For more details checkout [this
59
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
60
+ `num_attention_heads`.
61
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
62
+ The non-linear activation function (function or string) in the decoder.
63
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
64
+ The maximum sequence length that this model might ever be used with. MiniCPM 1 supports up to 2048 tokens,
65
+ MiniCPM 2 up to 4096, CodeMiniCPM up to 16384.
66
+ initializer_range (`float`, *optional*, defaults to 0.02):
67
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
68
+ rms_norm_eps (`float`, *optional*, defaults to 1e-06):
69
+ The epsilon used by the rms normalization layers.
70
+ use_cache (`bool`, *optional*, defaults to `True`):
71
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
72
+ relevant if `config.is_decoder=True`.
73
+ pad_token_id (`int`, *optional*):
74
+ Padding token id.
75
+ bos_token_id (`int`, *optional*, defaults to 1):
76
+ Beginning of stream token id.
77
+ eos_token_id (`int`, *optional*, defaults to 2):
78
+ End of stream token id.
79
+ pretraining_tp (`int`, *optional*, defaults to 1):
80
+ Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
81
+ document](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value is
82
+ necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
83
+ issue](https://github.com/pytorch/pytorch/issues/76232).
84
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
85
+ Whether to tie weight embeddings
86
+ rope_theta (`float`, *optional*, defaults to 10000.0):
87
+ The base period of the RoPE embeddings.
88
+ rope_scaling (`Dict`, *optional*):
89
+ Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
90
+ strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
91
+ `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
92
+ `max_position_embeddings` to the expected new maximum. See the following thread for more information on how
93
+ these scaling strategies behave:
94
+ https://www.reddit.com/r/LocalMiniCPM/comments/14mrgpr/dynamically_scaled_rope_further_increases/. This is an
95
+ experimental feature, subject to breaking API changes in future versions.
96
+ attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
97
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
98
+ attention_dropout (`float`, *optional*, defaults to 0.0):
99
+ The dropout ratio for the attention probabilities.
100
+
101
+ ```python
102
+ >>> from transformers import MiniCPMModel, MiniCPMConfig
103
+
104
+ >>> # Initializing a MiniCPM minicpm-7b style configuration
105
+ >>> configuration = MiniCPMConfig()
106
+
107
+ >>> # Initializing a model from the minicpm-7b style configuration
108
+ >>> model = MiniCPMModel(configuration)
109
+
110
+ >>> # Accessing the model configuration
111
+ >>> configuration = model.config
112
+ ```"""
113
+
114
+ model_type = "minicpm"
115
+ keys_to_ignore_at_inference = ["past_key_values"]
116
+
117
+ def __init__(
118
+ self,
119
+ vocab_size=32000,
120
+ hidden_size=4096,
121
+ intermediate_size=11008,
122
+ num_hidden_layers=32,
123
+ num_attention_heads=32,
124
+ num_key_value_heads=None,
125
+ hidden_act="silu",
126
+ max_position_embeddings=2048,
127
+ initializer_range=0.02,
128
+ rms_norm_eps=1e-6,
129
+ use_cache=True,
130
+ pad_token_id=None,
131
+ bos_token_id=1,
132
+ eos_token_id=2,
133
+ pretraining_tp=1,
134
+ tie_word_embeddings=True,
135
+ rope_theta=10000.0,
136
+ rope_scaling=None,
137
+ attention_bias=False,
138
+ attention_dropout=0.0,
139
+ scale_emb=1,
140
+ dim_model_base=1,
141
+ scale_depth=1,
142
+ **kwargs,
143
+ ):
144
+ self.vocab_size = vocab_size
145
+ self.max_position_embeddings = max_position_embeddings
146
+ self.hidden_size = hidden_size
147
+ self.intermediate_size = intermediate_size
148
+ self.num_hidden_layers = num_hidden_layers
149
+ self.num_attention_heads = num_attention_heads
150
+
151
+ # for backward compatibility
152
+ if num_key_value_heads is None:
153
+ num_key_value_heads = num_attention_heads
154
+
155
+ self.num_key_value_heads = num_key_value_heads
156
+ self.hidden_act = hidden_act
157
+ self.initializer_range = initializer_range
158
+ self.rms_norm_eps = rms_norm_eps
159
+ self.pretraining_tp = pretraining_tp
160
+ self.use_cache = use_cache
161
+ self.rope_theta = rope_theta
162
+ self.rope_scaling = rope_scaling
163
+ # self._rope_scaling_validation()
164
+ self.attention_bias = attention_bias
165
+ self.attention_dropout = attention_dropout
166
+ self.scale_emb = scale_emb
167
+ self.dim_model_base = dim_model_base
168
+ self.scale_depth = scale_depth
169
+
170
+ super().__init__(
171
+ pad_token_id=pad_token_id,
172
+ bos_token_id=bos_token_id,
173
+ eos_token_id=eos_token_id,
174
+ tie_word_embeddings=tie_word_embeddings,
175
+ **kwargs,
176
+ )
177
+ try:
178
+ import flash_attn
179
+ self._attn_implementation = "flash_attention_2"
180
+ except:
181
+ pass
182
+
183
+ def _rope_scaling_validation(self):
184
+ """
185
+ Validate the `rope_scaling` configuration.
186
+ """
187
+ if self.rope_scaling is None:
188
+ return
189
+
190
+ if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 2:
191
+ raise ValueError(
192
+ "`rope_scaling` must be a dictionary with with two fields, `type` and `factor`, "
193
+ f"got {self.rope_scaling}"
194
+ )
195
+ rope_scaling_type = self.rope_scaling.get("type", None)
196
+ rope_scaling_factor = self.rope_scaling.get("factor", None)
197
+ if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
198
+ raise ValueError(
199
+ f"`rope_scaling`'s type field must be one of ['linear', 'dynamic'], got {rope_scaling_type}"
200
+ )
201
+ if rope_scaling_factor is None or not isinstance(rope_scaling_factor, float) or rope_scaling_factor <= 1.0:
202
+ raise ValueError(f"`rope_scaling`'s factor field must be a float > 1, got {rope_scaling_factor}")
generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 1,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 2,
6
+ 73440
7
+ ],
8
+ "pad_token_id": 2,
9
+ "temperature": 0.8,
10
+ "top_p": 0.8,
11
+ "transformers_version": "4.53.3",
12
+ "trust_remote_code": true
13
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d2bccd2c57891b82cf9fc1f833579e617655670a6f11c7d3d81d88c3b0222a2
3
+ size 4604672688
model.safetensors.index.json ADDED
@@ -0,0 +1,751 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 4604588032,
4
+ "total_parameters": 8185253888
5
+ },
6
+ "weight_map": {
7
+ "lm_head.biases": "model.safetensors",
8
+ "lm_head.scales": "model.safetensors",
9
+ "lm_head.weight": "model.safetensors",
10
+ "model.embed_tokens.biases": "model.safetensors",
11
+ "model.embed_tokens.scales": "model.safetensors",
12
+ "model.embed_tokens.weight": "model.safetensors",
13
+ "model.layers.0.input_layernorm.weight": "model.safetensors",
14
+ "model.layers.0.mlp.down_proj.biases": "model.safetensors",
15
+ "model.layers.0.mlp.down_proj.scales": "model.safetensors",
16
+ "model.layers.0.mlp.down_proj.weight": "model.safetensors",
17
+ "model.layers.0.mlp.gate_proj.biases": "model.safetensors",
18
+ "model.layers.0.mlp.gate_proj.scales": "model.safetensors",
19
+ "model.layers.0.mlp.gate_proj.weight": "model.safetensors",
20
+ "model.layers.0.mlp.up_proj.biases": "model.safetensors",
21
+ "model.layers.0.mlp.up_proj.scales": "model.safetensors",
22
+ "model.layers.0.mlp.up_proj.weight": "model.safetensors",
23
+ "model.layers.0.post_attention_layernorm.weight": "model.safetensors",
24
+ "model.layers.0.self_attn.k_proj.biases": "model.safetensors",
25
+ "model.layers.0.self_attn.k_proj.scales": "model.safetensors",
26
+ "model.layers.0.self_attn.k_proj.weight": "model.safetensors",
27
+ "model.layers.0.self_attn.o_proj.biases": "model.safetensors",
28
+ "model.layers.0.self_attn.o_proj.scales": "model.safetensors",
29
+ "model.layers.0.self_attn.o_proj.weight": "model.safetensors",
30
+ "model.layers.0.self_attn.q_proj.biases": "model.safetensors",
31
+ "model.layers.0.self_attn.q_proj.scales": "model.safetensors",
32
+ "model.layers.0.self_attn.q_proj.weight": "model.safetensors",
33
+ "model.layers.0.self_attn.v_proj.biases": "model.safetensors",
34
+ "model.layers.0.self_attn.v_proj.scales": "model.safetensors",
35
+ "model.layers.0.self_attn.v_proj.weight": "model.safetensors",
36
+ "model.layers.1.input_layernorm.weight": "model.safetensors",
37
+ "model.layers.1.mlp.down_proj.biases": "model.safetensors",
38
+ "model.layers.1.mlp.down_proj.scales": "model.safetensors",
39
+ "model.layers.1.mlp.down_proj.weight": "model.safetensors",
40
+ "model.layers.1.mlp.gate_proj.biases": "model.safetensors",
41
+ "model.layers.1.mlp.gate_proj.scales": "model.safetensors",
42
+ "model.layers.1.mlp.gate_proj.weight": "model.safetensors",
43
+ "model.layers.1.mlp.up_proj.biases": "model.safetensors",
44
+ "model.layers.1.mlp.up_proj.scales": "model.safetensors",
45
+ "model.layers.1.mlp.up_proj.weight": "model.safetensors",
46
+ "model.layers.1.post_attention_layernorm.weight": "model.safetensors",
47
+ "model.layers.1.self_attn.k_proj.biases": "model.safetensors",
48
+ "model.layers.1.self_attn.k_proj.scales": "model.safetensors",
49
+ "model.layers.1.self_attn.k_proj.weight": "model.safetensors",
50
+ "model.layers.1.self_attn.o_proj.biases": "model.safetensors",
51
+ "model.layers.1.self_attn.o_proj.scales": "model.safetensors",
52
+ "model.layers.1.self_attn.o_proj.weight": "model.safetensors",
53
+ "model.layers.1.self_attn.q_proj.biases": "model.safetensors",
54
+ "model.layers.1.self_attn.q_proj.scales": "model.safetensors",
55
+ "model.layers.1.self_attn.q_proj.weight": "model.safetensors",
56
+ "model.layers.1.self_attn.v_proj.biases": "model.safetensors",
57
+ "model.layers.1.self_attn.v_proj.scales": "model.safetensors",
58
+ "model.layers.1.self_attn.v_proj.weight": "model.safetensors",
59
+ "model.layers.10.input_layernorm.weight": "model.safetensors",
60
+ "model.layers.10.mlp.down_proj.biases": "model.safetensors",
61
+ "model.layers.10.mlp.down_proj.scales": "model.safetensors",
62
+ "model.layers.10.mlp.down_proj.weight": "model.safetensors",
63
+ "model.layers.10.mlp.gate_proj.biases": "model.safetensors",
64
+ "model.layers.10.mlp.gate_proj.scales": "model.safetensors",
65
+ "model.layers.10.mlp.gate_proj.weight": "model.safetensors",
66
+ "model.layers.10.mlp.up_proj.biases": "model.safetensors",
67
+ "model.layers.10.mlp.up_proj.scales": "model.safetensors",
68
+ "model.layers.10.mlp.up_proj.weight": "model.safetensors",
69
+ "model.layers.10.post_attention_layernorm.weight": "model.safetensors",
70
+ "model.layers.10.self_attn.k_proj.biases": "model.safetensors",
71
+ "model.layers.10.self_attn.k_proj.scales": "model.safetensors",
72
+ "model.layers.10.self_attn.k_proj.weight": "model.safetensors",
73
+ "model.layers.10.self_attn.o_proj.biases": "model.safetensors",
74
+ "model.layers.10.self_attn.o_proj.scales": "model.safetensors",
75
+ "model.layers.10.self_attn.o_proj.weight": "model.safetensors",
76
+ "model.layers.10.self_attn.q_proj.biases": "model.safetensors",
77
+ "model.layers.10.self_attn.q_proj.scales": "model.safetensors",
78
+ "model.layers.10.self_attn.q_proj.weight": "model.safetensors",
79
+ "model.layers.10.self_attn.v_proj.biases": "model.safetensors",
80
+ "model.layers.10.self_attn.v_proj.scales": "model.safetensors",
81
+ "model.layers.10.self_attn.v_proj.weight": "model.safetensors",
82
+ "model.layers.11.input_layernorm.weight": "model.safetensors",
83
+ "model.layers.11.mlp.down_proj.biases": "model.safetensors",
84
+ "model.layers.11.mlp.down_proj.scales": "model.safetensors",
85
+ "model.layers.11.mlp.down_proj.weight": "model.safetensors",
86
+ "model.layers.11.mlp.gate_proj.biases": "model.safetensors",
87
+ "model.layers.11.mlp.gate_proj.scales": "model.safetensors",
88
+ "model.layers.11.mlp.gate_proj.weight": "model.safetensors",
89
+ "model.layers.11.mlp.up_proj.biases": "model.safetensors",
90
+ "model.layers.11.mlp.up_proj.scales": "model.safetensors",
91
+ "model.layers.11.mlp.up_proj.weight": "model.safetensors",
92
+ "model.layers.11.post_attention_layernorm.weight": "model.safetensors",
93
+ "model.layers.11.self_attn.k_proj.biases": "model.safetensors",
94
+ "model.layers.11.self_attn.k_proj.scales": "model.safetensors",
95
+ "model.layers.11.self_attn.k_proj.weight": "model.safetensors",
96
+ "model.layers.11.self_attn.o_proj.biases": "model.safetensors",
97
+ "model.layers.11.self_attn.o_proj.scales": "model.safetensors",
98
+ "model.layers.11.self_attn.o_proj.weight": "model.safetensors",
99
+ "model.layers.11.self_attn.q_proj.biases": "model.safetensors",
100
+ "model.layers.11.self_attn.q_proj.scales": "model.safetensors",
101
+ "model.layers.11.self_attn.q_proj.weight": "model.safetensors",
102
+ "model.layers.11.self_attn.v_proj.biases": "model.safetensors",
103
+ "model.layers.11.self_attn.v_proj.scales": "model.safetensors",
104
+ "model.layers.11.self_attn.v_proj.weight": "model.safetensors",
105
+ "model.layers.12.input_layernorm.weight": "model.safetensors",
106
+ "model.layers.12.mlp.down_proj.biases": "model.safetensors",
107
+ "model.layers.12.mlp.down_proj.scales": "model.safetensors",
108
+ "model.layers.12.mlp.down_proj.weight": "model.safetensors",
109
+ "model.layers.12.mlp.gate_proj.biases": "model.safetensors",
110
+ "model.layers.12.mlp.gate_proj.scales": "model.safetensors",
111
+ "model.layers.12.mlp.gate_proj.weight": "model.safetensors",
112
+ "model.layers.12.mlp.up_proj.biases": "model.safetensors",
113
+ "model.layers.12.mlp.up_proj.scales": "model.safetensors",
114
+ "model.layers.12.mlp.up_proj.weight": "model.safetensors",
115
+ "model.layers.12.post_attention_layernorm.weight": "model.safetensors",
116
+ "model.layers.12.self_attn.k_proj.biases": "model.safetensors",
117
+ "model.layers.12.self_attn.k_proj.scales": "model.safetensors",
118
+ "model.layers.12.self_attn.k_proj.weight": "model.safetensors",
119
+ "model.layers.12.self_attn.o_proj.biases": "model.safetensors",
120
+ "model.layers.12.self_attn.o_proj.scales": "model.safetensors",
121
+ "model.layers.12.self_attn.o_proj.weight": "model.safetensors",
122
+ "model.layers.12.self_attn.q_proj.biases": "model.safetensors",
123
+ "model.layers.12.self_attn.q_proj.scales": "model.safetensors",
124
+ "model.layers.12.self_attn.q_proj.weight": "model.safetensors",
125
+ "model.layers.12.self_attn.v_proj.biases": "model.safetensors",
126
+ "model.layers.12.self_attn.v_proj.scales": "model.safetensors",
127
+ "model.layers.12.self_attn.v_proj.weight": "model.safetensors",
128
+ "model.layers.13.input_layernorm.weight": "model.safetensors",
129
+ "model.layers.13.mlp.down_proj.biases": "model.safetensors",
130
+ "model.layers.13.mlp.down_proj.scales": "model.safetensors",
131
+ "model.layers.13.mlp.down_proj.weight": "model.safetensors",
132
+ "model.layers.13.mlp.gate_proj.biases": "model.safetensors",
133
+ "model.layers.13.mlp.gate_proj.scales": "model.safetensors",
134
+ "model.layers.13.mlp.gate_proj.weight": "model.safetensors",
135
+ "model.layers.13.mlp.up_proj.biases": "model.safetensors",
136
+ "model.layers.13.mlp.up_proj.scales": "model.safetensors",
137
+ "model.layers.13.mlp.up_proj.weight": "model.safetensors",
138
+ "model.layers.13.post_attention_layernorm.weight": "model.safetensors",
139
+ "model.layers.13.self_attn.k_proj.biases": "model.safetensors",
140
+ "model.layers.13.self_attn.k_proj.scales": "model.safetensors",
141
+ "model.layers.13.self_attn.k_proj.weight": "model.safetensors",
142
+ "model.layers.13.self_attn.o_proj.biases": "model.safetensors",
143
+ "model.layers.13.self_attn.o_proj.scales": "model.safetensors",
144
+ "model.layers.13.self_attn.o_proj.weight": "model.safetensors",
145
+ "model.layers.13.self_attn.q_proj.biases": "model.safetensors",
146
+ "model.layers.13.self_attn.q_proj.scales": "model.safetensors",
147
+ "model.layers.13.self_attn.q_proj.weight": "model.safetensors",
148
+ "model.layers.13.self_attn.v_proj.biases": "model.safetensors",
149
+ "model.layers.13.self_attn.v_proj.scales": "model.safetensors",
150
+ "model.layers.13.self_attn.v_proj.weight": "model.safetensors",
151
+ "model.layers.14.input_layernorm.weight": "model.safetensors",
152
+ "model.layers.14.mlp.down_proj.biases": "model.safetensors",
153
+ "model.layers.14.mlp.down_proj.scales": "model.safetensors",
154
+ "model.layers.14.mlp.down_proj.weight": "model.safetensors",
155
+ "model.layers.14.mlp.gate_proj.biases": "model.safetensors",
156
+ "model.layers.14.mlp.gate_proj.scales": "model.safetensors",
157
+ "model.layers.14.mlp.gate_proj.weight": "model.safetensors",
158
+ "model.layers.14.mlp.up_proj.biases": "model.safetensors",
159
+ "model.layers.14.mlp.up_proj.scales": "model.safetensors",
160
+ "model.layers.14.mlp.up_proj.weight": "model.safetensors",
161
+ "model.layers.14.post_attention_layernorm.weight": "model.safetensors",
162
+ "model.layers.14.self_attn.k_proj.biases": "model.safetensors",
163
+ "model.layers.14.self_attn.k_proj.scales": "model.safetensors",
164
+ "model.layers.14.self_attn.k_proj.weight": "model.safetensors",
165
+ "model.layers.14.self_attn.o_proj.biases": "model.safetensors",
166
+ "model.layers.14.self_attn.o_proj.scales": "model.safetensors",
167
+ "model.layers.14.self_attn.o_proj.weight": "model.safetensors",
168
+ "model.layers.14.self_attn.q_proj.biases": "model.safetensors",
169
+ "model.layers.14.self_attn.q_proj.scales": "model.safetensors",
170
+ "model.layers.14.self_attn.q_proj.weight": "model.safetensors",
171
+ "model.layers.14.self_attn.v_proj.biases": "model.safetensors",
172
+ "model.layers.14.self_attn.v_proj.scales": "model.safetensors",
173
+ "model.layers.14.self_attn.v_proj.weight": "model.safetensors",
174
+ "model.layers.15.input_layernorm.weight": "model.safetensors",
175
+ "model.layers.15.mlp.down_proj.biases": "model.safetensors",
176
+ "model.layers.15.mlp.down_proj.scales": "model.safetensors",
177
+ "model.layers.15.mlp.down_proj.weight": "model.safetensors",
178
+ "model.layers.15.mlp.gate_proj.biases": "model.safetensors",
179
+ "model.layers.15.mlp.gate_proj.scales": "model.safetensors",
180
+ "model.layers.15.mlp.gate_proj.weight": "model.safetensors",
181
+ "model.layers.15.mlp.up_proj.biases": "model.safetensors",
182
+ "model.layers.15.mlp.up_proj.scales": "model.safetensors",
183
+ "model.layers.15.mlp.up_proj.weight": "model.safetensors",
184
+ "model.layers.15.post_attention_layernorm.weight": "model.safetensors",
185
+ "model.layers.15.self_attn.k_proj.biases": "model.safetensors",
186
+ "model.layers.15.self_attn.k_proj.scales": "model.safetensors",
187
+ "model.layers.15.self_attn.k_proj.weight": "model.safetensors",
188
+ "model.layers.15.self_attn.o_proj.biases": "model.safetensors",
189
+ "model.layers.15.self_attn.o_proj.scales": "model.safetensors",
190
+ "model.layers.15.self_attn.o_proj.weight": "model.safetensors",
191
+ "model.layers.15.self_attn.q_proj.biases": "model.safetensors",
192
+ "model.layers.15.self_attn.q_proj.scales": "model.safetensors",
193
+ "model.layers.15.self_attn.q_proj.weight": "model.safetensors",
194
+ "model.layers.15.self_attn.v_proj.biases": "model.safetensors",
195
+ "model.layers.15.self_attn.v_proj.scales": "model.safetensors",
196
+ "model.layers.15.self_attn.v_proj.weight": "model.safetensors",
197
+ "model.layers.16.input_layernorm.weight": "model.safetensors",
198
+ "model.layers.16.mlp.down_proj.biases": "model.safetensors",
199
+ "model.layers.16.mlp.down_proj.scales": "model.safetensors",
200
+ "model.layers.16.mlp.down_proj.weight": "model.safetensors",
201
+ "model.layers.16.mlp.gate_proj.biases": "model.safetensors",
202
+ "model.layers.16.mlp.gate_proj.scales": "model.safetensors",
203
+ "model.layers.16.mlp.gate_proj.weight": "model.safetensors",
204
+ "model.layers.16.mlp.up_proj.biases": "model.safetensors",
205
+ "model.layers.16.mlp.up_proj.scales": "model.safetensors",
206
+ "model.layers.16.mlp.up_proj.weight": "model.safetensors",
207
+ "model.layers.16.post_attention_layernorm.weight": "model.safetensors",
208
+ "model.layers.16.self_attn.k_proj.biases": "model.safetensors",
209
+ "model.layers.16.self_attn.k_proj.scales": "model.safetensors",
210
+ "model.layers.16.self_attn.k_proj.weight": "model.safetensors",
211
+ "model.layers.16.self_attn.o_proj.biases": "model.safetensors",
212
+ "model.layers.16.self_attn.o_proj.scales": "model.safetensors",
213
+ "model.layers.16.self_attn.o_proj.weight": "model.safetensors",
214
+ "model.layers.16.self_attn.q_proj.biases": "model.safetensors",
215
+ "model.layers.16.self_attn.q_proj.scales": "model.safetensors",
216
+ "model.layers.16.self_attn.q_proj.weight": "model.safetensors",
217
+ "model.layers.16.self_attn.v_proj.biases": "model.safetensors",
218
+ "model.layers.16.self_attn.v_proj.scales": "model.safetensors",
219
+ "model.layers.16.self_attn.v_proj.weight": "model.safetensors",
220
+ "model.layers.17.input_layernorm.weight": "model.safetensors",
221
+ "model.layers.17.mlp.down_proj.biases": "model.safetensors",
222
+ "model.layers.17.mlp.down_proj.scales": "model.safetensors",
223
+ "model.layers.17.mlp.down_proj.weight": "model.safetensors",
224
+ "model.layers.17.mlp.gate_proj.biases": "model.safetensors",
225
+ "model.layers.17.mlp.gate_proj.scales": "model.safetensors",
226
+ "model.layers.17.mlp.gate_proj.weight": "model.safetensors",
227
+ "model.layers.17.mlp.up_proj.biases": "model.safetensors",
228
+ "model.layers.17.mlp.up_proj.scales": "model.safetensors",
229
+ "model.layers.17.mlp.up_proj.weight": "model.safetensors",
230
+ "model.layers.17.post_attention_layernorm.weight": "model.safetensors",
231
+ "model.layers.17.self_attn.k_proj.biases": "model.safetensors",
232
+ "model.layers.17.self_attn.k_proj.scales": "model.safetensors",
233
+ "model.layers.17.self_attn.k_proj.weight": "model.safetensors",
234
+ "model.layers.17.self_attn.o_proj.biases": "model.safetensors",
235
+ "model.layers.17.self_attn.o_proj.scales": "model.safetensors",
236
+ "model.layers.17.self_attn.o_proj.weight": "model.safetensors",
237
+ "model.layers.17.self_attn.q_proj.biases": "model.safetensors",
238
+ "model.layers.17.self_attn.q_proj.scales": "model.safetensors",
239
+ "model.layers.17.self_attn.q_proj.weight": "model.safetensors",
240
+ "model.layers.17.self_attn.v_proj.biases": "model.safetensors",
241
+ "model.layers.17.self_attn.v_proj.scales": "model.safetensors",
242
+ "model.layers.17.self_attn.v_proj.weight": "model.safetensors",
243
+ "model.layers.18.input_layernorm.weight": "model.safetensors",
244
+ "model.layers.18.mlp.down_proj.biases": "model.safetensors",
245
+ "model.layers.18.mlp.down_proj.scales": "model.safetensors",
246
+ "model.layers.18.mlp.down_proj.weight": "model.safetensors",
247
+ "model.layers.18.mlp.gate_proj.biases": "model.safetensors",
248
+ "model.layers.18.mlp.gate_proj.scales": "model.safetensors",
249
+ "model.layers.18.mlp.gate_proj.weight": "model.safetensors",
250
+ "model.layers.18.mlp.up_proj.biases": "model.safetensors",
251
+ "model.layers.18.mlp.up_proj.scales": "model.safetensors",
252
+ "model.layers.18.mlp.up_proj.weight": "model.safetensors",
253
+ "model.layers.18.post_attention_layernorm.weight": "model.safetensors",
254
+ "model.layers.18.self_attn.k_proj.biases": "model.safetensors",
255
+ "model.layers.18.self_attn.k_proj.scales": "model.safetensors",
256
+ "model.layers.18.self_attn.k_proj.weight": "model.safetensors",
257
+ "model.layers.18.self_attn.o_proj.biases": "model.safetensors",
258
+ "model.layers.18.self_attn.o_proj.scales": "model.safetensors",
259
+ "model.layers.18.self_attn.o_proj.weight": "model.safetensors",
260
+ "model.layers.18.self_attn.q_proj.biases": "model.safetensors",
261
+ "model.layers.18.self_attn.q_proj.scales": "model.safetensors",
262
+ "model.layers.18.self_attn.q_proj.weight": "model.safetensors",
263
+ "model.layers.18.self_attn.v_proj.biases": "model.safetensors",
264
+ "model.layers.18.self_attn.v_proj.scales": "model.safetensors",
265
+ "model.layers.18.self_attn.v_proj.weight": "model.safetensors",
266
+ "model.layers.19.input_layernorm.weight": "model.safetensors",
267
+ "model.layers.19.mlp.down_proj.biases": "model.safetensors",
268
+ "model.layers.19.mlp.down_proj.scales": "model.safetensors",
269
+ "model.layers.19.mlp.down_proj.weight": "model.safetensors",
270
+ "model.layers.19.mlp.gate_proj.biases": "model.safetensors",
271
+ "model.layers.19.mlp.gate_proj.scales": "model.safetensors",
272
+ "model.layers.19.mlp.gate_proj.weight": "model.safetensors",
273
+ "model.layers.19.mlp.up_proj.biases": "model.safetensors",
274
+ "model.layers.19.mlp.up_proj.scales": "model.safetensors",
275
+ "model.layers.19.mlp.up_proj.weight": "model.safetensors",
276
+ "model.layers.19.post_attention_layernorm.weight": "model.safetensors",
277
+ "model.layers.19.self_attn.k_proj.biases": "model.safetensors",
278
+ "model.layers.19.self_attn.k_proj.scales": "model.safetensors",
279
+ "model.layers.19.self_attn.k_proj.weight": "model.safetensors",
280
+ "model.layers.19.self_attn.o_proj.biases": "model.safetensors",
281
+ "model.layers.19.self_attn.o_proj.scales": "model.safetensors",
282
+ "model.layers.19.self_attn.o_proj.weight": "model.safetensors",
283
+ "model.layers.19.self_attn.q_proj.biases": "model.safetensors",
284
+ "model.layers.19.self_attn.q_proj.scales": "model.safetensors",
285
+ "model.layers.19.self_attn.q_proj.weight": "model.safetensors",
286
+ "model.layers.19.self_attn.v_proj.biases": "model.safetensors",
287
+ "model.layers.19.self_attn.v_proj.scales": "model.safetensors",
288
+ "model.layers.19.self_attn.v_proj.weight": "model.safetensors",
289
+ "model.layers.2.input_layernorm.weight": "model.safetensors",
290
+ "model.layers.2.mlp.down_proj.biases": "model.safetensors",
291
+ "model.layers.2.mlp.down_proj.scales": "model.safetensors",
292
+ "model.layers.2.mlp.down_proj.weight": "model.safetensors",
293
+ "model.layers.2.mlp.gate_proj.biases": "model.safetensors",
294
+ "model.layers.2.mlp.gate_proj.scales": "model.safetensors",
295
+ "model.layers.2.mlp.gate_proj.weight": "model.safetensors",
296
+ "model.layers.2.mlp.up_proj.biases": "model.safetensors",
297
+ "model.layers.2.mlp.up_proj.scales": "model.safetensors",
298
+ "model.layers.2.mlp.up_proj.weight": "model.safetensors",
299
+ "model.layers.2.post_attention_layernorm.weight": "model.safetensors",
300
+ "model.layers.2.self_attn.k_proj.biases": "model.safetensors",
301
+ "model.layers.2.self_attn.k_proj.scales": "model.safetensors",
302
+ "model.layers.2.self_attn.k_proj.weight": "model.safetensors",
303
+ "model.layers.2.self_attn.o_proj.biases": "model.safetensors",
304
+ "model.layers.2.self_attn.o_proj.scales": "model.safetensors",
305
+ "model.layers.2.self_attn.o_proj.weight": "model.safetensors",
306
+ "model.layers.2.self_attn.q_proj.biases": "model.safetensors",
307
+ "model.layers.2.self_attn.q_proj.scales": "model.safetensors",
308
+ "model.layers.2.self_attn.q_proj.weight": "model.safetensors",
309
+ "model.layers.2.self_attn.v_proj.biases": "model.safetensors",
310
+ "model.layers.2.self_attn.v_proj.scales": "model.safetensors",
311
+ "model.layers.2.self_attn.v_proj.weight": "model.safetensors",
312
+ "model.layers.20.input_layernorm.weight": "model.safetensors",
313
+ "model.layers.20.mlp.down_proj.biases": "model.safetensors",
314
+ "model.layers.20.mlp.down_proj.scales": "model.safetensors",
315
+ "model.layers.20.mlp.down_proj.weight": "model.safetensors",
316
+ "model.layers.20.mlp.gate_proj.biases": "model.safetensors",
317
+ "model.layers.20.mlp.gate_proj.scales": "model.safetensors",
318
+ "model.layers.20.mlp.gate_proj.weight": "model.safetensors",
319
+ "model.layers.20.mlp.up_proj.biases": "model.safetensors",
320
+ "model.layers.20.mlp.up_proj.scales": "model.safetensors",
321
+ "model.layers.20.mlp.up_proj.weight": "model.safetensors",
322
+ "model.layers.20.post_attention_layernorm.weight": "model.safetensors",
323
+ "model.layers.20.self_attn.k_proj.biases": "model.safetensors",
324
+ "model.layers.20.self_attn.k_proj.scales": "model.safetensors",
325
+ "model.layers.20.self_attn.k_proj.weight": "model.safetensors",
326
+ "model.layers.20.self_attn.o_proj.biases": "model.safetensors",
327
+ "model.layers.20.self_attn.o_proj.scales": "model.safetensors",
328
+ "model.layers.20.self_attn.o_proj.weight": "model.safetensors",
329
+ "model.layers.20.self_attn.q_proj.biases": "model.safetensors",
330
+ "model.layers.20.self_attn.q_proj.scales": "model.safetensors",
331
+ "model.layers.20.self_attn.q_proj.weight": "model.safetensors",
332
+ "model.layers.20.self_attn.v_proj.biases": "model.safetensors",
333
+ "model.layers.20.self_attn.v_proj.scales": "model.safetensors",
334
+ "model.layers.20.self_attn.v_proj.weight": "model.safetensors",
335
+ "model.layers.21.input_layernorm.weight": "model.safetensors",
336
+ "model.layers.21.mlp.down_proj.biases": "model.safetensors",
337
+ "model.layers.21.mlp.down_proj.scales": "model.safetensors",
338
+ "model.layers.21.mlp.down_proj.weight": "model.safetensors",
339
+ "model.layers.21.mlp.gate_proj.biases": "model.safetensors",
340
+ "model.layers.21.mlp.gate_proj.scales": "model.safetensors",
341
+ "model.layers.21.mlp.gate_proj.weight": "model.safetensors",
342
+ "model.layers.21.mlp.up_proj.biases": "model.safetensors",
343
+ "model.layers.21.mlp.up_proj.scales": "model.safetensors",
344
+ "model.layers.21.mlp.up_proj.weight": "model.safetensors",
345
+ "model.layers.21.post_attention_layernorm.weight": "model.safetensors",
346
+ "model.layers.21.self_attn.k_proj.biases": "model.safetensors",
347
+ "model.layers.21.self_attn.k_proj.scales": "model.safetensors",
348
+ "model.layers.21.self_attn.k_proj.weight": "model.safetensors",
349
+ "model.layers.21.self_attn.o_proj.biases": "model.safetensors",
350
+ "model.layers.21.self_attn.o_proj.scales": "model.safetensors",
351
+ "model.layers.21.self_attn.o_proj.weight": "model.safetensors",
352
+ "model.layers.21.self_attn.q_proj.biases": "model.safetensors",
353
+ "model.layers.21.self_attn.q_proj.scales": "model.safetensors",
354
+ "model.layers.21.self_attn.q_proj.weight": "model.safetensors",
355
+ "model.layers.21.self_attn.v_proj.biases": "model.safetensors",
356
+ "model.layers.21.self_attn.v_proj.scales": "model.safetensors",
357
+ "model.layers.21.self_attn.v_proj.weight": "model.safetensors",
358
+ "model.layers.22.input_layernorm.weight": "model.safetensors",
359
+ "model.layers.22.mlp.down_proj.biases": "model.safetensors",
360
+ "model.layers.22.mlp.down_proj.scales": "model.safetensors",
361
+ "model.layers.22.mlp.down_proj.weight": "model.safetensors",
362
+ "model.layers.22.mlp.gate_proj.biases": "model.safetensors",
363
+ "model.layers.22.mlp.gate_proj.scales": "model.safetensors",
364
+ "model.layers.22.mlp.gate_proj.weight": "model.safetensors",
365
+ "model.layers.22.mlp.up_proj.biases": "model.safetensors",
366
+ "model.layers.22.mlp.up_proj.scales": "model.safetensors",
367
+ "model.layers.22.mlp.up_proj.weight": "model.safetensors",
368
+ "model.layers.22.post_attention_layernorm.weight": "model.safetensors",
369
+ "model.layers.22.self_attn.k_proj.biases": "model.safetensors",
370
+ "model.layers.22.self_attn.k_proj.scales": "model.safetensors",
371
+ "model.layers.22.self_attn.k_proj.weight": "model.safetensors",
372
+ "model.layers.22.self_attn.o_proj.biases": "model.safetensors",
373
+ "model.layers.22.self_attn.o_proj.scales": "model.safetensors",
374
+ "model.layers.22.self_attn.o_proj.weight": "model.safetensors",
375
+ "model.layers.22.self_attn.q_proj.biases": "model.safetensors",
376
+ "model.layers.22.self_attn.q_proj.scales": "model.safetensors",
377
+ "model.layers.22.self_attn.q_proj.weight": "model.safetensors",
378
+ "model.layers.22.self_attn.v_proj.biases": "model.safetensors",
379
+ "model.layers.22.self_attn.v_proj.scales": "model.safetensors",
380
+ "model.layers.22.self_attn.v_proj.weight": "model.safetensors",
381
+ "model.layers.23.input_layernorm.weight": "model.safetensors",
382
+ "model.layers.23.mlp.down_proj.biases": "model.safetensors",
383
+ "model.layers.23.mlp.down_proj.scales": "model.safetensors",
384
+ "model.layers.23.mlp.down_proj.weight": "model.safetensors",
385
+ "model.layers.23.mlp.gate_proj.biases": "model.safetensors",
386
+ "model.layers.23.mlp.gate_proj.scales": "model.safetensors",
387
+ "model.layers.23.mlp.gate_proj.weight": "model.safetensors",
388
+ "model.layers.23.mlp.up_proj.biases": "model.safetensors",
389
+ "model.layers.23.mlp.up_proj.scales": "model.safetensors",
390
+ "model.layers.23.mlp.up_proj.weight": "model.safetensors",
391
+ "model.layers.23.post_attention_layernorm.weight": "model.safetensors",
392
+ "model.layers.23.self_attn.k_proj.biases": "model.safetensors",
393
+ "model.layers.23.self_attn.k_proj.scales": "model.safetensors",
394
+ "model.layers.23.self_attn.k_proj.weight": "model.safetensors",
395
+ "model.layers.23.self_attn.o_proj.biases": "model.safetensors",
396
+ "model.layers.23.self_attn.o_proj.scales": "model.safetensors",
397
+ "model.layers.23.self_attn.o_proj.weight": "model.safetensors",
398
+ "model.layers.23.self_attn.q_proj.biases": "model.safetensors",
399
+ "model.layers.23.self_attn.q_proj.scales": "model.safetensors",
400
+ "model.layers.23.self_attn.q_proj.weight": "model.safetensors",
401
+ "model.layers.23.self_attn.v_proj.biases": "model.safetensors",
402
+ "model.layers.23.self_attn.v_proj.scales": "model.safetensors",
403
+ "model.layers.23.self_attn.v_proj.weight": "model.safetensors",
404
+ "model.layers.24.input_layernorm.weight": "model.safetensors",
405
+ "model.layers.24.mlp.down_proj.biases": "model.safetensors",
406
+ "model.layers.24.mlp.down_proj.scales": "model.safetensors",
407
+ "model.layers.24.mlp.down_proj.weight": "model.safetensors",
408
+ "model.layers.24.mlp.gate_proj.biases": "model.safetensors",
409
+ "model.layers.24.mlp.gate_proj.scales": "model.safetensors",
410
+ "model.layers.24.mlp.gate_proj.weight": "model.safetensors",
411
+ "model.layers.24.mlp.up_proj.biases": "model.safetensors",
412
+ "model.layers.24.mlp.up_proj.scales": "model.safetensors",
413
+ "model.layers.24.mlp.up_proj.weight": "model.safetensors",
414
+ "model.layers.24.post_attention_layernorm.weight": "model.safetensors",
415
+ "model.layers.24.self_attn.k_proj.biases": "model.safetensors",
416
+ "model.layers.24.self_attn.k_proj.scales": "model.safetensors",
417
+ "model.layers.24.self_attn.k_proj.weight": "model.safetensors",
418
+ "model.layers.24.self_attn.o_proj.biases": "model.safetensors",
419
+ "model.layers.24.self_attn.o_proj.scales": "model.safetensors",
420
+ "model.layers.24.self_attn.o_proj.weight": "model.safetensors",
421
+ "model.layers.24.self_attn.q_proj.biases": "model.safetensors",
422
+ "model.layers.24.self_attn.q_proj.scales": "model.safetensors",
423
+ "model.layers.24.self_attn.q_proj.weight": "model.safetensors",
424
+ "model.layers.24.self_attn.v_proj.biases": "model.safetensors",
425
+ "model.layers.24.self_attn.v_proj.scales": "model.safetensors",
426
+ "model.layers.24.self_attn.v_proj.weight": "model.safetensors",
427
+ "model.layers.25.input_layernorm.weight": "model.safetensors",
428
+ "model.layers.25.mlp.down_proj.biases": "model.safetensors",
429
+ "model.layers.25.mlp.down_proj.scales": "model.safetensors",
430
+ "model.layers.25.mlp.down_proj.weight": "model.safetensors",
431
+ "model.layers.25.mlp.gate_proj.biases": "model.safetensors",
432
+ "model.layers.25.mlp.gate_proj.scales": "model.safetensors",
433
+ "model.layers.25.mlp.gate_proj.weight": "model.safetensors",
434
+ "model.layers.25.mlp.up_proj.biases": "model.safetensors",
435
+ "model.layers.25.mlp.up_proj.scales": "model.safetensors",
436
+ "model.layers.25.mlp.up_proj.weight": "model.safetensors",
437
+ "model.layers.25.post_attention_layernorm.weight": "model.safetensors",
438
+ "model.layers.25.self_attn.k_proj.biases": "model.safetensors",
439
+ "model.layers.25.self_attn.k_proj.scales": "model.safetensors",
440
+ "model.layers.25.self_attn.k_proj.weight": "model.safetensors",
441
+ "model.layers.25.self_attn.o_proj.biases": "model.safetensors",
442
+ "model.layers.25.self_attn.o_proj.scales": "model.safetensors",
443
+ "model.layers.25.self_attn.o_proj.weight": "model.safetensors",
444
+ "model.layers.25.self_attn.q_proj.biases": "model.safetensors",
445
+ "model.layers.25.self_attn.q_proj.scales": "model.safetensors",
446
+ "model.layers.25.self_attn.q_proj.weight": "model.safetensors",
447
+ "model.layers.25.self_attn.v_proj.biases": "model.safetensors",
448
+ "model.layers.25.self_attn.v_proj.scales": "model.safetensors",
449
+ "model.layers.25.self_attn.v_proj.weight": "model.safetensors",
450
+ "model.layers.26.input_layernorm.weight": "model.safetensors",
451
+ "model.layers.26.mlp.down_proj.biases": "model.safetensors",
452
+ "model.layers.26.mlp.down_proj.scales": "model.safetensors",
453
+ "model.layers.26.mlp.down_proj.weight": "model.safetensors",
454
+ "model.layers.26.mlp.gate_proj.biases": "model.safetensors",
455
+ "model.layers.26.mlp.gate_proj.scales": "model.safetensors",
456
+ "model.layers.26.mlp.gate_proj.weight": "model.safetensors",
457
+ "model.layers.26.mlp.up_proj.biases": "model.safetensors",
458
+ "model.layers.26.mlp.up_proj.scales": "model.safetensors",
459
+ "model.layers.26.mlp.up_proj.weight": "model.safetensors",
460
+ "model.layers.26.post_attention_layernorm.weight": "model.safetensors",
461
+ "model.layers.26.self_attn.k_proj.biases": "model.safetensors",
462
+ "model.layers.26.self_attn.k_proj.scales": "model.safetensors",
463
+ "model.layers.26.self_attn.k_proj.weight": "model.safetensors",
464
+ "model.layers.26.self_attn.o_proj.biases": "model.safetensors",
465
+ "model.layers.26.self_attn.o_proj.scales": "model.safetensors",
466
+ "model.layers.26.self_attn.o_proj.weight": "model.safetensors",
467
+ "model.layers.26.self_attn.q_proj.biases": "model.safetensors",
468
+ "model.layers.26.self_attn.q_proj.scales": "model.safetensors",
469
+ "model.layers.26.self_attn.q_proj.weight": "model.safetensors",
470
+ "model.layers.26.self_attn.v_proj.biases": "model.safetensors",
471
+ "model.layers.26.self_attn.v_proj.scales": "model.safetensors",
472
+ "model.layers.26.self_attn.v_proj.weight": "model.safetensors",
473
+ "model.layers.27.input_layernorm.weight": "model.safetensors",
474
+ "model.layers.27.mlp.down_proj.biases": "model.safetensors",
475
+ "model.layers.27.mlp.down_proj.scales": "model.safetensors",
476
+ "model.layers.27.mlp.down_proj.weight": "model.safetensors",
477
+ "model.layers.27.mlp.gate_proj.biases": "model.safetensors",
478
+ "model.layers.27.mlp.gate_proj.scales": "model.safetensors",
479
+ "model.layers.27.mlp.gate_proj.weight": "model.safetensors",
480
+ "model.layers.27.mlp.up_proj.biases": "model.safetensors",
481
+ "model.layers.27.mlp.up_proj.scales": "model.safetensors",
482
+ "model.layers.27.mlp.up_proj.weight": "model.safetensors",
483
+ "model.layers.27.post_attention_layernorm.weight": "model.safetensors",
484
+ "model.layers.27.self_attn.k_proj.biases": "model.safetensors",
485
+ "model.layers.27.self_attn.k_proj.scales": "model.safetensors",
486
+ "model.layers.27.self_attn.k_proj.weight": "model.safetensors",
487
+ "model.layers.27.self_attn.o_proj.biases": "model.safetensors",
488
+ "model.layers.27.self_attn.o_proj.scales": "model.safetensors",
489
+ "model.layers.27.self_attn.o_proj.weight": "model.safetensors",
490
+ "model.layers.27.self_attn.q_proj.biases": "model.safetensors",
491
+ "model.layers.27.self_attn.q_proj.scales": "model.safetensors",
492
+ "model.layers.27.self_attn.q_proj.weight": "model.safetensors",
493
+ "model.layers.27.self_attn.v_proj.biases": "model.safetensors",
494
+ "model.layers.27.self_attn.v_proj.scales": "model.safetensors",
495
+ "model.layers.27.self_attn.v_proj.weight": "model.safetensors",
496
+ "model.layers.28.input_layernorm.weight": "model.safetensors",
497
+ "model.layers.28.mlp.down_proj.biases": "model.safetensors",
498
+ "model.layers.28.mlp.down_proj.scales": "model.safetensors",
499
+ "model.layers.28.mlp.down_proj.weight": "model.safetensors",
500
+ "model.layers.28.mlp.gate_proj.biases": "model.safetensors",
501
+ "model.layers.28.mlp.gate_proj.scales": "model.safetensors",
502
+ "model.layers.28.mlp.gate_proj.weight": "model.safetensors",
503
+ "model.layers.28.mlp.up_proj.biases": "model.safetensors",
504
+ "model.layers.28.mlp.up_proj.scales": "model.safetensors",
505
+ "model.layers.28.mlp.up_proj.weight": "model.safetensors",
506
+ "model.layers.28.post_attention_layernorm.weight": "model.safetensors",
507
+ "model.layers.28.self_attn.k_proj.biases": "model.safetensors",
508
+ "model.layers.28.self_attn.k_proj.scales": "model.safetensors",
509
+ "model.layers.28.self_attn.k_proj.weight": "model.safetensors",
510
+ "model.layers.28.self_attn.o_proj.biases": "model.safetensors",
511
+ "model.layers.28.self_attn.o_proj.scales": "model.safetensors",
512
+ "model.layers.28.self_attn.o_proj.weight": "model.safetensors",
513
+ "model.layers.28.self_attn.q_proj.biases": "model.safetensors",
514
+ "model.layers.28.self_attn.q_proj.scales": "model.safetensors",
515
+ "model.layers.28.self_attn.q_proj.weight": "model.safetensors",
516
+ "model.layers.28.self_attn.v_proj.biases": "model.safetensors",
517
+ "model.layers.28.self_attn.v_proj.scales": "model.safetensors",
518
+ "model.layers.28.self_attn.v_proj.weight": "model.safetensors",
519
+ "model.layers.29.input_layernorm.weight": "model.safetensors",
520
+ "model.layers.29.mlp.down_proj.biases": "model.safetensors",
521
+ "model.layers.29.mlp.down_proj.scales": "model.safetensors",
522
+ "model.layers.29.mlp.down_proj.weight": "model.safetensors",
523
+ "model.layers.29.mlp.gate_proj.biases": "model.safetensors",
524
+ "model.layers.29.mlp.gate_proj.scales": "model.safetensors",
525
+ "model.layers.29.mlp.gate_proj.weight": "model.safetensors",
526
+ "model.layers.29.mlp.up_proj.biases": "model.safetensors",
527
+ "model.layers.29.mlp.up_proj.scales": "model.safetensors",
528
+ "model.layers.29.mlp.up_proj.weight": "model.safetensors",
529
+ "model.layers.29.post_attention_layernorm.weight": "model.safetensors",
530
+ "model.layers.29.self_attn.k_proj.biases": "model.safetensors",
531
+ "model.layers.29.self_attn.k_proj.scales": "model.safetensors",
532
+ "model.layers.29.self_attn.k_proj.weight": "model.safetensors",
533
+ "model.layers.29.self_attn.o_proj.biases": "model.safetensors",
534
+ "model.layers.29.self_attn.o_proj.scales": "model.safetensors",
535
+ "model.layers.29.self_attn.o_proj.weight": "model.safetensors",
536
+ "model.layers.29.self_attn.q_proj.biases": "model.safetensors",
537
+ "model.layers.29.self_attn.q_proj.scales": "model.safetensors",
538
+ "model.layers.29.self_attn.q_proj.weight": "model.safetensors",
539
+ "model.layers.29.self_attn.v_proj.biases": "model.safetensors",
540
+ "model.layers.29.self_attn.v_proj.scales": "model.safetensors",
541
+ "model.layers.29.self_attn.v_proj.weight": "model.safetensors",
542
+ "model.layers.3.input_layernorm.weight": "model.safetensors",
543
+ "model.layers.3.mlp.down_proj.biases": "model.safetensors",
544
+ "model.layers.3.mlp.down_proj.scales": "model.safetensors",
545
+ "model.layers.3.mlp.down_proj.weight": "model.safetensors",
546
+ "model.layers.3.mlp.gate_proj.biases": "model.safetensors",
547
+ "model.layers.3.mlp.gate_proj.scales": "model.safetensors",
548
+ "model.layers.3.mlp.gate_proj.weight": "model.safetensors",
549
+ "model.layers.3.mlp.up_proj.biases": "model.safetensors",
550
+ "model.layers.3.mlp.up_proj.scales": "model.safetensors",
551
+ "model.layers.3.mlp.up_proj.weight": "model.safetensors",
552
+ "model.layers.3.post_attention_layernorm.weight": "model.safetensors",
553
+ "model.layers.3.self_attn.k_proj.biases": "model.safetensors",
554
+ "model.layers.3.self_attn.k_proj.scales": "model.safetensors",
555
+ "model.layers.3.self_attn.k_proj.weight": "model.safetensors",
556
+ "model.layers.3.self_attn.o_proj.biases": "model.safetensors",
557
+ "model.layers.3.self_attn.o_proj.scales": "model.safetensors",
558
+ "model.layers.3.self_attn.o_proj.weight": "model.safetensors",
559
+ "model.layers.3.self_attn.q_proj.biases": "model.safetensors",
560
+ "model.layers.3.self_attn.q_proj.scales": "model.safetensors",
561
+ "model.layers.3.self_attn.q_proj.weight": "model.safetensors",
562
+ "model.layers.3.self_attn.v_proj.biases": "model.safetensors",
563
+ "model.layers.3.self_attn.v_proj.scales": "model.safetensors",
564
+ "model.layers.3.self_attn.v_proj.weight": "model.safetensors",
565
+ "model.layers.30.input_layernorm.weight": "model.safetensors",
566
+ "model.layers.30.mlp.down_proj.biases": "model.safetensors",
567
+ "model.layers.30.mlp.down_proj.scales": "model.safetensors",
568
+ "model.layers.30.mlp.down_proj.weight": "model.safetensors",
569
+ "model.layers.30.mlp.gate_proj.biases": "model.safetensors",
570
+ "model.layers.30.mlp.gate_proj.scales": "model.safetensors",
571
+ "model.layers.30.mlp.gate_proj.weight": "model.safetensors",
572
+ "model.layers.30.mlp.up_proj.biases": "model.safetensors",
573
+ "model.layers.30.mlp.up_proj.scales": "model.safetensors",
574
+ "model.layers.30.mlp.up_proj.weight": "model.safetensors",
575
+ "model.layers.30.post_attention_layernorm.weight": "model.safetensors",
576
+ "model.layers.30.self_attn.k_proj.biases": "model.safetensors",
577
+ "model.layers.30.self_attn.k_proj.scales": "model.safetensors",
578
+ "model.layers.30.self_attn.k_proj.weight": "model.safetensors",
579
+ "model.layers.30.self_attn.o_proj.biases": "model.safetensors",
580
+ "model.layers.30.self_attn.o_proj.scales": "model.safetensors",
581
+ "model.layers.30.self_attn.o_proj.weight": "model.safetensors",
582
+ "model.layers.30.self_attn.q_proj.biases": "model.safetensors",
583
+ "model.layers.30.self_attn.q_proj.scales": "model.safetensors",
584
+ "model.layers.30.self_attn.q_proj.weight": "model.safetensors",
585
+ "model.layers.30.self_attn.v_proj.biases": "model.safetensors",
586
+ "model.layers.30.self_attn.v_proj.scales": "model.safetensors",
587
+ "model.layers.30.self_attn.v_proj.weight": "model.safetensors",
588
+ "model.layers.31.input_layernorm.weight": "model.safetensors",
589
+ "model.layers.31.mlp.down_proj.biases": "model.safetensors",
590
+ "model.layers.31.mlp.down_proj.scales": "model.safetensors",
591
+ "model.layers.31.mlp.down_proj.weight": "model.safetensors",
592
+ "model.layers.31.mlp.gate_proj.biases": "model.safetensors",
593
+ "model.layers.31.mlp.gate_proj.scales": "model.safetensors",
594
+ "model.layers.31.mlp.gate_proj.weight": "model.safetensors",
595
+ "model.layers.31.mlp.up_proj.biases": "model.safetensors",
596
+ "model.layers.31.mlp.up_proj.scales": "model.safetensors",
597
+ "model.layers.31.mlp.up_proj.weight": "model.safetensors",
598
+ "model.layers.31.post_attention_layernorm.weight": "model.safetensors",
599
+ "model.layers.31.self_attn.k_proj.biases": "model.safetensors",
600
+ "model.layers.31.self_attn.k_proj.scales": "model.safetensors",
601
+ "model.layers.31.self_attn.k_proj.weight": "model.safetensors",
602
+ "model.layers.31.self_attn.o_proj.biases": "model.safetensors",
603
+ "model.layers.31.self_attn.o_proj.scales": "model.safetensors",
604
+ "model.layers.31.self_attn.o_proj.weight": "model.safetensors",
605
+ "model.layers.31.self_attn.q_proj.biases": "model.safetensors",
606
+ "model.layers.31.self_attn.q_proj.scales": "model.safetensors",
607
+ "model.layers.31.self_attn.q_proj.weight": "model.safetensors",
608
+ "model.layers.31.self_attn.v_proj.biases": "model.safetensors",
609
+ "model.layers.31.self_attn.v_proj.scales": "model.safetensors",
610
+ "model.layers.31.self_attn.v_proj.weight": "model.safetensors",
611
+ "model.layers.4.input_layernorm.weight": "model.safetensors",
612
+ "model.layers.4.mlp.down_proj.biases": "model.safetensors",
613
+ "model.layers.4.mlp.down_proj.scales": "model.safetensors",
614
+ "model.layers.4.mlp.down_proj.weight": "model.safetensors",
615
+ "model.layers.4.mlp.gate_proj.biases": "model.safetensors",
616
+ "model.layers.4.mlp.gate_proj.scales": "model.safetensors",
617
+ "model.layers.4.mlp.gate_proj.weight": "model.safetensors",
618
+ "model.layers.4.mlp.up_proj.biases": "model.safetensors",
619
+ "model.layers.4.mlp.up_proj.scales": "model.safetensors",
620
+ "model.layers.4.mlp.up_proj.weight": "model.safetensors",
621
+ "model.layers.4.post_attention_layernorm.weight": "model.safetensors",
622
+ "model.layers.4.self_attn.k_proj.biases": "model.safetensors",
623
+ "model.layers.4.self_attn.k_proj.scales": "model.safetensors",
624
+ "model.layers.4.self_attn.k_proj.weight": "model.safetensors",
625
+ "model.layers.4.self_attn.o_proj.biases": "model.safetensors",
626
+ "model.layers.4.self_attn.o_proj.scales": "model.safetensors",
627
+ "model.layers.4.self_attn.o_proj.weight": "model.safetensors",
628
+ "model.layers.4.self_attn.q_proj.biases": "model.safetensors",
629
+ "model.layers.4.self_attn.q_proj.scales": "model.safetensors",
630
+ "model.layers.4.self_attn.q_proj.weight": "model.safetensors",
631
+ "model.layers.4.self_attn.v_proj.biases": "model.safetensors",
632
+ "model.layers.4.self_attn.v_proj.scales": "model.safetensors",
633
+ "model.layers.4.self_attn.v_proj.weight": "model.safetensors",
634
+ "model.layers.5.input_layernorm.weight": "model.safetensors",
635
+ "model.layers.5.mlp.down_proj.biases": "model.safetensors",
636
+ "model.layers.5.mlp.down_proj.scales": "model.safetensors",
637
+ "model.layers.5.mlp.down_proj.weight": "model.safetensors",
638
+ "model.layers.5.mlp.gate_proj.biases": "model.safetensors",
639
+ "model.layers.5.mlp.gate_proj.scales": "model.safetensors",
640
+ "model.layers.5.mlp.gate_proj.weight": "model.safetensors",
641
+ "model.layers.5.mlp.up_proj.biases": "model.safetensors",
642
+ "model.layers.5.mlp.up_proj.scales": "model.safetensors",
643
+ "model.layers.5.mlp.up_proj.weight": "model.safetensors",
644
+ "model.layers.5.post_attention_layernorm.weight": "model.safetensors",
645
+ "model.layers.5.self_attn.k_proj.biases": "model.safetensors",
646
+ "model.layers.5.self_attn.k_proj.scales": "model.safetensors",
647
+ "model.layers.5.self_attn.k_proj.weight": "model.safetensors",
648
+ "model.layers.5.self_attn.o_proj.biases": "model.safetensors",
649
+ "model.layers.5.self_attn.o_proj.scales": "model.safetensors",
650
+ "model.layers.5.self_attn.o_proj.weight": "model.safetensors",
651
+ "model.layers.5.self_attn.q_proj.biases": "model.safetensors",
652
+ "model.layers.5.self_attn.q_proj.scales": "model.safetensors",
653
+ "model.layers.5.self_attn.q_proj.weight": "model.safetensors",
654
+ "model.layers.5.self_attn.v_proj.biases": "model.safetensors",
655
+ "model.layers.5.self_attn.v_proj.scales": "model.safetensors",
656
+ "model.layers.5.self_attn.v_proj.weight": "model.safetensors",
657
+ "model.layers.6.input_layernorm.weight": "model.safetensors",
658
+ "model.layers.6.mlp.down_proj.biases": "model.safetensors",
659
+ "model.layers.6.mlp.down_proj.scales": "model.safetensors",
660
+ "model.layers.6.mlp.down_proj.weight": "model.safetensors",
661
+ "model.layers.6.mlp.gate_proj.biases": "model.safetensors",
662
+ "model.layers.6.mlp.gate_proj.scales": "model.safetensors",
663
+ "model.layers.6.mlp.gate_proj.weight": "model.safetensors",
664
+ "model.layers.6.mlp.up_proj.biases": "model.safetensors",
665
+ "model.layers.6.mlp.up_proj.scales": "model.safetensors",
666
+ "model.layers.6.mlp.up_proj.weight": "model.safetensors",
667
+ "model.layers.6.post_attention_layernorm.weight": "model.safetensors",
668
+ "model.layers.6.self_attn.k_proj.biases": "model.safetensors",
669
+ "model.layers.6.self_attn.k_proj.scales": "model.safetensors",
670
+ "model.layers.6.self_attn.k_proj.weight": "model.safetensors",
671
+ "model.layers.6.self_attn.o_proj.biases": "model.safetensors",
672
+ "model.layers.6.self_attn.o_proj.scales": "model.safetensors",
673
+ "model.layers.6.self_attn.o_proj.weight": "model.safetensors",
674
+ "model.layers.6.self_attn.q_proj.biases": "model.safetensors",
675
+ "model.layers.6.self_attn.q_proj.scales": "model.safetensors",
676
+ "model.layers.6.self_attn.q_proj.weight": "model.safetensors",
677
+ "model.layers.6.self_attn.v_proj.biases": "model.safetensors",
678
+ "model.layers.6.self_attn.v_proj.scales": "model.safetensors",
679
+ "model.layers.6.self_attn.v_proj.weight": "model.safetensors",
680
+ "model.layers.7.input_layernorm.weight": "model.safetensors",
681
+ "model.layers.7.mlp.down_proj.biases": "model.safetensors",
682
+ "model.layers.7.mlp.down_proj.scales": "model.safetensors",
683
+ "model.layers.7.mlp.down_proj.weight": "model.safetensors",
684
+ "model.layers.7.mlp.gate_proj.biases": "model.safetensors",
685
+ "model.layers.7.mlp.gate_proj.scales": "model.safetensors",
686
+ "model.layers.7.mlp.gate_proj.weight": "model.safetensors",
687
+ "model.layers.7.mlp.up_proj.biases": "model.safetensors",
688
+ "model.layers.7.mlp.up_proj.scales": "model.safetensors",
689
+ "model.layers.7.mlp.up_proj.weight": "model.safetensors",
690
+ "model.layers.7.post_attention_layernorm.weight": "model.safetensors",
691
+ "model.layers.7.self_attn.k_proj.biases": "model.safetensors",
692
+ "model.layers.7.self_attn.k_proj.scales": "model.safetensors",
693
+ "model.layers.7.self_attn.k_proj.weight": "model.safetensors",
694
+ "model.layers.7.self_attn.o_proj.biases": "model.safetensors",
695
+ "model.layers.7.self_attn.o_proj.scales": "model.safetensors",
696
+ "model.layers.7.self_attn.o_proj.weight": "model.safetensors",
697
+ "model.layers.7.self_attn.q_proj.biases": "model.safetensors",
698
+ "model.layers.7.self_attn.q_proj.scales": "model.safetensors",
699
+ "model.layers.7.self_attn.q_proj.weight": "model.safetensors",
700
+ "model.layers.7.self_attn.v_proj.biases": "model.safetensors",
701
+ "model.layers.7.self_attn.v_proj.scales": "model.safetensors",
702
+ "model.layers.7.self_attn.v_proj.weight": "model.safetensors",
703
+ "model.layers.8.input_layernorm.weight": "model.safetensors",
704
+ "model.layers.8.mlp.down_proj.biases": "model.safetensors",
705
+ "model.layers.8.mlp.down_proj.scales": "model.safetensors",
706
+ "model.layers.8.mlp.down_proj.weight": "model.safetensors",
707
+ "model.layers.8.mlp.gate_proj.biases": "model.safetensors",
708
+ "model.layers.8.mlp.gate_proj.scales": "model.safetensors",
709
+ "model.layers.8.mlp.gate_proj.weight": "model.safetensors",
710
+ "model.layers.8.mlp.up_proj.biases": "model.safetensors",
711
+ "model.layers.8.mlp.up_proj.scales": "model.safetensors",
712
+ "model.layers.8.mlp.up_proj.weight": "model.safetensors",
713
+ "model.layers.8.post_attention_layernorm.weight": "model.safetensors",
714
+ "model.layers.8.self_attn.k_proj.biases": "model.safetensors",
715
+ "model.layers.8.self_attn.k_proj.scales": "model.safetensors",
716
+ "model.layers.8.self_attn.k_proj.weight": "model.safetensors",
717
+ "model.layers.8.self_attn.o_proj.biases": "model.safetensors",
718
+ "model.layers.8.self_attn.o_proj.scales": "model.safetensors",
719
+ "model.layers.8.self_attn.o_proj.weight": "model.safetensors",
720
+ "model.layers.8.self_attn.q_proj.biases": "model.safetensors",
721
+ "model.layers.8.self_attn.q_proj.scales": "model.safetensors",
722
+ "model.layers.8.self_attn.q_proj.weight": "model.safetensors",
723
+ "model.layers.8.self_attn.v_proj.biases": "model.safetensors",
724
+ "model.layers.8.self_attn.v_proj.scales": "model.safetensors",
725
+ "model.layers.8.self_attn.v_proj.weight": "model.safetensors",
726
+ "model.layers.9.input_layernorm.weight": "model.safetensors",
727
+ "model.layers.9.mlp.down_proj.biases": "model.safetensors",
728
+ "model.layers.9.mlp.down_proj.scales": "model.safetensors",
729
+ "model.layers.9.mlp.down_proj.weight": "model.safetensors",
730
+ "model.layers.9.mlp.gate_proj.biases": "model.safetensors",
731
+ "model.layers.9.mlp.gate_proj.scales": "model.safetensors",
732
+ "model.layers.9.mlp.gate_proj.weight": "model.safetensors",
733
+ "model.layers.9.mlp.up_proj.biases": "model.safetensors",
734
+ "model.layers.9.mlp.up_proj.scales": "model.safetensors",
735
+ "model.layers.9.mlp.up_proj.weight": "model.safetensors",
736
+ "model.layers.9.post_attention_layernorm.weight": "model.safetensors",
737
+ "model.layers.9.self_attn.k_proj.biases": "model.safetensors",
738
+ "model.layers.9.self_attn.k_proj.scales": "model.safetensors",
739
+ "model.layers.9.self_attn.k_proj.weight": "model.safetensors",
740
+ "model.layers.9.self_attn.o_proj.biases": "model.safetensors",
741
+ "model.layers.9.self_attn.o_proj.scales": "model.safetensors",
742
+ "model.layers.9.self_attn.o_proj.weight": "model.safetensors",
743
+ "model.layers.9.self_attn.q_proj.biases": "model.safetensors",
744
+ "model.layers.9.self_attn.q_proj.scales": "model.safetensors",
745
+ "model.layers.9.self_attn.q_proj.weight": "model.safetensors",
746
+ "model.layers.9.self_attn.v_proj.biases": "model.safetensors",
747
+ "model.layers.9.self_attn.v_proj.scales": "model.safetensors",
748
+ "model.layers.9.self_attn.v_proj.weight": "model.safetensors",
749
+ "model.norm.weight": "model.safetensors"
750
+ }
751
+ }
modeling_minicpm.py ADDED
@@ -0,0 +1,968 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # encoding: utf-8
3
+
4
+ # coding=utf-8
5
+ # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
6
+ #
7
+ # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
8
+ # and OPT implementations in this library. It has been modified from its
9
+ # original forms to accommodate minor architectural differences compared
10
+ # to GPT-NeoX and OPT used by the Meta AI team that trained the model.
11
+ #
12
+ # Licensed under the Apache License, Version 2.0 (the "License");
13
+ # you may not use this file except in compliance with the License.
14
+ # You may obtain a copy of the License at
15
+ #
16
+ # http://www.apache.org/licenses/LICENSE-2.0
17
+ #
18
+ # Unless required by applicable law or agreed to in writing, software
19
+ # distributed under the License is distributed on an "AS IS" BASIS,
20
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ # See the License for the specific language governing permissions and
22
+ # limitations under the License.
23
+ from typing import Callable, Optional, Tuple, Union
24
+
25
+ import math
26
+ import torch
27
+ import torch.utils.checkpoint
28
+ from torch import nn
29
+
30
+ from transformers.activations import ACT2FN
31
+ from transformers.cache_utils import Cache, DynamicCache
32
+ from transformers.generation import GenerationMixin
33
+ from transformers.modeling_attn_mask_utils import AttentionMaskConverter
34
+ from transformers.modeling_flash_attention_utils import FlashAttentionKwargs
35
+ from transformers.modeling_layers import GradientCheckpointingLayer
36
+ from transformers.modeling_outputs import (
37
+ BaseModelOutputWithPast,
38
+ CausalLMOutputWithPast,
39
+ QuestionAnsweringModelOutput,
40
+ SequenceClassifierOutputWithPast,
41
+ TokenClassifierOutput,
42
+ )
43
+ from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
44
+ from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
45
+ from transformers.processing_utils import Unpack
46
+ from transformers.pytorch_utils import ALL_LAYERNORM_LAYERS
47
+ from transformers.utils import LossKwargs, auto_docstring, can_return_tuple, is_torch_flex_attn_available, logging
48
+ from .configuration_minicpm import MiniCPMConfig
49
+
50
+
51
+ if is_torch_flex_attn_available():
52
+ from torch.nn.attention.flex_attention import BlockMask
53
+
54
+ from transformers.integrations.flex_attention import make_flex_block_causal_mask
55
+
56
+ from transformers.integrations import use_kernel_forward_from_hub
57
+
58
+
59
+ logger = logging.get_logger(__name__)
60
+
61
+
62
+ @use_kernel_forward_from_hub("RMSNorm")
63
+ class MiniCPMRMSNorm(nn.Module):
64
+ def __init__(self, hidden_size, eps=1e-6):
65
+ """
66
+ MiniCPMRMSNorm is equivalent to T5LayerNorm
67
+ """
68
+ super().__init__()
69
+ self.weight = nn.Parameter(torch.ones(hidden_size))
70
+ self.variance_epsilon = eps
71
+
72
+ def forward(self, hidden_states):
73
+ input_dtype = hidden_states.dtype
74
+ hidden_states = hidden_states.to(torch.float32)
75
+ variance = hidden_states.pow(2).mean(-1, keepdim=True)
76
+ hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
77
+ return self.weight * hidden_states.to(input_dtype)
78
+
79
+ def extra_repr(self):
80
+ return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
81
+
82
+
83
+ ALL_LAYERNORM_LAYERS.append(MiniCPMRMSNorm)
84
+
85
+
86
+ class MiniCPMRotaryEmbedding(nn.Module):
87
+ def __init__(self, config: MiniCPMConfig, device=None):
88
+ super().__init__()
89
+ # BC: "rope_type" was originally "type"
90
+ if hasattr(config, "rope_scaling") and config.rope_scaling is not None:
91
+ self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type"))
92
+ else:
93
+ self.rope_type = "default"
94
+ self.max_seq_len_cached = config.max_position_embeddings
95
+ self.original_max_seq_len = config.max_position_embeddings
96
+
97
+ self.config = config
98
+ self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
99
+
100
+ inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device)
101
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
102
+ self.original_inv_freq = self.inv_freq
103
+
104
+ @torch.no_grad()
105
+ @dynamic_rope_update # power user: used with advanced RoPE types (e.g. dynamic rope)
106
+ def forward(self, x, position_ids):
107
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device)
108
+ position_ids_expanded = position_ids[:, None, :].float()
109
+
110
+ device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu"
111
+ with torch.autocast(device_type=device_type, enabled=False): # Force float32
112
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
113
+ emb = torch.cat((freqs, freqs), dim=-1)
114
+ cos = emb.cos() * self.attention_scaling
115
+ sin = emb.sin() * self.attention_scaling
116
+
117
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
118
+
119
+
120
+ def rotate_half(x):
121
+ """Rotates half the hidden dims of the input."""
122
+ x1 = x[..., : x.shape[-1] // 2]
123
+ x2 = x[..., x.shape[-1] // 2 :]
124
+ return torch.cat((-x2, x1), dim=-1)
125
+
126
+
127
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
128
+ """Applies Rotary Position Embedding to the query and key tensors.
129
+
130
+ Args:
131
+ q (`torch.Tensor`): The query tensor.
132
+ k (`torch.Tensor`): The key tensor.
133
+ cos (`torch.Tensor`): The cosine part of the rotary embedding.
134
+ sin (`torch.Tensor`): The sine part of the rotary embedding.
135
+ position_ids (`torch.Tensor`, *optional*):
136
+ Deprecated and unused.
137
+ unsqueeze_dim (`int`, *optional*, defaults to 1):
138
+ The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
139
+ sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
140
+ that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
141
+ k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
142
+ cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
143
+ the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
144
+ Returns:
145
+ `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
146
+ """
147
+ cos = cos.unsqueeze(unsqueeze_dim)
148
+ sin = sin.unsqueeze(unsqueeze_dim)
149
+ q_embed = (q * cos) + (rotate_half(q) * sin)
150
+ k_embed = (k * cos) + (rotate_half(k) * sin)
151
+ return q_embed, k_embed
152
+
153
+
154
+ class MiniCPMMLP(nn.Module):
155
+ def __init__(self, config):
156
+ super().__init__()
157
+ self.config = config
158
+ self.hidden_size = config.hidden_size
159
+ self.intermediate_size = config.intermediate_size
160
+ self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=config.mlp_bias)
161
+ self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=config.mlp_bias)
162
+ self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=config.mlp_bias)
163
+ self.act_fn = ACT2FN[config.hidden_act]
164
+
165
+ def forward(self, x):
166
+ down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
167
+ return down_proj
168
+
169
+
170
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
171
+ """
172
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
173
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
174
+ """
175
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
176
+ if n_rep == 1:
177
+ return hidden_states
178
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
179
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
180
+
181
+
182
+ def eager_attention_forward(
183
+ module: nn.Module,
184
+ query: torch.Tensor,
185
+ key: torch.Tensor,
186
+ value: torch.Tensor,
187
+ attention_mask: Optional[torch.Tensor],
188
+ scaling: float,
189
+ dropout: float = 0.0,
190
+ **kwargs,
191
+ ):
192
+ key_states = repeat_kv(key, module.num_key_value_groups)
193
+ value_states = repeat_kv(value, module.num_key_value_groups)
194
+
195
+ attn_weights = torch.matmul(query, key_states.transpose(2, 3)) * scaling
196
+ if attention_mask is not None:
197
+ causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
198
+ attn_weights = attn_weights + causal_mask
199
+
200
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype)
201
+ attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)
202
+ attn_output = torch.matmul(attn_weights, value_states)
203
+ attn_output = attn_output.transpose(1, 2).contiguous()
204
+
205
+ return attn_output, attn_weights
206
+
207
+
208
+ class MiniCPMAttention(nn.Module):
209
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
210
+
211
+ def __init__(self, config: MiniCPMConfig, layer_idx: int):
212
+ super().__init__()
213
+ self.config = config
214
+ self.layer_idx = layer_idx
215
+ self.head_dim = getattr(config, "head_dim", config.hidden_size // config.num_attention_heads)
216
+ self.num_key_value_groups = config.num_attention_heads // config.num_key_value_heads
217
+ self.scaling = self.head_dim**-0.5
218
+ self.attention_dropout = config.attention_dropout
219
+ self.is_causal = True
220
+
221
+ self.q_proj = nn.Linear(
222
+ config.hidden_size, config.num_attention_heads * self.head_dim, bias=config.attention_bias
223
+ )
224
+ self.k_proj = nn.Linear(
225
+ config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias
226
+ )
227
+ self.v_proj = nn.Linear(
228
+ config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias
229
+ )
230
+ self.o_proj = nn.Linear(
231
+ config.num_attention_heads * self.head_dim, config.hidden_size, bias=config.attention_bias
232
+ )
233
+
234
+ def forward(
235
+ self,
236
+ hidden_states: torch.Tensor,
237
+ position_embeddings: Tuple[torch.Tensor, torch.Tensor],
238
+ attention_mask: Optional[torch.Tensor],
239
+ past_key_value: Optional[Cache] = None,
240
+ cache_position: Optional[torch.LongTensor] = None,
241
+ **kwargs: Unpack[FlashAttentionKwargs],
242
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
243
+ input_shape = hidden_states.shape[:-1]
244
+ hidden_shape = (*input_shape, -1, self.head_dim)
245
+
246
+ query_states = self.q_proj(hidden_states).view(hidden_shape).transpose(1, 2)
247
+ key_states = self.k_proj(hidden_states).view(hidden_shape).transpose(1, 2)
248
+ value_states = self.v_proj(hidden_states).view(hidden_shape).transpose(1, 2)
249
+
250
+ cos, sin = position_embeddings
251
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
252
+
253
+ if past_key_value is not None:
254
+ # sin and cos are specific to RoPE models; cache_position needed for the static cache
255
+ cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
256
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
257
+
258
+ attention_interface: Callable = eager_attention_forward
259
+
260
+ if self.config._attn_implementation != "eager":
261
+ if self.config._attn_implementation == "sdpa" and kwargs.get("output_attentions", False):
262
+ logger.warning_once(
263
+ "`torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. Falling back to "
264
+ 'eager attention. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.'
265
+ )
266
+ else:
267
+ attention_interface = ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation]
268
+
269
+ attn_output, attn_weights = attention_interface(
270
+ self,
271
+ query_states,
272
+ key_states,
273
+ value_states,
274
+ attention_mask,
275
+ dropout=0.0 if not self.training else self.attention_dropout,
276
+ scaling=self.scaling,
277
+ **kwargs,
278
+ )
279
+
280
+ attn_output = attn_output.reshape(*input_shape, -1).contiguous()
281
+ attn_output = self.o_proj(attn_output)
282
+ return attn_output, attn_weights
283
+
284
+
285
+ class MiniCPMDecoderLayer(GradientCheckpointingLayer):
286
+ def __init__(self, config: MiniCPMConfig, layer_idx: int):
287
+ super().__init__()
288
+ self.hidden_size = config.hidden_size
289
+
290
+ self.self_attn = MiniCPMAttention(config=config, layer_idx=layer_idx)
291
+
292
+ self.mlp = MiniCPMMLP(config)
293
+ self.input_layernorm = MiniCPMRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
294
+ self.post_attention_layernorm = MiniCPMRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
295
+
296
+ self.scale_depth = config.scale_depth
297
+ self.num_hidden_layers = config.num_hidden_layers
298
+
299
+ def forward(
300
+ self,
301
+ hidden_states: torch.Tensor,
302
+ attention_mask: Optional[torch.Tensor] = None,
303
+ position_ids: Optional[torch.LongTensor] = None,
304
+ past_key_value: Optional[Cache] = None,
305
+ output_attentions: Optional[bool] = False,
306
+ use_cache: Optional[bool] = False,
307
+ cache_position: Optional[torch.LongTensor] = None,
308
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC
309
+ **kwargs: Unpack[FlashAttentionKwargs],
310
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
311
+ residual = hidden_states
312
+ hidden_states = self.input_layernorm(hidden_states)
313
+
314
+ # Self Attention
315
+ hidden_states, self_attn_weights = self.self_attn(
316
+ hidden_states=hidden_states,
317
+ attention_mask=attention_mask,
318
+ position_ids=position_ids,
319
+ past_key_value=past_key_value,
320
+ output_attentions=output_attentions,
321
+ use_cache=use_cache,
322
+ cache_position=cache_position,
323
+ position_embeddings=position_embeddings,
324
+ **kwargs,
325
+ )
326
+ hidden_states = residual + hidden_states * (self.scale_depth / math.sqrt(self.num_hidden_layers))
327
+
328
+ # Fully Connected
329
+ residual = hidden_states
330
+ hidden_states = self.post_attention_layernorm(hidden_states)
331
+ hidden_states = self.mlp(hidden_states)
332
+ hidden_states = residual + hidden_states * (self.scale_depth / math.sqrt(self.num_hidden_layers))
333
+
334
+ outputs = (hidden_states,)
335
+ if output_attentions:
336
+ outputs += (self_attn_weights,)
337
+
338
+ return outputs
339
+
340
+
341
+ @auto_docstring
342
+ class MiniCPMPreTrainedModel(PreTrainedModel):
343
+ config_class = MiniCPMConfig
344
+ base_model_prefix = "model"
345
+ supports_gradient_checkpointing = True
346
+ _no_split_modules = ["MiniCPMDecoderLayer"]
347
+ _skip_keys_device_placement = ["past_key_values"]
348
+ _supports_flash_attn_2 = True
349
+ _supports_sdpa = True
350
+ _supports_flex_attn = True
351
+ _supports_cache_class = True
352
+ _supports_quantized_cache = True
353
+ _supports_static_cache = True
354
+ _supports_attention_backend = True
355
+
356
+ def _init_weights(self, module):
357
+ std = self.config.initializer_range
358
+ if isinstance(module, nn.Linear):
359
+ module.weight.data.normal_(mean=0.0, std=std)
360
+ if module.bias is not None:
361
+ module.bias.data.zero_()
362
+ elif isinstance(module, nn.Embedding):
363
+ module.weight.data.normal_(mean=0.0, std=std)
364
+ if module.padding_idx is not None:
365
+ module.weight.data[module.padding_idx].zero_()
366
+ elif isinstance(module, MiniCPMRMSNorm):
367
+ module.weight.data.fill_(1.0)
368
+
369
+
370
+ @auto_docstring
371
+ class MiniCPMModel(MiniCPMPreTrainedModel):
372
+ def __init__(self, config: MiniCPMConfig):
373
+ super().__init__(config)
374
+ self.padding_idx = config.pad_token_id
375
+ self.vocab_size = config.vocab_size
376
+
377
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
378
+ self.layers = nn.ModuleList(
379
+ [MiniCPMDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
380
+ )
381
+ self.norm = MiniCPMRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
382
+ self.rotary_emb = MiniCPMRotaryEmbedding(config=config)
383
+ self.gradient_checkpointing = False
384
+
385
+ # Initialize weights and apply final processing
386
+ self.post_init()
387
+
388
+ def get_input_embeddings(self):
389
+ return self.embed_tokens
390
+
391
+ def set_input_embeddings(self, value):
392
+ self.embed_tokens = value
393
+
394
+ @can_return_tuple
395
+ @auto_docstring
396
+ def forward(
397
+ self,
398
+ input_ids: Optional[torch.LongTensor] = None,
399
+ attention_mask: Optional[torch.Tensor] = None,
400
+ position_ids: Optional[torch.LongTensor] = None,
401
+ past_key_values: Optional[Cache] = None,
402
+ inputs_embeds: Optional[torch.FloatTensor] = None,
403
+ use_cache: Optional[bool] = None,
404
+ output_attentions: Optional[bool] = None,
405
+ output_hidden_states: Optional[bool] = None,
406
+ cache_position: Optional[torch.LongTensor] = None,
407
+ **flash_attn_kwargs: Unpack[FlashAttentionKwargs],
408
+ ) -> BaseModelOutputWithPast:
409
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
410
+ output_hidden_states = (
411
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
412
+ )
413
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
414
+
415
+ if (input_ids is None) ^ (inputs_embeds is not None):
416
+ raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
417
+
418
+ if self.gradient_checkpointing and self.training and use_cache:
419
+ logger.warning_once(
420
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`."
421
+ )
422
+ use_cache = False
423
+
424
+ # TODO (joao): remove this exception in v4.56 -- it exists for users that try to pass a legacy cache
425
+ if not isinstance(past_key_values, (type(None), Cache)):
426
+ raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")
427
+
428
+ if inputs_embeds is None:
429
+ inputs_embeds = self.embed_tokens(input_ids) * self.config.scale_emb
430
+
431
+ if use_cache and past_key_values is None:
432
+ past_key_values = DynamicCache()
433
+
434
+ if cache_position is None:
435
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
436
+ cache_position = torch.arange(
437
+ past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device
438
+ )
439
+
440
+ if position_ids is None:
441
+ position_ids = cache_position.unsqueeze(0)
442
+
443
+ causal_mask = self._update_causal_mask(
444
+ attention_mask, inputs_embeds, cache_position, past_key_values, output_attentions
445
+ )
446
+
447
+ hidden_states = inputs_embeds
448
+
449
+ # create position embeddings to be shared across the decoder layers
450
+ position_embeddings = self.rotary_emb(hidden_states, position_ids)
451
+
452
+ # decoder layers
453
+ all_hidden_states = () if output_hidden_states else None
454
+ all_self_attns = () if output_attentions else None
455
+
456
+ for decoder_layer in self.layers[: self.config.num_hidden_layers]:
457
+ if output_hidden_states:
458
+ all_hidden_states += (hidden_states,)
459
+
460
+ layer_outputs = decoder_layer(
461
+ hidden_states,
462
+ attention_mask=causal_mask,
463
+ position_ids=position_ids,
464
+ past_key_value=past_key_values,
465
+ output_attentions=output_attentions,
466
+ use_cache=use_cache,
467
+ cache_position=cache_position,
468
+ position_embeddings=position_embeddings,
469
+ **flash_attn_kwargs,
470
+ )
471
+
472
+ hidden_states = layer_outputs[0]
473
+
474
+ if output_attentions:
475
+ all_self_attns += (layer_outputs[1],)
476
+
477
+ hidden_states = self.norm(hidden_states)
478
+
479
+ # add hidden states from the last decoder layer
480
+ if output_hidden_states:
481
+ all_hidden_states += (hidden_states,)
482
+
483
+ return BaseModelOutputWithPast(
484
+ last_hidden_state=hidden_states,
485
+ past_key_values=past_key_values if use_cache else None,
486
+ hidden_states=all_hidden_states,
487
+ attentions=all_self_attns,
488
+ )
489
+
490
+ def _update_causal_mask(
491
+ self,
492
+ attention_mask: Union[torch.Tensor, "BlockMask"],
493
+ input_tensor: torch.Tensor,
494
+ cache_position: torch.Tensor,
495
+ past_key_values: Cache,
496
+ output_attentions: bool = False,
497
+ ):
498
+ if self.config._attn_implementation == "flash_attention_2":
499
+ if attention_mask is not None and (attention_mask == 0.0).any():
500
+ return attention_mask
501
+ return None
502
+ if self.config._attn_implementation == "flex_attention":
503
+ if isinstance(attention_mask, torch.Tensor):
504
+ attention_mask = make_flex_block_causal_mask(attention_mask)
505
+ return attention_mask
506
+
507
+ # For SDPA, when possible, we will rely on its `is_causal` argument instead of its `attn_mask` argument, in
508
+ # order to dispatch on Flash Attention 2. This feature is not compatible with static cache, as SDPA will fail
509
+ # to infer the attention mask.
510
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
511
+ using_compilable_cache = past_key_values.is_compileable if past_key_values is not None else False
512
+
513
+ # When output attentions is True, sdpa implementation's forward method calls the eager implementation's forward
514
+ if self.config._attn_implementation == "sdpa" and not using_compilable_cache and not output_attentions:
515
+ if AttentionMaskConverter._ignore_causal_mask_sdpa(
516
+ attention_mask,
517
+ inputs_embeds=input_tensor,
518
+ past_key_values_length=past_seen_tokens,
519
+ is_training=self.training,
520
+ ):
521
+ return None
522
+
523
+ dtype = input_tensor.dtype
524
+ sequence_length = input_tensor.shape[1]
525
+ if using_compilable_cache:
526
+ target_length = past_key_values.get_max_cache_shape()
527
+ else:
528
+ target_length = (
529
+ attention_mask.shape[-1]
530
+ if isinstance(attention_mask, torch.Tensor)
531
+ else past_seen_tokens + sequence_length + 1
532
+ )
533
+
534
+ # In case the provided `attention` mask is 2D, we generate a causal mask here (4D).
535
+ causal_mask = self._prepare_4d_causal_attention_mask_with_cache_position(
536
+ attention_mask,
537
+ sequence_length=sequence_length,
538
+ target_length=target_length,
539
+ dtype=dtype,
540
+ cache_position=cache_position,
541
+ batch_size=input_tensor.shape[0],
542
+ )
543
+
544
+ if (
545
+ self.config._attn_implementation == "sdpa"
546
+ and attention_mask is not None
547
+ and attention_mask.device.type in ["cuda", "xpu", "npu"]
548
+ and not output_attentions
549
+ ):
550
+ # Attend to all tokens in fully masked rows in the causal_mask, for example the relevant first rows when
551
+ # using left padding. This is required by F.scaled_dot_product_attention memory-efficient attention path.
552
+ # Details: https://github.com/pytorch/pytorch/issues/110213
553
+ min_dtype = torch.finfo(dtype).min
554
+ causal_mask = AttentionMaskConverter._unmask_unattended(causal_mask, min_dtype)
555
+
556
+ return causal_mask
557
+
558
+ @staticmethod
559
+ def _prepare_4d_causal_attention_mask_with_cache_position(
560
+ attention_mask: torch.Tensor,
561
+ sequence_length: int,
562
+ target_length: int,
563
+ dtype: torch.dtype,
564
+ cache_position: torch.Tensor,
565
+ batch_size: int,
566
+ **kwargs,
567
+ ):
568
+ """
569
+ Creates a causal 4D mask of shape `(batch_size, 1, query_length, key_value_length)` from a 2D mask of shape
570
+ `(batch_size, key_value_length)`, or if the input `attention_mask` is already 4D, do nothing.
571
+
572
+ Args:
573
+ attention_mask (`torch.Tensor`):
574
+ A 2D attention mask of shape `(batch_size, key_value_length)` or a 4D attention mask of shape
575
+ `(batch_size, 1, query_length, key_value_length)`.
576
+ sequence_length (`int`):
577
+ The sequence length being processed.
578
+ target_length (`int`):
579
+ The target length: when generating with static cache, the mask should be as long as the static cache,
580
+ to account for the 0 padding, the part of the cache that is not filled yet.
581
+ dtype (`torch.dtype`):
582
+ The dtype to use for the 4D attention mask.
583
+ cache_position (`torch.Tensor`):
584
+ Indices depicting the position of the input sequence tokens in the sequence.
585
+ batch_size (`torch.Tensor`):
586
+ Batch size.
587
+ """
588
+ if attention_mask is not None and attention_mask.dim() == 4:
589
+ # In this case we assume that the mask comes already in inverted form and requires no inversion or slicing.
590
+ causal_mask = attention_mask
591
+ else:
592
+ min_dtype = torch.finfo(dtype).min
593
+ causal_mask = torch.full(
594
+ (sequence_length, target_length), fill_value=min_dtype, dtype=dtype, device=cache_position.device
595
+ )
596
+ if sequence_length != 1:
597
+ causal_mask = torch.triu(causal_mask, diagonal=1)
598
+ causal_mask *= torch.arange(target_length, device=cache_position.device) > cache_position.reshape(-1, 1)
599
+ causal_mask = causal_mask[None, None, :, :].expand(batch_size, 1, -1, -1)
600
+ if attention_mask is not None:
601
+ causal_mask = causal_mask.clone() # copy to contiguous memory for in-place edit
602
+ mask_length = attention_mask.shape[-1]
603
+ padding_mask = causal_mask[:, :, :, :mask_length] + attention_mask[:, None, None, :].to(
604
+ causal_mask.device
605
+ )
606
+ padding_mask = padding_mask == 0
607
+ causal_mask[:, :, :, :mask_length] = causal_mask[:, :, :, :mask_length].masked_fill(
608
+ padding_mask, min_dtype
609
+ )
610
+
611
+ return causal_mask
612
+
613
+
614
+ class KwargsForCausalLM(FlashAttentionKwargs, LossKwargs): ...
615
+
616
+
617
+ @auto_docstring
618
+ class MiniCPMForCausalLM(MiniCPMPreTrainedModel, GenerationMixin):
619
+ _tied_weights_keys = ["lm_head.weight"]
620
+ _tp_plan = {"lm_head": "colwise_rep"}
621
+ _pp_plan = {"lm_head": (["hidden_states"], ["logits"])}
622
+
623
+ def __init__(self, config):
624
+ super().__init__(config)
625
+ self.model = MiniCPMModel(config)
626
+ self.vocab_size = config.vocab_size
627
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
628
+
629
+ # Initialize weights and apply final processing
630
+ self.post_init()
631
+
632
+ def get_input_embeddings(self):
633
+ return self.model.embed_tokens
634
+
635
+ def set_input_embeddings(self, value):
636
+ self.model.embed_tokens = value
637
+
638
+ def get_output_embeddings(self):
639
+ return self.lm_head
640
+
641
+ def set_output_embeddings(self, new_embeddings):
642
+ self.lm_head = new_embeddings
643
+
644
+ def set_decoder(self, decoder):
645
+ self.model = decoder
646
+
647
+ def get_decoder(self):
648
+ return self.model
649
+
650
+ @can_return_tuple
651
+ @auto_docstring
652
+ def forward(
653
+ self,
654
+ input_ids: Optional[torch.LongTensor] = None,
655
+ attention_mask: Optional[torch.Tensor] = None,
656
+ position_ids: Optional[torch.LongTensor] = None,
657
+ past_key_values: Optional[Cache] = None,
658
+ inputs_embeds: Optional[torch.FloatTensor] = None,
659
+ labels: Optional[torch.LongTensor] = None,
660
+ use_cache: Optional[bool] = None,
661
+ output_attentions: Optional[bool] = None,
662
+ output_hidden_states: Optional[bool] = None,
663
+ cache_position: Optional[torch.LongTensor] = None,
664
+ logits_to_keep: Union[int, torch.Tensor] = 0,
665
+ **kwargs: Unpack[KwargsForCausalLM],
666
+ ) -> CausalLMOutputWithPast:
667
+ r"""
668
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
669
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
670
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
671
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
672
+
673
+ Example:
674
+
675
+ ```python
676
+ >>> from transformers import AutoTokenizer, MiniCPMForCausalLM
677
+
678
+ >>> model = MiniCPMForCausalLM.from_pretrained("meta-MiniCPM/MiniCPM-2-7b-hf")
679
+ >>> tokenizer = AutoTokenizer.from_pretrained("meta-MiniCPM/MiniCPM-2-7b-hf")
680
+
681
+ >>> prompt = "Hey, are you conscious? Can you talk to me?"
682
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
683
+
684
+ >>> # Generate
685
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
686
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
687
+ "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
688
+ ```"""
689
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
690
+ output_hidden_states = (
691
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
692
+ )
693
+
694
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
695
+ outputs: BaseModelOutputWithPast = self.model(
696
+ input_ids=input_ids,
697
+ attention_mask=attention_mask,
698
+ position_ids=position_ids,
699
+ past_key_values=past_key_values,
700
+ inputs_embeds=inputs_embeds,
701
+ use_cache=use_cache,
702
+ output_attentions=output_attentions,
703
+ output_hidden_states=output_hidden_states,
704
+ cache_position=cache_position,
705
+ **kwargs,
706
+ )
707
+
708
+ hidden_states = outputs.last_hidden_state
709
+ # Only compute necessary logits, and do not upcast them to float if we are not computing the loss
710
+ slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep
711
+ logits = self.lm_head(hidden_states[:, slice_indices, :] / (self.config.hidden_size / self.config.dim_model_base))
712
+
713
+ loss = None
714
+ if labels is not None:
715
+ loss = self.loss_function(logits=logits, labels=labels, vocab_size=self.config.vocab_size, **kwargs)
716
+
717
+ return CausalLMOutputWithPast(
718
+ loss=loss,
719
+ logits=logits,
720
+ past_key_values=outputs.past_key_values,
721
+ hidden_states=outputs.hidden_states,
722
+ attentions=outputs.attentions,
723
+ )
724
+
725
+
726
+ @auto_docstring(
727
+ custom_intro="""
728
+ The MiniCPM Model transformer with a sequence classification head on top (linear layer).
729
+
730
+ [`MiniCPMForSequenceClassification`] uses the last token in order to do the classification, as other causal models
731
+ (e.g. GPT-2) do.
732
+
733
+ Since it does classification on the last token, it requires to know the position of the last token. If a
734
+ `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
735
+ no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
736
+ padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
737
+ each row of the batch).
738
+ """
739
+ )
740
+ class MiniCPMForSequenceClassification(MiniCPMPreTrainedModel):
741
+ def __init__(self, config):
742
+ super().__init__(config)
743
+ self.num_labels = config.num_labels
744
+ self.model = MiniCPMModel(config)
745
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
746
+
747
+ # Initialize weights and apply final processing
748
+ self.post_init()
749
+
750
+ def get_input_embeddings(self):
751
+ return self.model.embed_tokens
752
+
753
+ def set_input_embeddings(self, value):
754
+ self.model.embed_tokens = value
755
+
756
+ @can_return_tuple
757
+ @auto_docstring
758
+ def forward(
759
+ self,
760
+ input_ids: Optional[torch.LongTensor] = None,
761
+ attention_mask: Optional[torch.Tensor] = None,
762
+ position_ids: Optional[torch.LongTensor] = None,
763
+ past_key_values: Optional[Cache] = None,
764
+ inputs_embeds: Optional[torch.FloatTensor] = None,
765
+ labels: Optional[torch.LongTensor] = None,
766
+ use_cache: Optional[bool] = None,
767
+ output_attentions: Optional[bool] = None,
768
+ output_hidden_states: Optional[bool] = None,
769
+ ) -> SequenceClassifierOutputWithPast:
770
+ r"""
771
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
772
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
773
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
774
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
775
+ """
776
+
777
+ transformer_outputs: BaseModelOutputWithPast = self.model(
778
+ input_ids,
779
+ attention_mask=attention_mask,
780
+ position_ids=position_ids,
781
+ past_key_values=past_key_values,
782
+ inputs_embeds=inputs_embeds,
783
+ use_cache=use_cache,
784
+ output_attentions=output_attentions,
785
+ output_hidden_states=output_hidden_states,
786
+ )
787
+ hidden_states = transformer_outputs.last_hidden_state
788
+ logits = self.score(hidden_states)
789
+
790
+ if input_ids is not None:
791
+ batch_size = input_ids.shape[0]
792
+ else:
793
+ batch_size = inputs_embeds.shape[0]
794
+
795
+ if self.config.pad_token_id is None and batch_size != 1:
796
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
797
+ if self.config.pad_token_id is None:
798
+ last_non_pad_token = -1
799
+ elif input_ids is not None:
800
+ # To handle both left- and right- padding, we take the rightmost token that is not equal to pad_token_id
801
+ non_pad_mask = (input_ids != self.config.pad_token_id).to(logits.device, torch.int32)
802
+ token_indices = torch.arange(input_ids.shape[-1], device=logits.device, dtype=torch.int32)
803
+ last_non_pad_token = (token_indices * non_pad_mask).argmax(-1)
804
+ else:
805
+ last_non_pad_token = -1
806
+ logger.warning_once(
807
+ f"{self.__class__.__name__} will not detect padding tokens in `inputs_embeds`. Results may be "
808
+ "unexpected if using padding tokens in conjunction with `inputs_embeds.`"
809
+ )
810
+
811
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), last_non_pad_token]
812
+
813
+ loss = None
814
+ if labels is not None:
815
+ loss = self.loss_function(logits=logits, labels=labels, pooled_logits=pooled_logits, config=self.config)
816
+
817
+ return SequenceClassifierOutputWithPast(
818
+ loss=loss,
819
+ logits=pooled_logits,
820
+ past_key_values=transformer_outputs.past_key_values,
821
+ hidden_states=transformer_outputs.hidden_states,
822
+ attentions=transformer_outputs.attentions,
823
+ )
824
+
825
+
826
+ @auto_docstring
827
+ class MiniCPMForQuestionAnswering(MiniCPMPreTrainedModel):
828
+ base_model_prefix = "transformer"
829
+
830
+ # Copied from transformers.models.bloom.modeling_bloom.BloomForQuestionAnswering.__init__ with Bloom->MiniCPM
831
+ def __init__(self, config):
832
+ super().__init__(config)
833
+ self.transformer = MiniCPMModel(config)
834
+ self.qa_outputs = nn.Linear(config.hidden_size, 2)
835
+
836
+ # Initialize weights and apply final processing
837
+ self.post_init()
838
+
839
+ def get_input_embeddings(self):
840
+ return self.transformer.embed_tokens
841
+
842
+ def set_input_embeddings(self, value):
843
+ self.transformer.embed_tokens = value
844
+
845
+ @can_return_tuple
846
+ @auto_docstring
847
+ def forward(
848
+ self,
849
+ input_ids: Optional[torch.LongTensor] = None,
850
+ attention_mask: Optional[torch.Tensor] = None,
851
+ position_ids: Optional[torch.LongTensor] = None,
852
+ past_key_values: Optional[Cache] = None,
853
+ inputs_embeds: Optional[torch.FloatTensor] = None,
854
+ start_positions: Optional[torch.LongTensor] = None,
855
+ end_positions: Optional[torch.LongTensor] = None,
856
+ output_attentions: Optional[bool] = None,
857
+ output_hidden_states: Optional[bool] = None,
858
+ **kwargs,
859
+ ) -> QuestionAnsweringModelOutput:
860
+ outputs: BaseModelOutputWithPast = self.transformer(
861
+ input_ids,
862
+ attention_mask=attention_mask,
863
+ position_ids=position_ids,
864
+ past_key_values=past_key_values,
865
+ inputs_embeds=inputs_embeds,
866
+ output_attentions=output_attentions,
867
+ output_hidden_states=output_hidden_states,
868
+ )
869
+
870
+ sequence_output = outputs.last_hidden_state
871
+
872
+ logits = self.qa_outputs(sequence_output)
873
+ start_logits, end_logits = logits.split(1, dim=-1)
874
+ start_logits = start_logits.squeeze(-1).contiguous()
875
+ end_logits = end_logits.squeeze(-1).contiguous()
876
+
877
+ loss = None
878
+ if start_positions is not None and end_positions is not None:
879
+ loss = self.loss_function(start_logits, end_logits, start_positions, end_positions, **kwargs)
880
+
881
+ return QuestionAnsweringModelOutput(
882
+ loss=loss,
883
+ start_logits=start_logits,
884
+ end_logits=end_logits,
885
+ hidden_states=outputs.hidden_states,
886
+ attentions=outputs.attentions,
887
+ )
888
+
889
+
890
+ @auto_docstring
891
+ class MiniCPMForTokenClassification(MiniCPMPreTrainedModel):
892
+ def __init__(self, config):
893
+ super().__init__(config)
894
+ self.num_labels = config.num_labels
895
+ self.model = MiniCPMModel(config)
896
+ if getattr(config, "classifier_dropout", None) is not None:
897
+ classifier_dropout = config.classifier_dropout
898
+ elif getattr(config, "hidden_dropout", None) is not None:
899
+ classifier_dropout = config.hidden_dropout
900
+ else:
901
+ classifier_dropout = 0.1
902
+ self.dropout = nn.Dropout(classifier_dropout)
903
+ self.score = nn.Linear(config.hidden_size, config.num_labels)
904
+
905
+ # Initialize weights and apply final processing
906
+ self.post_init()
907
+
908
+ def get_input_embeddings(self):
909
+ return self.model.embed_tokens
910
+
911
+ def set_input_embeddings(self, value):
912
+ self.model.embed_tokens = value
913
+
914
+ @can_return_tuple
915
+ @auto_docstring
916
+ def forward(
917
+ self,
918
+ input_ids: Optional[torch.LongTensor] = None,
919
+ attention_mask: Optional[torch.Tensor] = None,
920
+ position_ids: Optional[torch.LongTensor] = None,
921
+ past_key_values: Optional[Cache] = None,
922
+ inputs_embeds: Optional[torch.FloatTensor] = None,
923
+ labels: Optional[torch.LongTensor] = None,
924
+ use_cache: Optional[bool] = None,
925
+ output_attentions: Optional[bool] = None,
926
+ output_hidden_states: Optional[bool] = None,
927
+ ) -> TokenClassifierOutput:
928
+ r"""
929
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
930
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
931
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
932
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
933
+ """
934
+
935
+ outputs: BaseModelOutputWithPast = self.model(
936
+ input_ids,
937
+ attention_mask=attention_mask,
938
+ position_ids=position_ids,
939
+ past_key_values=past_key_values,
940
+ inputs_embeds=inputs_embeds,
941
+ use_cache=use_cache,
942
+ output_attentions=output_attentions,
943
+ output_hidden_states=output_hidden_states,
944
+ )
945
+ sequence_output = outputs.last_hidden_state
946
+ sequence_output = self.dropout(sequence_output)
947
+ logits = self.score(sequence_output)
948
+
949
+ loss = None
950
+ if labels is not None:
951
+ loss = self.loss_function(logits, labels, self.config)
952
+
953
+ return TokenClassifierOutput(
954
+ loss=loss,
955
+ logits=logits,
956
+ hidden_states=outputs.hidden_states,
957
+ attentions=outputs.attentions,
958
+ )
959
+
960
+
961
+ __all__ = [
962
+ "MiniCPMForCausalLM",
963
+ "MiniCPMModel",
964
+ "MiniCPMPreTrainedModel",
965
+ "MiniCPMForSequenceClassification",
966
+ "MiniCPMForQuestionAnswering",
967
+ "MiniCPMForTokenClassification",
968
+ ]
special_tokens_map.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_end|>",
4
+ "<|im_start|>",
5
+ "<|tool_call|>",
6
+ "<|execute_start|>",
7
+ "<|execute_end|>",
8
+ "<|fim_prefix|>",
9
+ "<|fim_middle|>",
10
+ "<|fim_suffix|>"
11
+ ],
12
+ "bos_token": {
13
+ "content": "<s>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false
18
+ },
19
+ "eos_token": {
20
+ "content": "<|im_end|>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false
25
+ },
26
+ "pad_token": {
27
+ "content": "<|im_end|>",
28
+ "lstrip": false,
29
+ "normalized": false,
30
+ "rstrip": false,
31
+ "single_word": false
32
+ },
33
+ "unk_token": {
34
+ "content": "<unk>",
35
+ "lstrip": false,
36
+ "normalized": false,
37
+ "rstrip": false,
38
+ "single_word": false
39
+ }
40
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bb74d51116831c3bf65db812c553f94ab0c88dcf97a5bbb37e3504f6d359c530
3
+ size 1181204
tokenizer_config.json ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": null,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "</s>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ },
30
+ "73440": {
31
+ "content": "<|im_end|>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": true
37
+ },
38
+ "73441": {
39
+ "content": "<|im_start|>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": true
45
+ },
46
+ "73442": {
47
+ "content": "<|tool_call|>",
48
+ "lstrip": false,
49
+ "normalized": false,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": true
53
+ },
54
+ "73443": {
55
+ "content": "<|execute_start|>",
56
+ "lstrip": false,
57
+ "normalized": false,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": true
61
+ },
62
+ "73444": {
63
+ "content": "<|execute_end|>",
64
+ "lstrip": false,
65
+ "normalized": false,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": true
69
+ },
70
+ "73445": {
71
+ "content": "<|fim_prefix|>",
72
+ "lstrip": false,
73
+ "normalized": false,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": true
77
+ },
78
+ "73446": {
79
+ "content": "<|fim_middle|>",
80
+ "lstrip": false,
81
+ "normalized": false,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": true
85
+ },
86
+ "73447": {
87
+ "content": "<|fim_suffix|>",
88
+ "lstrip": false,
89
+ "normalized": false,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": true
93
+ }
94
+ },
95
+ "additional_special_tokens": [
96
+ "<|im_end|>",
97
+ "<|im_start|>",
98
+ "<|tool_call|>",
99
+ "<|execute_start|>",
100
+ "<|execute_end|>",
101
+ "<|fim_prefix|>",
102
+ "<|fim_middle|>",
103
+ "<|fim_suffix|>"
104
+ ],
105
+ "bos_token": "<s>",
106
+ "clean_up_tokenization_spaces": false,
107
+ "eos_token": "<|im_end|>",
108
+ "extra_special_tokens": {},
109
+ "legacy": true,
110
+ "model_max_length": 1000000000000000019884624838656,
111
+ "pad_token": "<|im_end|>",
112
+ "sp_model_kwargs": {},
113
+ "spaces_between_special_tokens": false,
114
+ "tokenizer_class": "LlamaTokenizer",
115
+ "unk_token": "<unk>",
116
+ "use_default_system_prompt": false
117
+ }