madgnu commited on
Commit
c7736b8
·
verified ·
1 Parent(s): b60f318

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,11 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: ai-sage/GigaChat-20B-A3B-instruct
4
+ language:
5
+ - ru
6
+ - en
7
+ tags:
8
+ - mlx
9
+ library_name: mlx
10
+ pipeline_tag: text-generation
11
+ ---
chat_template.jinja ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% if messages[0]['role'] == 'system' -%}
2
+ {%- set loop_messages = messages[1:] -%}
3
+ {%- set system_message = bos_token + messages[0]['content'] + additional_special_tokens[1] -%}
4
+ {%- else -%}
5
+ {%- set loop_messages = messages -%}
6
+ {%- set system_message = bos_token + '' -%}
7
+ {%- endif -%}
8
+ {%- for message in loop_messages %}
9
+ {% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}
10
+ {{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}
11
+ {% endif %}
12
+
13
+ {%- if loop.index0 == 0 -%}
14
+ {{ system_message -}}
15
+ {%- endif -%}
16
+ {%- if message['role'] == 'user' -%}
17
+ {{ message['role'] + additional_special_tokens[0] + message['content'] + additional_special_tokens[1] -}}
18
+ {{ 'available functions' + additional_special_tokens[0] + additional_special_tokens[2] + additional_special_tokens[3] + additional_special_tokens[1] -}}
19
+ {%- endif -%}
20
+ {%- if message['role'] == 'assistant' -%}
21
+ {{ message['role'] + additional_special_tokens[0] + message['content'] + additional_special_tokens[1] -}}
22
+ {%- endif -%}
23
+ {%- if loop.last and add_generation_prompt -%}
24
+ {{ 'assistant' + additional_special_tokens[0] -}}
25
+ {%- endif -%}
26
+ {%- endfor %}
config.json ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DeepseekForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_deepseek.DeepseekConfig",
9
+ "AutoModel": "modelling_deepseek.DeepseekModel",
10
+ "AutoModelForCausalLM": "modelling_deepseek.DeepseekForCausalLM"
11
+ },
12
+ "aux_loss_alpha": 0.001,
13
+ "bos_token_id": 1,
14
+ "eos_token_id": 128001,
15
+ "first_k_dense_replace": 1,
16
+ "head_dim": 128,
17
+ "hidden_act": "silu",
18
+ "hidden_size": 2048,
19
+ "initializer_range": 0.006,
20
+ "intermediate_size": 14336,
21
+ "max_position_embeddings": 131072,
22
+ "mlp_bias": false,
23
+ "model_type": "deepseek",
24
+ "moe_implementation": "eager",
25
+ "moe_intermediate_size": 1792,
26
+ "moe_layer_freq": 1,
27
+ "n_routed_experts": 64,
28
+ "n_shared_experts": 2,
29
+ "norm_topk_prob": false,
30
+ "num_attention_heads": 16,
31
+ "num_experts_per_tok": 6,
32
+ "num_hidden_layers": 28,
33
+ "num_key_value_heads": 8,
34
+ "pad_token_id": 1,
35
+ "pretraining_tp": 1,
36
+ "quantization": {
37
+ "group_size": 64,
38
+ "bits": 4
39
+ },
40
+ "quantization_config": {
41
+ "group_size": 64,
42
+ "bits": 4
43
+ },
44
+ "rms_norm_eps": 1e-05,
45
+ "rope_scaling": null,
46
+ "rope_theta": 1400000,
47
+ "scoring_func": "softmax",
48
+ "seq_aux": true,
49
+ "tie_word_embeddings": false,
50
+ "torch_dtype": "float32",
51
+ "transformers_version": "4.47.0",
52
+ "use_cache": true,
53
+ "vocab_size": 128256
54
+ }
configuration_deepseek.py ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Deepseek Moe model configuration"""
2
+ from transformers.utils import logging
3
+ from transformers.configuration_utils import PretrainedConfig
4
+ from transformers.modeling_rope_utils import rope_config_validation
5
+
6
+ logger = logging.get_logger(__name__)
7
+
8
+ DEEPSEEK_FIXES_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
9
+ class DeepseekConfig(PretrainedConfig):
10
+ r"""
11
+ This is the configuration class to store the configuration of a DeepseekModel`]. It is used to instantiate an DeepSeek
12
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
13
+ defaults will yield a similar configuration to that of the DeepseekModel-20b.
14
+
15
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
16
+ documentation from [`PretrainedConfig`] for more information.
17
+
18
+
19
+ Args:
20
+ vocab_size (`int`, *optional*, defaults to 128256):
21
+ Vocabulary size of the Deep model. Defines the number of different tokens that can be represented by the
22
+ `inputs_ids` passed when calling [`DeepseekModel`]
23
+ hidden_size (`int`, *optional*, defaults to 4096):
24
+ Dimension of the hidden representations.
25
+ intermediate_size (`int`, *optional*, defaults to 11008):
26
+ Dimension of the MLP representations.
27
+ moe_intermediate_size (`int`, *optional*, defaults to 1792):
28
+ Dimension of the MoE representations.
29
+ num_hidden_layers (`int`, *optional*, defaults to 32):
30
+ Number of hidden layers in the Transformer decoder.
31
+ num_attention_heads (`int`, *optional*, defaults to 32):
32
+ Number of attention heads for each attention layer in the Transformer decoder.
33
+ n_shared_experts (`int`, *optional*, defaults to None):
34
+ Number of shared experts, None means dense model.
35
+ n_routed_experts (`int`, *optional*, defaults to None):
36
+ Number of routed experts, None means dense model.
37
+ num_experts_per_tok (`int`, *optional*, defaults to None):
38
+ Number of selected experts, None means dense model.
39
+ moe_layer_freq (`int`, *optional*, defaults to 1):
40
+ The frequency of the MoE layer: one expert layer for every `moe_layer_freq - 1` dense layers.
41
+ first_k_dense_replace (`int`, *optional*, defaults to 0):
42
+ Number of dense layers in shallow layers(embed->dense->dense->...->dense->moe->moe...->lm_head).
43
+ \--k dense layers--/
44
+ norm_topk_prob (`bool`, *optional*, defaults to False):
45
+ Whether to normalize the weights of the routed experts.
46
+ scoring_func (`str`, *optional*, defaults to 'softmax'):
47
+ Method of computing expert weights.
48
+ aux_loss_alpha (`float`, *optional*, defaults to 0.001):
49
+ Auxiliary loss weight coefficient.
50
+ seq_aux = (`bool`, *optional*, defaults to True):
51
+ Whether to compute the auxiliary loss for each individual sample.
52
+ num_key_value_heads (`int`, *optional*):
53
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
54
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
55
+ `num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
56
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
57
+ by meanpooling all the original heads within that group. For more details checkout [this
58
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
59
+ `num_attention_heads`.
60
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
61
+ The non-linear activation function (function or string) in the decoder.
62
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
63
+ The maximum sequence length that this model might ever be used with.
64
+ initializer_range (`float`, *optional*, defaults to 0.02):
65
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
66
+ rms_norm_eps (`float`, *optional*, defaults to 1e-06):
67
+ The epsilon used by the rms normalization layers.
68
+ use_cache (`bool`, *optional*, defaults to `True`):
69
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
70
+ relevant if `config.is_decoder=True`.
71
+ pad_token_id (`int`, *optional*):
72
+ Padding token id.
73
+ bos_token_id (`int`, *optional*, defaults to 1):
74
+ Beginning of stream token id.
75
+ eos_token_id (`int`, *optional*, defaults to 2):
76
+ End of stream token id.
77
+ pretraining_tp (`int`, *optional*, defaults to 1):
78
+ Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
79
+ document](https://huggingface.co/docs/transformers/main/perf_train_gpu_many#tensor-parallelism) to
80
+ understand more about it. This value is necessary to ensure exact reproducibility of the pretraining
81
+ results. Please refer to [this issue](https://github.com/pytorch/pytorch/issues/76232).
82
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
83
+ Whether to tie weight embeddings
84
+ rope_theta (`float`, *optional*, defaults to 10000.0):
85
+ The base period of the RoPE embeddings.
86
+ rope_scaling (`Dict`, *optional*):
87
+ Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
88
+ and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
89
+ accordingly.
90
+ Expected contents:
91
+ `rope_type` (`str`):
92
+ The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
93
+ 'llama3'], with 'default' being the original RoPE implementation.
94
+ `factor` (`float`, *optional*):
95
+ Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
96
+ most scaling types, a `factor` of x will enable the model to handle sequences of length x *
97
+ original maximum pre-trained length.
98
+ `original_max_position_embeddings` (`int`, *optional*):
99
+ Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
100
+ pretraining.
101
+ `attention_factor` (`float`, *optional*):
102
+ Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
103
+ computation. If unspecified, it defaults to value recommended by the implementation, using the
104
+ `factor` field to infer the suggested value.
105
+ `beta_fast` (`float`, *optional*):
106
+ Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
107
+ ramp function. If unspecified, it defaults to 32.
108
+ `beta_slow` (`float`, *optional*):
109
+ Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
110
+ ramp function. If unspecified, it defaults to 1.
111
+ `short_factor` (`List[float]`, *optional*):
112
+ Only used with 'longrope'. The scaling factor to be applied to short contexts (<
113
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
114
+ size divided by the number of attention heads divided by 2
115
+ `long_factor` (`List[float]`, *optional*):
116
+ Only used with 'longrope'. The scaling factor to be applied to long contexts (<
117
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
118
+ size divided by the number of attention heads divided by 2
119
+ `low_freq_factor` (`float`, *optional*):
120
+ Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
121
+ `high_freq_factor` (`float`, *optional*):
122
+ Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
123
+ attention_bias (`bool`, *optional*, defaults to `False`):
124
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
125
+ attention_dropout (`float`, *optional*, defaults to 0.0):
126
+ The dropout ratio for the attention probabilities.
127
+ mlp_bias (`bool`, *optional*, defaults to `False`):
128
+ Whether to use a bias in up_proj, down_proj and gate_proj layers in the MLP layers.
129
+ head_dim (`int`, *optional*):
130
+ The attention head dimension. If None, it will default to hidden_size // num_heads
131
+
132
+ ```python
133
+ >>> from transformers import DeepseekModel, DeepseekConfig
134
+
135
+ >>> configuration = DeepseekConfig()
136
+ >>> model = DeepseekModel(configuration)
137
+
138
+ >>> # Accessing the model configuration
139
+ >>> configuration = model.config
140
+ ```"""
141
+
142
+ model_type = "deepseek"
143
+ keys_to_ignore_at_inference = ["past_key_values"]
144
+
145
+ def __init__(
146
+ self,
147
+ vocab_size=128256,
148
+ hidden_size=2048,
149
+ intermediate_size=14336,
150
+ moe_intermediate_size = 1792,
151
+ num_hidden_layers=28,
152
+ num_attention_heads=16,
153
+ num_key_value_heads=8,
154
+ n_shared_experts = None,
155
+ n_routed_experts = None,
156
+ num_experts_per_tok = None,
157
+ moe_layer_freq = 1,
158
+ first_k_dense_replace = 0,
159
+ norm_topk_prob = False,
160
+ scoring_func = 'softmax',
161
+ aux_loss_alpha = 0.001,
162
+ seq_aux = True,
163
+ hidden_act="silu",
164
+ max_position_embeddings=2048,
165
+ initializer_range=0.02,
166
+ rms_norm_eps=1e-6,
167
+ use_cache=True,
168
+ pad_token_id=None,
169
+ bos_token_id=1,
170
+ eos_token_id=2,
171
+ pretraining_tp=1,
172
+ tie_word_embeddings=False,
173
+ rope_theta=10000.0,
174
+ rope_scaling=None,
175
+ attention_bias=False,
176
+ attention_dropout=0.0,
177
+ moe_implementation="eager",
178
+ mlp_bias=False,
179
+ head_dim=None,
180
+ **kwargs,
181
+ ):
182
+ assert moe_implementation in ('eager', ), "Invalid moe_implementation value."
183
+ self.vocab_size = vocab_size
184
+ self.max_position_embeddings = max_position_embeddings
185
+ self.hidden_size = hidden_size
186
+ self.intermediate_size = intermediate_size
187
+ self.moe_intermediate_size = moe_intermediate_size
188
+ self.num_hidden_layers = num_hidden_layers
189
+ self.num_attention_heads = num_attention_heads
190
+ self.n_shared_experts = n_shared_experts
191
+ self.n_routed_experts = n_routed_experts
192
+ self.num_experts_per_tok = num_experts_per_tok
193
+ self.moe_layer_freq = moe_layer_freq
194
+ self.first_k_dense_replace = first_k_dense_replace
195
+ self.norm_topk_prob = norm_topk_prob
196
+ self.scoring_func = scoring_func
197
+ self.aux_loss_alpha = aux_loss_alpha
198
+ self.seq_aux = seq_aux
199
+
200
+ # for backward compatibility
201
+ if num_key_value_heads is None:
202
+ num_key_value_heads = num_attention_heads
203
+
204
+ self.num_key_value_heads = num_key_value_heads
205
+ self.hidden_act = hidden_act
206
+ self.initializer_range = initializer_range
207
+ self.rms_norm_eps = rms_norm_eps
208
+ self.pretraining_tp = pretraining_tp
209
+ self.use_cache = use_cache
210
+ self.rope_theta = rope_theta
211
+ self.rope_scaling = rope_scaling
212
+ self.attention_bias = attention_bias
213
+ self.attention_dropout = attention_dropout
214
+ self.mlp_bias = mlp_bias
215
+ self.head_dim = head_dim if head_dim is not None else self.hidden_size // self.num_attention_heads
216
+ # Validate the correctness of rotary position embeddings parameters
217
+ # BC: if there is a 'type' field, copy it it to 'rope_type'.
218
+ if self.rope_scaling is not None and "type" in self.rope_scaling:
219
+ self.rope_scaling["rope_type"] = self.rope_scaling["type"]
220
+ rope_config_validation(self)
221
+ self.moe_implementation = moe_implementation
222
+
223
+ super().__init__(
224
+ pad_token_id=pad_token_id,
225
+ bos_token_id=bos_token_id,
226
+ eos_token_id=eos_token_id,
227
+ tie_word_embeddings=tie_word_embeddings,
228
+ **kwargs,
229
+ )
generation_config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 128001,
5
+ "max_new_tokens": 2048,
6
+ "pad_token_id": 2,
7
+ "transformers_version": "4.47.0"
8
+ }
model-00001-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c90d10851d4e67b8b1e6f25ad139817eca9e91f9663f22637f0c2c18c4c964e9
3
+ size 5323274886
model-00002-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e35d24d69ace7a21a98785ecd05fd51f2bf48ba10826c1ac40e97a575ed37243
3
+ size 5367229855
model-00003-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7238b79ec87ba556c0ef290140934e6c89b6a20bf2c3304020ee940175419180
3
+ size 2190255952
model.safetensors.index.json ADDED
@@ -0,0 +1,929 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 12880650240,
4
+ "total_parameters": 20589299712
5
+ },
6
+ "weight_map": {
7
+ "lm_head.biases": "model-00003-of-00003.safetensors",
8
+ "lm_head.scales": "model-00003-of-00003.safetensors",
9
+ "lm_head.weight": "model-00003-of-00003.safetensors",
10
+ "model.embed_tokens.biases": "model-00001-of-00003.safetensors",
11
+ "model.embed_tokens.scales": "model-00001-of-00003.safetensors",
12
+ "model.embed_tokens.weight": "model-00001-of-00003.safetensors",
13
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00003.safetensors",
14
+ "model.layers.0.mlp.down_proj.biases": "model-00001-of-00003.safetensors",
15
+ "model.layers.0.mlp.down_proj.scales": "model-00001-of-00003.safetensors",
16
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
17
+ "model.layers.0.mlp.gate_proj.biases": "model-00001-of-00003.safetensors",
18
+ "model.layers.0.mlp.gate_proj.scales": "model-00001-of-00003.safetensors",
19
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
20
+ "model.layers.0.mlp.up_proj.biases": "model-00001-of-00003.safetensors",
21
+ "model.layers.0.mlp.up_proj.scales": "model-00001-of-00003.safetensors",
22
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
23
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
24
+ "model.layers.0.self_attn.k_proj.biases": "model-00001-of-00003.safetensors",
25
+ "model.layers.0.self_attn.k_proj.scales": "model-00001-of-00003.safetensors",
26
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
27
+ "model.layers.0.self_attn.o_proj.biases": "model-00001-of-00003.safetensors",
28
+ "model.layers.0.self_attn.o_proj.scales": "model-00001-of-00003.safetensors",
29
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
30
+ "model.layers.0.self_attn.q_proj.biases": "model-00001-of-00003.safetensors",
31
+ "model.layers.0.self_attn.q_proj.scales": "model-00001-of-00003.safetensors",
32
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
33
+ "model.layers.0.self_attn.v_proj.biases": "model-00001-of-00003.safetensors",
34
+ "model.layers.0.self_attn.v_proj.scales": "model-00001-of-00003.safetensors",
35
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
36
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00003.safetensors",
37
+ "model.layers.1.mlp.gate.weight": "model-00001-of-00003.safetensors",
38
+ "model.layers.1.mlp.shared_experts.down_proj.biases": "model-00001-of-00003.safetensors",
39
+ "model.layers.1.mlp.shared_experts.down_proj.scales": "model-00001-of-00003.safetensors",
40
+ "model.layers.1.mlp.shared_experts.down_proj.weight": "model-00001-of-00003.safetensors",
41
+ "model.layers.1.mlp.shared_experts.gate_proj.biases": "model-00001-of-00003.safetensors",
42
+ "model.layers.1.mlp.shared_experts.gate_proj.scales": "model-00001-of-00003.safetensors",
43
+ "model.layers.1.mlp.shared_experts.gate_proj.weight": "model-00001-of-00003.safetensors",
44
+ "model.layers.1.mlp.shared_experts.up_proj.biases": "model-00001-of-00003.safetensors",
45
+ "model.layers.1.mlp.shared_experts.up_proj.scales": "model-00001-of-00003.safetensors",
46
+ "model.layers.1.mlp.shared_experts.up_proj.weight": "model-00001-of-00003.safetensors",
47
+ "model.layers.1.mlp.switch_mlp.down_proj.biases": "model-00001-of-00003.safetensors",
48
+ "model.layers.1.mlp.switch_mlp.down_proj.scales": "model-00001-of-00003.safetensors",
49
+ "model.layers.1.mlp.switch_mlp.down_proj.weight": "model-00001-of-00003.safetensors",
50
+ "model.layers.1.mlp.switch_mlp.gate_proj.biases": "model-00001-of-00003.safetensors",
51
+ "model.layers.1.mlp.switch_mlp.gate_proj.scales": "model-00001-of-00003.safetensors",
52
+ "model.layers.1.mlp.switch_mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
53
+ "model.layers.1.mlp.switch_mlp.up_proj.biases": "model-00001-of-00003.safetensors",
54
+ "model.layers.1.mlp.switch_mlp.up_proj.scales": "model-00001-of-00003.safetensors",
55
+ "model.layers.1.mlp.switch_mlp.up_proj.weight": "model-00001-of-00003.safetensors",
56
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
57
+ "model.layers.1.self_attn.k_proj.biases": "model-00001-of-00003.safetensors",
58
+ "model.layers.1.self_attn.k_proj.scales": "model-00001-of-00003.safetensors",
59
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
60
+ "model.layers.1.self_attn.o_proj.biases": "model-00001-of-00003.safetensors",
61
+ "model.layers.1.self_attn.o_proj.scales": "model-00001-of-00003.safetensors",
62
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
63
+ "model.layers.1.self_attn.q_proj.biases": "model-00001-of-00003.safetensors",
64
+ "model.layers.1.self_attn.q_proj.scales": "model-00001-of-00003.safetensors",
65
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
66
+ "model.layers.1.self_attn.v_proj.biases": "model-00001-of-00003.safetensors",
67
+ "model.layers.1.self_attn.v_proj.scales": "model-00001-of-00003.safetensors",
68
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
69
+ "model.layers.10.input_layernorm.weight": "model-00001-of-00003.safetensors",
70
+ "model.layers.10.mlp.gate.weight": "model-00001-of-00003.safetensors",
71
+ "model.layers.10.mlp.shared_experts.down_proj.biases": "model-00001-of-00003.safetensors",
72
+ "model.layers.10.mlp.shared_experts.down_proj.scales": "model-00001-of-00003.safetensors",
73
+ "model.layers.10.mlp.shared_experts.down_proj.weight": "model-00001-of-00003.safetensors",
74
+ "model.layers.10.mlp.shared_experts.gate_proj.biases": "model-00001-of-00003.safetensors",
75
+ "model.layers.10.mlp.shared_experts.gate_proj.scales": "model-00001-of-00003.safetensors",
76
+ "model.layers.10.mlp.shared_experts.gate_proj.weight": "model-00001-of-00003.safetensors",
77
+ "model.layers.10.mlp.shared_experts.up_proj.biases": "model-00001-of-00003.safetensors",
78
+ "model.layers.10.mlp.shared_experts.up_proj.scales": "model-00001-of-00003.safetensors",
79
+ "model.layers.10.mlp.shared_experts.up_proj.weight": "model-00001-of-00003.safetensors",
80
+ "model.layers.10.mlp.switch_mlp.down_proj.biases": "model-00001-of-00003.safetensors",
81
+ "model.layers.10.mlp.switch_mlp.down_proj.scales": "model-00001-of-00003.safetensors",
82
+ "model.layers.10.mlp.switch_mlp.down_proj.weight": "model-00001-of-00003.safetensors",
83
+ "model.layers.10.mlp.switch_mlp.gate_proj.biases": "model-00001-of-00003.safetensors",
84
+ "model.layers.10.mlp.switch_mlp.gate_proj.scales": "model-00001-of-00003.safetensors",
85
+ "model.layers.10.mlp.switch_mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
86
+ "model.layers.10.mlp.switch_mlp.up_proj.biases": "model-00001-of-00003.safetensors",
87
+ "model.layers.10.mlp.switch_mlp.up_proj.scales": "model-00001-of-00003.safetensors",
88
+ "model.layers.10.mlp.switch_mlp.up_proj.weight": "model-00001-of-00003.safetensors",
89
+ "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
90
+ "model.layers.10.self_attn.k_proj.biases": "model-00001-of-00003.safetensors",
91
+ "model.layers.10.self_attn.k_proj.scales": "model-00001-of-00003.safetensors",
92
+ "model.layers.10.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
93
+ "model.layers.10.self_attn.o_proj.biases": "model-00001-of-00003.safetensors",
94
+ "model.layers.10.self_attn.o_proj.scales": "model-00001-of-00003.safetensors",
95
+ "model.layers.10.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
96
+ "model.layers.10.self_attn.q_proj.biases": "model-00001-of-00003.safetensors",
97
+ "model.layers.10.self_attn.q_proj.scales": "model-00001-of-00003.safetensors",
98
+ "model.layers.10.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
99
+ "model.layers.10.self_attn.v_proj.biases": "model-00001-of-00003.safetensors",
100
+ "model.layers.10.self_attn.v_proj.scales": "model-00001-of-00003.safetensors",
101
+ "model.layers.10.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
102
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00003.safetensors",
103
+ "model.layers.11.mlp.gate.weight": "model-00001-of-00003.safetensors",
104
+ "model.layers.11.mlp.shared_experts.down_proj.biases": "model-00001-of-00003.safetensors",
105
+ "model.layers.11.mlp.shared_experts.down_proj.scales": "model-00001-of-00003.safetensors",
106
+ "model.layers.11.mlp.shared_experts.down_proj.weight": "model-00001-of-00003.safetensors",
107
+ "model.layers.11.mlp.shared_experts.gate_proj.biases": "model-00001-of-00003.safetensors",
108
+ "model.layers.11.mlp.shared_experts.gate_proj.scales": "model-00001-of-00003.safetensors",
109
+ "model.layers.11.mlp.shared_experts.gate_proj.weight": "model-00001-of-00003.safetensors",
110
+ "model.layers.11.mlp.shared_experts.up_proj.biases": "model-00001-of-00003.safetensors",
111
+ "model.layers.11.mlp.shared_experts.up_proj.scales": "model-00001-of-00003.safetensors",
112
+ "model.layers.11.mlp.shared_experts.up_proj.weight": "model-00001-of-00003.safetensors",
113
+ "model.layers.11.mlp.switch_mlp.down_proj.biases": "model-00001-of-00003.safetensors",
114
+ "model.layers.11.mlp.switch_mlp.down_proj.scales": "model-00001-of-00003.safetensors",
115
+ "model.layers.11.mlp.switch_mlp.down_proj.weight": "model-00001-of-00003.safetensors",
116
+ "model.layers.11.mlp.switch_mlp.gate_proj.biases": "model-00001-of-00003.safetensors",
117
+ "model.layers.11.mlp.switch_mlp.gate_proj.scales": "model-00001-of-00003.safetensors",
118
+ "model.layers.11.mlp.switch_mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
119
+ "model.layers.11.mlp.switch_mlp.up_proj.biases": "model-00001-of-00003.safetensors",
120
+ "model.layers.11.mlp.switch_mlp.up_proj.scales": "model-00001-of-00003.safetensors",
121
+ "model.layers.11.mlp.switch_mlp.up_proj.weight": "model-00001-of-00003.safetensors",
122
+ "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
123
+ "model.layers.11.self_attn.k_proj.biases": "model-00001-of-00003.safetensors",
124
+ "model.layers.11.self_attn.k_proj.scales": "model-00001-of-00003.safetensors",
125
+ "model.layers.11.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
126
+ "model.layers.11.self_attn.o_proj.biases": "model-00001-of-00003.safetensors",
127
+ "model.layers.11.self_attn.o_proj.scales": "model-00001-of-00003.safetensors",
128
+ "model.layers.11.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
129
+ "model.layers.11.self_attn.q_proj.biases": "model-00001-of-00003.safetensors",
130
+ "model.layers.11.self_attn.q_proj.scales": "model-00001-of-00003.safetensors",
131
+ "model.layers.11.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
132
+ "model.layers.11.self_attn.v_proj.biases": "model-00001-of-00003.safetensors",
133
+ "model.layers.11.self_attn.v_proj.scales": "model-00001-of-00003.safetensors",
134
+ "model.layers.11.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
135
+ "model.layers.12.input_layernorm.weight": "model-00002-of-00003.safetensors",
136
+ "model.layers.12.mlp.gate.weight": "model-00002-of-00003.safetensors",
137
+ "model.layers.12.mlp.shared_experts.down_proj.biases": "model-00002-of-00003.safetensors",
138
+ "model.layers.12.mlp.shared_experts.down_proj.scales": "model-00002-of-00003.safetensors",
139
+ "model.layers.12.mlp.shared_experts.down_proj.weight": "model-00002-of-00003.safetensors",
140
+ "model.layers.12.mlp.shared_experts.gate_proj.biases": "model-00002-of-00003.safetensors",
141
+ "model.layers.12.mlp.shared_experts.gate_proj.scales": "model-00002-of-00003.safetensors",
142
+ "model.layers.12.mlp.shared_experts.gate_proj.weight": "model-00002-of-00003.safetensors",
143
+ "model.layers.12.mlp.shared_experts.up_proj.biases": "model-00002-of-00003.safetensors",
144
+ "model.layers.12.mlp.shared_experts.up_proj.scales": "model-00002-of-00003.safetensors",
145
+ "model.layers.12.mlp.shared_experts.up_proj.weight": "model-00002-of-00003.safetensors",
146
+ "model.layers.12.mlp.switch_mlp.down_proj.biases": "model-00002-of-00003.safetensors",
147
+ "model.layers.12.mlp.switch_mlp.down_proj.scales": "model-00002-of-00003.safetensors",
148
+ "model.layers.12.mlp.switch_mlp.down_proj.weight": "model-00002-of-00003.safetensors",
149
+ "model.layers.12.mlp.switch_mlp.gate_proj.biases": "model-00002-of-00003.safetensors",
150
+ "model.layers.12.mlp.switch_mlp.gate_proj.scales": "model-00002-of-00003.safetensors",
151
+ "model.layers.12.mlp.switch_mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
152
+ "model.layers.12.mlp.switch_mlp.up_proj.biases": "model-00002-of-00003.safetensors",
153
+ "model.layers.12.mlp.switch_mlp.up_proj.scales": "model-00002-of-00003.safetensors",
154
+ "model.layers.12.mlp.switch_mlp.up_proj.weight": "model-00002-of-00003.safetensors",
155
+ "model.layers.12.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
156
+ "model.layers.12.self_attn.k_proj.biases": "model-00001-of-00003.safetensors",
157
+ "model.layers.12.self_attn.k_proj.scales": "model-00001-of-00003.safetensors",
158
+ "model.layers.12.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
159
+ "model.layers.12.self_attn.o_proj.biases": "model-00001-of-00003.safetensors",
160
+ "model.layers.12.self_attn.o_proj.scales": "model-00001-of-00003.safetensors",
161
+ "model.layers.12.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
162
+ "model.layers.12.self_attn.q_proj.biases": "model-00001-of-00003.safetensors",
163
+ "model.layers.12.self_attn.q_proj.scales": "model-00001-of-00003.safetensors",
164
+ "model.layers.12.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
165
+ "model.layers.12.self_attn.v_proj.biases": "model-00001-of-00003.safetensors",
166
+ "model.layers.12.self_attn.v_proj.scales": "model-00001-of-00003.safetensors",
167
+ "model.layers.12.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
168
+ "model.layers.13.input_layernorm.weight": "model-00002-of-00003.safetensors",
169
+ "model.layers.13.mlp.gate.weight": "model-00002-of-00003.safetensors",
170
+ "model.layers.13.mlp.shared_experts.down_proj.biases": "model-00002-of-00003.safetensors",
171
+ "model.layers.13.mlp.shared_experts.down_proj.scales": "model-00002-of-00003.safetensors",
172
+ "model.layers.13.mlp.shared_experts.down_proj.weight": "model-00002-of-00003.safetensors",
173
+ "model.layers.13.mlp.shared_experts.gate_proj.biases": "model-00002-of-00003.safetensors",
174
+ "model.layers.13.mlp.shared_experts.gate_proj.scales": "model-00002-of-00003.safetensors",
175
+ "model.layers.13.mlp.shared_experts.gate_proj.weight": "model-00002-of-00003.safetensors",
176
+ "model.layers.13.mlp.shared_experts.up_proj.biases": "model-00002-of-00003.safetensors",
177
+ "model.layers.13.mlp.shared_experts.up_proj.scales": "model-00002-of-00003.safetensors",
178
+ "model.layers.13.mlp.shared_experts.up_proj.weight": "model-00002-of-00003.safetensors",
179
+ "model.layers.13.mlp.switch_mlp.down_proj.biases": "model-00002-of-00003.safetensors",
180
+ "model.layers.13.mlp.switch_mlp.down_proj.scales": "model-00002-of-00003.safetensors",
181
+ "model.layers.13.mlp.switch_mlp.down_proj.weight": "model-00002-of-00003.safetensors",
182
+ "model.layers.13.mlp.switch_mlp.gate_proj.biases": "model-00002-of-00003.safetensors",
183
+ "model.layers.13.mlp.switch_mlp.gate_proj.scales": "model-00002-of-00003.safetensors",
184
+ "model.layers.13.mlp.switch_mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
185
+ "model.layers.13.mlp.switch_mlp.up_proj.biases": "model-00002-of-00003.safetensors",
186
+ "model.layers.13.mlp.switch_mlp.up_proj.scales": "model-00002-of-00003.safetensors",
187
+ "model.layers.13.mlp.switch_mlp.up_proj.weight": "model-00002-of-00003.safetensors",
188
+ "model.layers.13.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
189
+ "model.layers.13.self_attn.k_proj.biases": "model-00002-of-00003.safetensors",
190
+ "model.layers.13.self_attn.k_proj.scales": "model-00002-of-00003.safetensors",
191
+ "model.layers.13.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
192
+ "model.layers.13.self_attn.o_proj.biases": "model-00002-of-00003.safetensors",
193
+ "model.layers.13.self_attn.o_proj.scales": "model-00002-of-00003.safetensors",
194
+ "model.layers.13.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
195
+ "model.layers.13.self_attn.q_proj.biases": "model-00002-of-00003.safetensors",
196
+ "model.layers.13.self_attn.q_proj.scales": "model-00002-of-00003.safetensors",
197
+ "model.layers.13.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
198
+ "model.layers.13.self_attn.v_proj.biases": "model-00002-of-00003.safetensors",
199
+ "model.layers.13.self_attn.v_proj.scales": "model-00002-of-00003.safetensors",
200
+ "model.layers.13.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
201
+ "model.layers.14.input_layernorm.weight": "model-00002-of-00003.safetensors",
202
+ "model.layers.14.mlp.gate.weight": "model-00002-of-00003.safetensors",
203
+ "model.layers.14.mlp.shared_experts.down_proj.biases": "model-00002-of-00003.safetensors",
204
+ "model.layers.14.mlp.shared_experts.down_proj.scales": "model-00002-of-00003.safetensors",
205
+ "model.layers.14.mlp.shared_experts.down_proj.weight": "model-00002-of-00003.safetensors",
206
+ "model.layers.14.mlp.shared_experts.gate_proj.biases": "model-00002-of-00003.safetensors",
207
+ "model.layers.14.mlp.shared_experts.gate_proj.scales": "model-00002-of-00003.safetensors",
208
+ "model.layers.14.mlp.shared_experts.gate_proj.weight": "model-00002-of-00003.safetensors",
209
+ "model.layers.14.mlp.shared_experts.up_proj.biases": "model-00002-of-00003.safetensors",
210
+ "model.layers.14.mlp.shared_experts.up_proj.scales": "model-00002-of-00003.safetensors",
211
+ "model.layers.14.mlp.shared_experts.up_proj.weight": "model-00002-of-00003.safetensors",
212
+ "model.layers.14.mlp.switch_mlp.down_proj.biases": "model-00002-of-00003.safetensors",
213
+ "model.layers.14.mlp.switch_mlp.down_proj.scales": "model-00002-of-00003.safetensors",
214
+ "model.layers.14.mlp.switch_mlp.down_proj.weight": "model-00002-of-00003.safetensors",
215
+ "model.layers.14.mlp.switch_mlp.gate_proj.biases": "model-00002-of-00003.safetensors",
216
+ "model.layers.14.mlp.switch_mlp.gate_proj.scales": "model-00002-of-00003.safetensors",
217
+ "model.layers.14.mlp.switch_mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
218
+ "model.layers.14.mlp.switch_mlp.up_proj.biases": "model-00002-of-00003.safetensors",
219
+ "model.layers.14.mlp.switch_mlp.up_proj.scales": "model-00002-of-00003.safetensors",
220
+ "model.layers.14.mlp.switch_mlp.up_proj.weight": "model-00002-of-00003.safetensors",
221
+ "model.layers.14.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
222
+ "model.layers.14.self_attn.k_proj.biases": "model-00002-of-00003.safetensors",
223
+ "model.layers.14.self_attn.k_proj.scales": "model-00002-of-00003.safetensors",
224
+ "model.layers.14.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
225
+ "model.layers.14.self_attn.o_proj.biases": "model-00002-of-00003.safetensors",
226
+ "model.layers.14.self_attn.o_proj.scales": "model-00002-of-00003.safetensors",
227
+ "model.layers.14.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
228
+ "model.layers.14.self_attn.q_proj.biases": "model-00002-of-00003.safetensors",
229
+ "model.layers.14.self_attn.q_proj.scales": "model-00002-of-00003.safetensors",
230
+ "model.layers.14.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
231
+ "model.layers.14.self_attn.v_proj.biases": "model-00002-of-00003.safetensors",
232
+ "model.layers.14.self_attn.v_proj.scales": "model-00002-of-00003.safetensors",
233
+ "model.layers.14.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
234
+ "model.layers.15.input_layernorm.weight": "model-00002-of-00003.safetensors",
235
+ "model.layers.15.mlp.gate.weight": "model-00002-of-00003.safetensors",
236
+ "model.layers.15.mlp.shared_experts.down_proj.biases": "model-00002-of-00003.safetensors",
237
+ "model.layers.15.mlp.shared_experts.down_proj.scales": "model-00002-of-00003.safetensors",
238
+ "model.layers.15.mlp.shared_experts.down_proj.weight": "model-00002-of-00003.safetensors",
239
+ "model.layers.15.mlp.shared_experts.gate_proj.biases": "model-00002-of-00003.safetensors",
240
+ "model.layers.15.mlp.shared_experts.gate_proj.scales": "model-00002-of-00003.safetensors",
241
+ "model.layers.15.mlp.shared_experts.gate_proj.weight": "model-00002-of-00003.safetensors",
242
+ "model.layers.15.mlp.shared_experts.up_proj.biases": "model-00002-of-00003.safetensors",
243
+ "model.layers.15.mlp.shared_experts.up_proj.scales": "model-00002-of-00003.safetensors",
244
+ "model.layers.15.mlp.shared_experts.up_proj.weight": "model-00002-of-00003.safetensors",
245
+ "model.layers.15.mlp.switch_mlp.down_proj.biases": "model-00002-of-00003.safetensors",
246
+ "model.layers.15.mlp.switch_mlp.down_proj.scales": "model-00002-of-00003.safetensors",
247
+ "model.layers.15.mlp.switch_mlp.down_proj.weight": "model-00002-of-00003.safetensors",
248
+ "model.layers.15.mlp.switch_mlp.gate_proj.biases": "model-00002-of-00003.safetensors",
249
+ "model.layers.15.mlp.switch_mlp.gate_proj.scales": "model-00002-of-00003.safetensors",
250
+ "model.layers.15.mlp.switch_mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
251
+ "model.layers.15.mlp.switch_mlp.up_proj.biases": "model-00002-of-00003.safetensors",
252
+ "model.layers.15.mlp.switch_mlp.up_proj.scales": "model-00002-of-00003.safetensors",
253
+ "model.layers.15.mlp.switch_mlp.up_proj.weight": "model-00002-of-00003.safetensors",
254
+ "model.layers.15.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
255
+ "model.layers.15.self_attn.k_proj.biases": "model-00002-of-00003.safetensors",
256
+ "model.layers.15.self_attn.k_proj.scales": "model-00002-of-00003.safetensors",
257
+ "model.layers.15.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
258
+ "model.layers.15.self_attn.o_proj.biases": "model-00002-of-00003.safetensors",
259
+ "model.layers.15.self_attn.o_proj.scales": "model-00002-of-00003.safetensors",
260
+ "model.layers.15.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
261
+ "model.layers.15.self_attn.q_proj.biases": "model-00002-of-00003.safetensors",
262
+ "model.layers.15.self_attn.q_proj.scales": "model-00002-of-00003.safetensors",
263
+ "model.layers.15.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
264
+ "model.layers.15.self_attn.v_proj.biases": "model-00002-of-00003.safetensors",
265
+ "model.layers.15.self_attn.v_proj.scales": "model-00002-of-00003.safetensors",
266
+ "model.layers.15.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
267
+ "model.layers.16.input_layernorm.weight": "model-00002-of-00003.safetensors",
268
+ "model.layers.16.mlp.gate.weight": "model-00002-of-00003.safetensors",
269
+ "model.layers.16.mlp.shared_experts.down_proj.biases": "model-00002-of-00003.safetensors",
270
+ "model.layers.16.mlp.shared_experts.down_proj.scales": "model-00002-of-00003.safetensors",
271
+ "model.layers.16.mlp.shared_experts.down_proj.weight": "model-00002-of-00003.safetensors",
272
+ "model.layers.16.mlp.shared_experts.gate_proj.biases": "model-00002-of-00003.safetensors",
273
+ "model.layers.16.mlp.shared_experts.gate_proj.scales": "model-00002-of-00003.safetensors",
274
+ "model.layers.16.mlp.shared_experts.gate_proj.weight": "model-00002-of-00003.safetensors",
275
+ "model.layers.16.mlp.shared_experts.up_proj.biases": "model-00002-of-00003.safetensors",
276
+ "model.layers.16.mlp.shared_experts.up_proj.scales": "model-00002-of-00003.safetensors",
277
+ "model.layers.16.mlp.shared_experts.up_proj.weight": "model-00002-of-00003.safetensors",
278
+ "model.layers.16.mlp.switch_mlp.down_proj.biases": "model-00002-of-00003.safetensors",
279
+ "model.layers.16.mlp.switch_mlp.down_proj.scales": "model-00002-of-00003.safetensors",
280
+ "model.layers.16.mlp.switch_mlp.down_proj.weight": "model-00002-of-00003.safetensors",
281
+ "model.layers.16.mlp.switch_mlp.gate_proj.biases": "model-00002-of-00003.safetensors",
282
+ "model.layers.16.mlp.switch_mlp.gate_proj.scales": "model-00002-of-00003.safetensors",
283
+ "model.layers.16.mlp.switch_mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
284
+ "model.layers.16.mlp.switch_mlp.up_proj.biases": "model-00002-of-00003.safetensors",
285
+ "model.layers.16.mlp.switch_mlp.up_proj.scales": "model-00002-of-00003.safetensors",
286
+ "model.layers.16.mlp.switch_mlp.up_proj.weight": "model-00002-of-00003.safetensors",
287
+ "model.layers.16.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
288
+ "model.layers.16.self_attn.k_proj.biases": "model-00002-of-00003.safetensors",
289
+ "model.layers.16.self_attn.k_proj.scales": "model-00002-of-00003.safetensors",
290
+ "model.layers.16.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
291
+ "model.layers.16.self_attn.o_proj.biases": "model-00002-of-00003.safetensors",
292
+ "model.layers.16.self_attn.o_proj.scales": "model-00002-of-00003.safetensors",
293
+ "model.layers.16.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
294
+ "model.layers.16.self_attn.q_proj.biases": "model-00002-of-00003.safetensors",
295
+ "model.layers.16.self_attn.q_proj.scales": "model-00002-of-00003.safetensors",
296
+ "model.layers.16.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
297
+ "model.layers.16.self_attn.v_proj.biases": "model-00002-of-00003.safetensors",
298
+ "model.layers.16.self_attn.v_proj.scales": "model-00002-of-00003.safetensors",
299
+ "model.layers.16.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
300
+ "model.layers.17.input_layernorm.weight": "model-00002-of-00003.safetensors",
301
+ "model.layers.17.mlp.gate.weight": "model-00002-of-00003.safetensors",
302
+ "model.layers.17.mlp.shared_experts.down_proj.biases": "model-00002-of-00003.safetensors",
303
+ "model.layers.17.mlp.shared_experts.down_proj.scales": "model-00002-of-00003.safetensors",
304
+ "model.layers.17.mlp.shared_experts.down_proj.weight": "model-00002-of-00003.safetensors",
305
+ "model.layers.17.mlp.shared_experts.gate_proj.biases": "model-00002-of-00003.safetensors",
306
+ "model.layers.17.mlp.shared_experts.gate_proj.scales": "model-00002-of-00003.safetensors",
307
+ "model.layers.17.mlp.shared_experts.gate_proj.weight": "model-00002-of-00003.safetensors",
308
+ "model.layers.17.mlp.shared_experts.up_proj.biases": "model-00002-of-00003.safetensors",
309
+ "model.layers.17.mlp.shared_experts.up_proj.scales": "model-00002-of-00003.safetensors",
310
+ "model.layers.17.mlp.shared_experts.up_proj.weight": "model-00002-of-00003.safetensors",
311
+ "model.layers.17.mlp.switch_mlp.down_proj.biases": "model-00002-of-00003.safetensors",
312
+ "model.layers.17.mlp.switch_mlp.down_proj.scales": "model-00002-of-00003.safetensors",
313
+ "model.layers.17.mlp.switch_mlp.down_proj.weight": "model-00002-of-00003.safetensors",
314
+ "model.layers.17.mlp.switch_mlp.gate_proj.biases": "model-00002-of-00003.safetensors",
315
+ "model.layers.17.mlp.switch_mlp.gate_proj.scales": "model-00002-of-00003.safetensors",
316
+ "model.layers.17.mlp.switch_mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
317
+ "model.layers.17.mlp.switch_mlp.up_proj.biases": "model-00002-of-00003.safetensors",
318
+ "model.layers.17.mlp.switch_mlp.up_proj.scales": "model-00002-of-00003.safetensors",
319
+ "model.layers.17.mlp.switch_mlp.up_proj.weight": "model-00002-of-00003.safetensors",
320
+ "model.layers.17.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
321
+ "model.layers.17.self_attn.k_proj.biases": "model-00002-of-00003.safetensors",
322
+ "model.layers.17.self_attn.k_proj.scales": "model-00002-of-00003.safetensors",
323
+ "model.layers.17.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
324
+ "model.layers.17.self_attn.o_proj.biases": "model-00002-of-00003.safetensors",
325
+ "model.layers.17.self_attn.o_proj.scales": "model-00002-of-00003.safetensors",
326
+ "model.layers.17.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
327
+ "model.layers.17.self_attn.q_proj.biases": "model-00002-of-00003.safetensors",
328
+ "model.layers.17.self_attn.q_proj.scales": "model-00002-of-00003.safetensors",
329
+ "model.layers.17.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
330
+ "model.layers.17.self_attn.v_proj.biases": "model-00002-of-00003.safetensors",
331
+ "model.layers.17.self_attn.v_proj.scales": "model-00002-of-00003.safetensors",
332
+ "model.layers.17.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
333
+ "model.layers.18.input_layernorm.weight": "model-00002-of-00003.safetensors",
334
+ "model.layers.18.mlp.gate.weight": "model-00002-of-00003.safetensors",
335
+ "model.layers.18.mlp.shared_experts.down_proj.biases": "model-00002-of-00003.safetensors",
336
+ "model.layers.18.mlp.shared_experts.down_proj.scales": "model-00002-of-00003.safetensors",
337
+ "model.layers.18.mlp.shared_experts.down_proj.weight": "model-00002-of-00003.safetensors",
338
+ "model.layers.18.mlp.shared_experts.gate_proj.biases": "model-00002-of-00003.safetensors",
339
+ "model.layers.18.mlp.shared_experts.gate_proj.scales": "model-00002-of-00003.safetensors",
340
+ "model.layers.18.mlp.shared_experts.gate_proj.weight": "model-00002-of-00003.safetensors",
341
+ "model.layers.18.mlp.shared_experts.up_proj.biases": "model-00002-of-00003.safetensors",
342
+ "model.layers.18.mlp.shared_experts.up_proj.scales": "model-00002-of-00003.safetensors",
343
+ "model.layers.18.mlp.shared_experts.up_proj.weight": "model-00002-of-00003.safetensors",
344
+ "model.layers.18.mlp.switch_mlp.down_proj.biases": "model-00002-of-00003.safetensors",
345
+ "model.layers.18.mlp.switch_mlp.down_proj.scales": "model-00002-of-00003.safetensors",
346
+ "model.layers.18.mlp.switch_mlp.down_proj.weight": "model-00002-of-00003.safetensors",
347
+ "model.layers.18.mlp.switch_mlp.gate_proj.biases": "model-00002-of-00003.safetensors",
348
+ "model.layers.18.mlp.switch_mlp.gate_proj.scales": "model-00002-of-00003.safetensors",
349
+ "model.layers.18.mlp.switch_mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
350
+ "model.layers.18.mlp.switch_mlp.up_proj.biases": "model-00002-of-00003.safetensors",
351
+ "model.layers.18.mlp.switch_mlp.up_proj.scales": "model-00002-of-00003.safetensors",
352
+ "model.layers.18.mlp.switch_mlp.up_proj.weight": "model-00002-of-00003.safetensors",
353
+ "model.layers.18.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
354
+ "model.layers.18.self_attn.k_proj.biases": "model-00002-of-00003.safetensors",
355
+ "model.layers.18.self_attn.k_proj.scales": "model-00002-of-00003.safetensors",
356
+ "model.layers.18.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
357
+ "model.layers.18.self_attn.o_proj.biases": "model-00002-of-00003.safetensors",
358
+ "model.layers.18.self_attn.o_proj.scales": "model-00002-of-00003.safetensors",
359
+ "model.layers.18.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
360
+ "model.layers.18.self_attn.q_proj.biases": "model-00002-of-00003.safetensors",
361
+ "model.layers.18.self_attn.q_proj.scales": "model-00002-of-00003.safetensors",
362
+ "model.layers.18.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
363
+ "model.layers.18.self_attn.v_proj.biases": "model-00002-of-00003.safetensors",
364
+ "model.layers.18.self_attn.v_proj.scales": "model-00002-of-00003.safetensors",
365
+ "model.layers.18.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
366
+ "model.layers.19.input_layernorm.weight": "model-00002-of-00003.safetensors",
367
+ "model.layers.19.mlp.gate.weight": "model-00002-of-00003.safetensors",
368
+ "model.layers.19.mlp.shared_experts.down_proj.biases": "model-00002-of-00003.safetensors",
369
+ "model.layers.19.mlp.shared_experts.down_proj.scales": "model-00002-of-00003.safetensors",
370
+ "model.layers.19.mlp.shared_experts.down_proj.weight": "model-00002-of-00003.safetensors",
371
+ "model.layers.19.mlp.shared_experts.gate_proj.biases": "model-00002-of-00003.safetensors",
372
+ "model.layers.19.mlp.shared_experts.gate_proj.scales": "model-00002-of-00003.safetensors",
373
+ "model.layers.19.mlp.shared_experts.gate_proj.weight": "model-00002-of-00003.safetensors",
374
+ "model.layers.19.mlp.shared_experts.up_proj.biases": "model-00002-of-00003.safetensors",
375
+ "model.layers.19.mlp.shared_experts.up_proj.scales": "model-00002-of-00003.safetensors",
376
+ "model.layers.19.mlp.shared_experts.up_proj.weight": "model-00002-of-00003.safetensors",
377
+ "model.layers.19.mlp.switch_mlp.down_proj.biases": "model-00002-of-00003.safetensors",
378
+ "model.layers.19.mlp.switch_mlp.down_proj.scales": "model-00002-of-00003.safetensors",
379
+ "model.layers.19.mlp.switch_mlp.down_proj.weight": "model-00002-of-00003.safetensors",
380
+ "model.layers.19.mlp.switch_mlp.gate_proj.biases": "model-00002-of-00003.safetensors",
381
+ "model.layers.19.mlp.switch_mlp.gate_proj.scales": "model-00002-of-00003.safetensors",
382
+ "model.layers.19.mlp.switch_mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
383
+ "model.layers.19.mlp.switch_mlp.up_proj.biases": "model-00002-of-00003.safetensors",
384
+ "model.layers.19.mlp.switch_mlp.up_proj.scales": "model-00002-of-00003.safetensors",
385
+ "model.layers.19.mlp.switch_mlp.up_proj.weight": "model-00002-of-00003.safetensors",
386
+ "model.layers.19.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
387
+ "model.layers.19.self_attn.k_proj.biases": "model-00002-of-00003.safetensors",
388
+ "model.layers.19.self_attn.k_proj.scales": "model-00002-of-00003.safetensors",
389
+ "model.layers.19.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
390
+ "model.layers.19.self_attn.o_proj.biases": "model-00002-of-00003.safetensors",
391
+ "model.layers.19.self_attn.o_proj.scales": "model-00002-of-00003.safetensors",
392
+ "model.layers.19.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
393
+ "model.layers.19.self_attn.q_proj.biases": "model-00002-of-00003.safetensors",
394
+ "model.layers.19.self_attn.q_proj.scales": "model-00002-of-00003.safetensors",
395
+ "model.layers.19.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
396
+ "model.layers.19.self_attn.v_proj.biases": "model-00002-of-00003.safetensors",
397
+ "model.layers.19.self_attn.v_proj.scales": "model-00002-of-00003.safetensors",
398
+ "model.layers.19.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
399
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00003.safetensors",
400
+ "model.layers.2.mlp.gate.weight": "model-00001-of-00003.safetensors",
401
+ "model.layers.2.mlp.shared_experts.down_proj.biases": "model-00001-of-00003.safetensors",
402
+ "model.layers.2.mlp.shared_experts.down_proj.scales": "model-00001-of-00003.safetensors",
403
+ "model.layers.2.mlp.shared_experts.down_proj.weight": "model-00001-of-00003.safetensors",
404
+ "model.layers.2.mlp.shared_experts.gate_proj.biases": "model-00001-of-00003.safetensors",
405
+ "model.layers.2.mlp.shared_experts.gate_proj.scales": "model-00001-of-00003.safetensors",
406
+ "model.layers.2.mlp.shared_experts.gate_proj.weight": "model-00001-of-00003.safetensors",
407
+ "model.layers.2.mlp.shared_experts.up_proj.biases": "model-00001-of-00003.safetensors",
408
+ "model.layers.2.mlp.shared_experts.up_proj.scales": "model-00001-of-00003.safetensors",
409
+ "model.layers.2.mlp.shared_experts.up_proj.weight": "model-00001-of-00003.safetensors",
410
+ "model.layers.2.mlp.switch_mlp.down_proj.biases": "model-00001-of-00003.safetensors",
411
+ "model.layers.2.mlp.switch_mlp.down_proj.scales": "model-00001-of-00003.safetensors",
412
+ "model.layers.2.mlp.switch_mlp.down_proj.weight": "model-00001-of-00003.safetensors",
413
+ "model.layers.2.mlp.switch_mlp.gate_proj.biases": "model-00001-of-00003.safetensors",
414
+ "model.layers.2.mlp.switch_mlp.gate_proj.scales": "model-00001-of-00003.safetensors",
415
+ "model.layers.2.mlp.switch_mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
416
+ "model.layers.2.mlp.switch_mlp.up_proj.biases": "model-00001-of-00003.safetensors",
417
+ "model.layers.2.mlp.switch_mlp.up_proj.scales": "model-00001-of-00003.safetensors",
418
+ "model.layers.2.mlp.switch_mlp.up_proj.weight": "model-00001-of-00003.safetensors",
419
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
420
+ "model.layers.2.self_attn.k_proj.biases": "model-00001-of-00003.safetensors",
421
+ "model.layers.2.self_attn.k_proj.scales": "model-00001-of-00003.safetensors",
422
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
423
+ "model.layers.2.self_attn.o_proj.biases": "model-00001-of-00003.safetensors",
424
+ "model.layers.2.self_attn.o_proj.scales": "model-00001-of-00003.safetensors",
425
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
426
+ "model.layers.2.self_attn.q_proj.biases": "model-00001-of-00003.safetensors",
427
+ "model.layers.2.self_attn.q_proj.scales": "model-00001-of-00003.safetensors",
428
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
429
+ "model.layers.2.self_attn.v_proj.biases": "model-00001-of-00003.safetensors",
430
+ "model.layers.2.self_attn.v_proj.scales": "model-00001-of-00003.safetensors",
431
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
432
+ "model.layers.20.input_layernorm.weight": "model-00002-of-00003.safetensors",
433
+ "model.layers.20.mlp.gate.weight": "model-00002-of-00003.safetensors",
434
+ "model.layers.20.mlp.shared_experts.down_proj.biases": "model-00002-of-00003.safetensors",
435
+ "model.layers.20.mlp.shared_experts.down_proj.scales": "model-00002-of-00003.safetensors",
436
+ "model.layers.20.mlp.shared_experts.down_proj.weight": "model-00002-of-00003.safetensors",
437
+ "model.layers.20.mlp.shared_experts.gate_proj.biases": "model-00002-of-00003.safetensors",
438
+ "model.layers.20.mlp.shared_experts.gate_proj.scales": "model-00002-of-00003.safetensors",
439
+ "model.layers.20.mlp.shared_experts.gate_proj.weight": "model-00002-of-00003.safetensors",
440
+ "model.layers.20.mlp.shared_experts.up_proj.biases": "model-00002-of-00003.safetensors",
441
+ "model.layers.20.mlp.shared_experts.up_proj.scales": "model-00002-of-00003.safetensors",
442
+ "model.layers.20.mlp.shared_experts.up_proj.weight": "model-00002-of-00003.safetensors",
443
+ "model.layers.20.mlp.switch_mlp.down_proj.biases": "model-00002-of-00003.safetensors",
444
+ "model.layers.20.mlp.switch_mlp.down_proj.scales": "model-00002-of-00003.safetensors",
445
+ "model.layers.20.mlp.switch_mlp.down_proj.weight": "model-00002-of-00003.safetensors",
446
+ "model.layers.20.mlp.switch_mlp.gate_proj.biases": "model-00002-of-00003.safetensors",
447
+ "model.layers.20.mlp.switch_mlp.gate_proj.scales": "model-00002-of-00003.safetensors",
448
+ "model.layers.20.mlp.switch_mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
449
+ "model.layers.20.mlp.switch_mlp.up_proj.biases": "model-00002-of-00003.safetensors",
450
+ "model.layers.20.mlp.switch_mlp.up_proj.scales": "model-00002-of-00003.safetensors",
451
+ "model.layers.20.mlp.switch_mlp.up_proj.weight": "model-00002-of-00003.safetensors",
452
+ "model.layers.20.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
453
+ "model.layers.20.self_attn.k_proj.biases": "model-00002-of-00003.safetensors",
454
+ "model.layers.20.self_attn.k_proj.scales": "model-00002-of-00003.safetensors",
455
+ "model.layers.20.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
456
+ "model.layers.20.self_attn.o_proj.biases": "model-00002-of-00003.safetensors",
457
+ "model.layers.20.self_attn.o_proj.scales": "model-00002-of-00003.safetensors",
458
+ "model.layers.20.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
459
+ "model.layers.20.self_attn.q_proj.biases": "model-00002-of-00003.safetensors",
460
+ "model.layers.20.self_attn.q_proj.scales": "model-00002-of-00003.safetensors",
461
+ "model.layers.20.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
462
+ "model.layers.20.self_attn.v_proj.biases": "model-00002-of-00003.safetensors",
463
+ "model.layers.20.self_attn.v_proj.scales": "model-00002-of-00003.safetensors",
464
+ "model.layers.20.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
465
+ "model.layers.21.input_layernorm.weight": "model-00002-of-00003.safetensors",
466
+ "model.layers.21.mlp.gate.weight": "model-00002-of-00003.safetensors",
467
+ "model.layers.21.mlp.shared_experts.down_proj.biases": "model-00002-of-00003.safetensors",
468
+ "model.layers.21.mlp.shared_experts.down_proj.scales": "model-00002-of-00003.safetensors",
469
+ "model.layers.21.mlp.shared_experts.down_proj.weight": "model-00002-of-00003.safetensors",
470
+ "model.layers.21.mlp.shared_experts.gate_proj.biases": "model-00002-of-00003.safetensors",
471
+ "model.layers.21.mlp.shared_experts.gate_proj.scales": "model-00002-of-00003.safetensors",
472
+ "model.layers.21.mlp.shared_experts.gate_proj.weight": "model-00002-of-00003.safetensors",
473
+ "model.layers.21.mlp.shared_experts.up_proj.biases": "model-00002-of-00003.safetensors",
474
+ "model.layers.21.mlp.shared_experts.up_proj.scales": "model-00002-of-00003.safetensors",
475
+ "model.layers.21.mlp.shared_experts.up_proj.weight": "model-00002-of-00003.safetensors",
476
+ "model.layers.21.mlp.switch_mlp.down_proj.biases": "model-00002-of-00003.safetensors",
477
+ "model.layers.21.mlp.switch_mlp.down_proj.scales": "model-00002-of-00003.safetensors",
478
+ "model.layers.21.mlp.switch_mlp.down_proj.weight": "model-00002-of-00003.safetensors",
479
+ "model.layers.21.mlp.switch_mlp.gate_proj.biases": "model-00002-of-00003.safetensors",
480
+ "model.layers.21.mlp.switch_mlp.gate_proj.scales": "model-00002-of-00003.safetensors",
481
+ "model.layers.21.mlp.switch_mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
482
+ "model.layers.21.mlp.switch_mlp.up_proj.biases": "model-00002-of-00003.safetensors",
483
+ "model.layers.21.mlp.switch_mlp.up_proj.scales": "model-00002-of-00003.safetensors",
484
+ "model.layers.21.mlp.switch_mlp.up_proj.weight": "model-00002-of-00003.safetensors",
485
+ "model.layers.21.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
486
+ "model.layers.21.self_attn.k_proj.biases": "model-00002-of-00003.safetensors",
487
+ "model.layers.21.self_attn.k_proj.scales": "model-00002-of-00003.safetensors",
488
+ "model.layers.21.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
489
+ "model.layers.21.self_attn.o_proj.biases": "model-00002-of-00003.safetensors",
490
+ "model.layers.21.self_attn.o_proj.scales": "model-00002-of-00003.safetensors",
491
+ "model.layers.21.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
492
+ "model.layers.21.self_attn.q_proj.biases": "model-00002-of-00003.safetensors",
493
+ "model.layers.21.self_attn.q_proj.scales": "model-00002-of-00003.safetensors",
494
+ "model.layers.21.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
495
+ "model.layers.21.self_attn.v_proj.biases": "model-00002-of-00003.safetensors",
496
+ "model.layers.21.self_attn.v_proj.scales": "model-00002-of-00003.safetensors",
497
+ "model.layers.21.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
498
+ "model.layers.22.input_layernorm.weight": "model-00002-of-00003.safetensors",
499
+ "model.layers.22.mlp.gate.weight": "model-00002-of-00003.safetensors",
500
+ "model.layers.22.mlp.shared_experts.down_proj.biases": "model-00002-of-00003.safetensors",
501
+ "model.layers.22.mlp.shared_experts.down_proj.scales": "model-00002-of-00003.safetensors",
502
+ "model.layers.22.mlp.shared_experts.down_proj.weight": "model-00002-of-00003.safetensors",
503
+ "model.layers.22.mlp.shared_experts.gate_proj.biases": "model-00002-of-00003.safetensors",
504
+ "model.layers.22.mlp.shared_experts.gate_proj.scales": "model-00002-of-00003.safetensors",
505
+ "model.layers.22.mlp.shared_experts.gate_proj.weight": "model-00002-of-00003.safetensors",
506
+ "model.layers.22.mlp.shared_experts.up_proj.biases": "model-00002-of-00003.safetensors",
507
+ "model.layers.22.mlp.shared_experts.up_proj.scales": "model-00002-of-00003.safetensors",
508
+ "model.layers.22.mlp.shared_experts.up_proj.weight": "model-00002-of-00003.safetensors",
509
+ "model.layers.22.mlp.switch_mlp.down_proj.biases": "model-00002-of-00003.safetensors",
510
+ "model.layers.22.mlp.switch_mlp.down_proj.scales": "model-00002-of-00003.safetensors",
511
+ "model.layers.22.mlp.switch_mlp.down_proj.weight": "model-00002-of-00003.safetensors",
512
+ "model.layers.22.mlp.switch_mlp.gate_proj.biases": "model-00002-of-00003.safetensors",
513
+ "model.layers.22.mlp.switch_mlp.gate_proj.scales": "model-00002-of-00003.safetensors",
514
+ "model.layers.22.mlp.switch_mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
515
+ "model.layers.22.mlp.switch_mlp.up_proj.biases": "model-00002-of-00003.safetensors",
516
+ "model.layers.22.mlp.switch_mlp.up_proj.scales": "model-00002-of-00003.safetensors",
517
+ "model.layers.22.mlp.switch_mlp.up_proj.weight": "model-00002-of-00003.safetensors",
518
+ "model.layers.22.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
519
+ "model.layers.22.self_attn.k_proj.biases": "model-00002-of-00003.safetensors",
520
+ "model.layers.22.self_attn.k_proj.scales": "model-00002-of-00003.safetensors",
521
+ "model.layers.22.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
522
+ "model.layers.22.self_attn.o_proj.biases": "model-00002-of-00003.safetensors",
523
+ "model.layers.22.self_attn.o_proj.scales": "model-00002-of-00003.safetensors",
524
+ "model.layers.22.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
525
+ "model.layers.22.self_attn.q_proj.biases": "model-00002-of-00003.safetensors",
526
+ "model.layers.22.self_attn.q_proj.scales": "model-00002-of-00003.safetensors",
527
+ "model.layers.22.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
528
+ "model.layers.22.self_attn.v_proj.biases": "model-00002-of-00003.safetensors",
529
+ "model.layers.22.self_attn.v_proj.scales": "model-00002-of-00003.safetensors",
530
+ "model.layers.22.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
531
+ "model.layers.23.input_layernorm.weight": "model-00003-of-00003.safetensors",
532
+ "model.layers.23.mlp.gate.weight": "model-00003-of-00003.safetensors",
533
+ "model.layers.23.mlp.shared_experts.down_proj.biases": "model-00003-of-00003.safetensors",
534
+ "model.layers.23.mlp.shared_experts.down_proj.scales": "model-00003-of-00003.safetensors",
535
+ "model.layers.23.mlp.shared_experts.down_proj.weight": "model-00003-of-00003.safetensors",
536
+ "model.layers.23.mlp.shared_experts.gate_proj.biases": "model-00003-of-00003.safetensors",
537
+ "model.layers.23.mlp.shared_experts.gate_proj.scales": "model-00003-of-00003.safetensors",
538
+ "model.layers.23.mlp.shared_experts.gate_proj.weight": "model-00003-of-00003.safetensors",
539
+ "model.layers.23.mlp.shared_experts.up_proj.biases": "model-00003-of-00003.safetensors",
540
+ "model.layers.23.mlp.shared_experts.up_proj.scales": "model-00003-of-00003.safetensors",
541
+ "model.layers.23.mlp.shared_experts.up_proj.weight": "model-00003-of-00003.safetensors",
542
+ "model.layers.23.mlp.switch_mlp.down_proj.biases": "model-00003-of-00003.safetensors",
543
+ "model.layers.23.mlp.switch_mlp.down_proj.scales": "model-00003-of-00003.safetensors",
544
+ "model.layers.23.mlp.switch_mlp.down_proj.weight": "model-00003-of-00003.safetensors",
545
+ "model.layers.23.mlp.switch_mlp.gate_proj.biases": "model-00002-of-00003.safetensors",
546
+ "model.layers.23.mlp.switch_mlp.gate_proj.scales": "model-00002-of-00003.safetensors",
547
+ "model.layers.23.mlp.switch_mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
548
+ "model.layers.23.mlp.switch_mlp.up_proj.biases": "model-00003-of-00003.safetensors",
549
+ "model.layers.23.mlp.switch_mlp.up_proj.scales": "model-00002-of-00003.safetensors",
550
+ "model.layers.23.mlp.switch_mlp.up_proj.weight": "model-00002-of-00003.safetensors",
551
+ "model.layers.23.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
552
+ "model.layers.23.self_attn.k_proj.biases": "model-00002-of-00003.safetensors",
553
+ "model.layers.23.self_attn.k_proj.scales": "model-00002-of-00003.safetensors",
554
+ "model.layers.23.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
555
+ "model.layers.23.self_attn.o_proj.biases": "model-00002-of-00003.safetensors",
556
+ "model.layers.23.self_attn.o_proj.scales": "model-00002-of-00003.safetensors",
557
+ "model.layers.23.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
558
+ "model.layers.23.self_attn.q_proj.biases": "model-00002-of-00003.safetensors",
559
+ "model.layers.23.self_attn.q_proj.scales": "model-00002-of-00003.safetensors",
560
+ "model.layers.23.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
561
+ "model.layers.23.self_attn.v_proj.biases": "model-00002-of-00003.safetensors",
562
+ "model.layers.23.self_attn.v_proj.scales": "model-00002-of-00003.safetensors",
563
+ "model.layers.23.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
564
+ "model.layers.24.input_layernorm.weight": "model-00003-of-00003.safetensors",
565
+ "model.layers.24.mlp.gate.weight": "model-00003-of-00003.safetensors",
566
+ "model.layers.24.mlp.shared_experts.down_proj.biases": "model-00003-of-00003.safetensors",
567
+ "model.layers.24.mlp.shared_experts.down_proj.scales": "model-00003-of-00003.safetensors",
568
+ "model.layers.24.mlp.shared_experts.down_proj.weight": "model-00003-of-00003.safetensors",
569
+ "model.layers.24.mlp.shared_experts.gate_proj.biases": "model-00003-of-00003.safetensors",
570
+ "model.layers.24.mlp.shared_experts.gate_proj.scales": "model-00003-of-00003.safetensors",
571
+ "model.layers.24.mlp.shared_experts.gate_proj.weight": "model-00003-of-00003.safetensors",
572
+ "model.layers.24.mlp.shared_experts.up_proj.biases": "model-00003-of-00003.safetensors",
573
+ "model.layers.24.mlp.shared_experts.up_proj.scales": "model-00003-of-00003.safetensors",
574
+ "model.layers.24.mlp.shared_experts.up_proj.weight": "model-00003-of-00003.safetensors",
575
+ "model.layers.24.mlp.switch_mlp.down_proj.biases": "model-00003-of-00003.safetensors",
576
+ "model.layers.24.mlp.switch_mlp.down_proj.scales": "model-00003-of-00003.safetensors",
577
+ "model.layers.24.mlp.switch_mlp.down_proj.weight": "model-00003-of-00003.safetensors",
578
+ "model.layers.24.mlp.switch_mlp.gate_proj.biases": "model-00003-of-00003.safetensors",
579
+ "model.layers.24.mlp.switch_mlp.gate_proj.scales": "model-00003-of-00003.safetensors",
580
+ "model.layers.24.mlp.switch_mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
581
+ "model.layers.24.mlp.switch_mlp.up_proj.biases": "model-00003-of-00003.safetensors",
582
+ "model.layers.24.mlp.switch_mlp.up_proj.scales": "model-00003-of-00003.safetensors",
583
+ "model.layers.24.mlp.switch_mlp.up_proj.weight": "model-00003-of-00003.safetensors",
584
+ "model.layers.24.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
585
+ "model.layers.24.self_attn.k_proj.biases": "model-00003-of-00003.safetensors",
586
+ "model.layers.24.self_attn.k_proj.scales": "model-00003-of-00003.safetensors",
587
+ "model.layers.24.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
588
+ "model.layers.24.self_attn.o_proj.biases": "model-00003-of-00003.safetensors",
589
+ "model.layers.24.self_attn.o_proj.scales": "model-00003-of-00003.safetensors",
590
+ "model.layers.24.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
591
+ "model.layers.24.self_attn.q_proj.biases": "model-00003-of-00003.safetensors",
592
+ "model.layers.24.self_attn.q_proj.scales": "model-00003-of-00003.safetensors",
593
+ "model.layers.24.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
594
+ "model.layers.24.self_attn.v_proj.biases": "model-00003-of-00003.safetensors",
595
+ "model.layers.24.self_attn.v_proj.scales": "model-00003-of-00003.safetensors",
596
+ "model.layers.24.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
597
+ "model.layers.25.input_layernorm.weight": "model-00003-of-00003.safetensors",
598
+ "model.layers.25.mlp.gate.weight": "model-00003-of-00003.safetensors",
599
+ "model.layers.25.mlp.shared_experts.down_proj.biases": "model-00003-of-00003.safetensors",
600
+ "model.layers.25.mlp.shared_experts.down_proj.scales": "model-00003-of-00003.safetensors",
601
+ "model.layers.25.mlp.shared_experts.down_proj.weight": "model-00003-of-00003.safetensors",
602
+ "model.layers.25.mlp.shared_experts.gate_proj.biases": "model-00003-of-00003.safetensors",
603
+ "model.layers.25.mlp.shared_experts.gate_proj.scales": "model-00003-of-00003.safetensors",
604
+ "model.layers.25.mlp.shared_experts.gate_proj.weight": "model-00003-of-00003.safetensors",
605
+ "model.layers.25.mlp.shared_experts.up_proj.biases": "model-00003-of-00003.safetensors",
606
+ "model.layers.25.mlp.shared_experts.up_proj.scales": "model-00003-of-00003.safetensors",
607
+ "model.layers.25.mlp.shared_experts.up_proj.weight": "model-00003-of-00003.safetensors",
608
+ "model.layers.25.mlp.switch_mlp.down_proj.biases": "model-00003-of-00003.safetensors",
609
+ "model.layers.25.mlp.switch_mlp.down_proj.scales": "model-00003-of-00003.safetensors",
610
+ "model.layers.25.mlp.switch_mlp.down_proj.weight": "model-00003-of-00003.safetensors",
611
+ "model.layers.25.mlp.switch_mlp.gate_proj.biases": "model-00003-of-00003.safetensors",
612
+ "model.layers.25.mlp.switch_mlp.gate_proj.scales": "model-00003-of-00003.safetensors",
613
+ "model.layers.25.mlp.switch_mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
614
+ "model.layers.25.mlp.switch_mlp.up_proj.biases": "model-00003-of-00003.safetensors",
615
+ "model.layers.25.mlp.switch_mlp.up_proj.scales": "model-00003-of-00003.safetensors",
616
+ "model.layers.25.mlp.switch_mlp.up_proj.weight": "model-00003-of-00003.safetensors",
617
+ "model.layers.25.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
618
+ "model.layers.25.self_attn.k_proj.biases": "model-00003-of-00003.safetensors",
619
+ "model.layers.25.self_attn.k_proj.scales": "model-00003-of-00003.safetensors",
620
+ "model.layers.25.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
621
+ "model.layers.25.self_attn.o_proj.biases": "model-00003-of-00003.safetensors",
622
+ "model.layers.25.self_attn.o_proj.scales": "model-00003-of-00003.safetensors",
623
+ "model.layers.25.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
624
+ "model.layers.25.self_attn.q_proj.biases": "model-00003-of-00003.safetensors",
625
+ "model.layers.25.self_attn.q_proj.scales": "model-00003-of-00003.safetensors",
626
+ "model.layers.25.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
627
+ "model.layers.25.self_attn.v_proj.biases": "model-00003-of-00003.safetensors",
628
+ "model.layers.25.self_attn.v_proj.scales": "model-00003-of-00003.safetensors",
629
+ "model.layers.25.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
630
+ "model.layers.26.input_layernorm.weight": "model-00003-of-00003.safetensors",
631
+ "model.layers.26.mlp.gate.weight": "model-00003-of-00003.safetensors",
632
+ "model.layers.26.mlp.shared_experts.down_proj.biases": "model-00003-of-00003.safetensors",
633
+ "model.layers.26.mlp.shared_experts.down_proj.scales": "model-00003-of-00003.safetensors",
634
+ "model.layers.26.mlp.shared_experts.down_proj.weight": "model-00003-of-00003.safetensors",
635
+ "model.layers.26.mlp.shared_experts.gate_proj.biases": "model-00003-of-00003.safetensors",
636
+ "model.layers.26.mlp.shared_experts.gate_proj.scales": "model-00003-of-00003.safetensors",
637
+ "model.layers.26.mlp.shared_experts.gate_proj.weight": "model-00003-of-00003.safetensors",
638
+ "model.layers.26.mlp.shared_experts.up_proj.biases": "model-00003-of-00003.safetensors",
639
+ "model.layers.26.mlp.shared_experts.up_proj.scales": "model-00003-of-00003.safetensors",
640
+ "model.layers.26.mlp.shared_experts.up_proj.weight": "model-00003-of-00003.safetensors",
641
+ "model.layers.26.mlp.switch_mlp.down_proj.biases": "model-00003-of-00003.safetensors",
642
+ "model.layers.26.mlp.switch_mlp.down_proj.scales": "model-00003-of-00003.safetensors",
643
+ "model.layers.26.mlp.switch_mlp.down_proj.weight": "model-00003-of-00003.safetensors",
644
+ "model.layers.26.mlp.switch_mlp.gate_proj.biases": "model-00003-of-00003.safetensors",
645
+ "model.layers.26.mlp.switch_mlp.gate_proj.scales": "model-00003-of-00003.safetensors",
646
+ "model.layers.26.mlp.switch_mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
647
+ "model.layers.26.mlp.switch_mlp.up_proj.biases": "model-00003-of-00003.safetensors",
648
+ "model.layers.26.mlp.switch_mlp.up_proj.scales": "model-00003-of-00003.safetensors",
649
+ "model.layers.26.mlp.switch_mlp.up_proj.weight": "model-00003-of-00003.safetensors",
650
+ "model.layers.26.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
651
+ "model.layers.26.self_attn.k_proj.biases": "model-00003-of-00003.safetensors",
652
+ "model.layers.26.self_attn.k_proj.scales": "model-00003-of-00003.safetensors",
653
+ "model.layers.26.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
654
+ "model.layers.26.self_attn.o_proj.biases": "model-00003-of-00003.safetensors",
655
+ "model.layers.26.self_attn.o_proj.scales": "model-00003-of-00003.safetensors",
656
+ "model.layers.26.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
657
+ "model.layers.26.self_attn.q_proj.biases": "model-00003-of-00003.safetensors",
658
+ "model.layers.26.self_attn.q_proj.scales": "model-00003-of-00003.safetensors",
659
+ "model.layers.26.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
660
+ "model.layers.26.self_attn.v_proj.biases": "model-00003-of-00003.safetensors",
661
+ "model.layers.26.self_attn.v_proj.scales": "model-00003-of-00003.safetensors",
662
+ "model.layers.26.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
663
+ "model.layers.27.input_layernorm.weight": "model-00003-of-00003.safetensors",
664
+ "model.layers.27.mlp.gate.weight": "model-00003-of-00003.safetensors",
665
+ "model.layers.27.mlp.shared_experts.down_proj.biases": "model-00003-of-00003.safetensors",
666
+ "model.layers.27.mlp.shared_experts.down_proj.scales": "model-00003-of-00003.safetensors",
667
+ "model.layers.27.mlp.shared_experts.down_proj.weight": "model-00003-of-00003.safetensors",
668
+ "model.layers.27.mlp.shared_experts.gate_proj.biases": "model-00003-of-00003.safetensors",
669
+ "model.layers.27.mlp.shared_experts.gate_proj.scales": "model-00003-of-00003.safetensors",
670
+ "model.layers.27.mlp.shared_experts.gate_proj.weight": "model-00003-of-00003.safetensors",
671
+ "model.layers.27.mlp.shared_experts.up_proj.biases": "model-00003-of-00003.safetensors",
672
+ "model.layers.27.mlp.shared_experts.up_proj.scales": "model-00003-of-00003.safetensors",
673
+ "model.layers.27.mlp.shared_experts.up_proj.weight": "model-00003-of-00003.safetensors",
674
+ "model.layers.27.mlp.switch_mlp.down_proj.biases": "model-00003-of-00003.safetensors",
675
+ "model.layers.27.mlp.switch_mlp.down_proj.scales": "model-00003-of-00003.safetensors",
676
+ "model.layers.27.mlp.switch_mlp.down_proj.weight": "model-00003-of-00003.safetensors",
677
+ "model.layers.27.mlp.switch_mlp.gate_proj.biases": "model-00003-of-00003.safetensors",
678
+ "model.layers.27.mlp.switch_mlp.gate_proj.scales": "model-00003-of-00003.safetensors",
679
+ "model.layers.27.mlp.switch_mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
680
+ "model.layers.27.mlp.switch_mlp.up_proj.biases": "model-00003-of-00003.safetensors",
681
+ "model.layers.27.mlp.switch_mlp.up_proj.scales": "model-00003-of-00003.safetensors",
682
+ "model.layers.27.mlp.switch_mlp.up_proj.weight": "model-00003-of-00003.safetensors",
683
+ "model.layers.27.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
684
+ "model.layers.27.self_attn.k_proj.biases": "model-00003-of-00003.safetensors",
685
+ "model.layers.27.self_attn.k_proj.scales": "model-00003-of-00003.safetensors",
686
+ "model.layers.27.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
687
+ "model.layers.27.self_attn.o_proj.biases": "model-00003-of-00003.safetensors",
688
+ "model.layers.27.self_attn.o_proj.scales": "model-00003-of-00003.safetensors",
689
+ "model.layers.27.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
690
+ "model.layers.27.self_attn.q_proj.biases": "model-00003-of-00003.safetensors",
691
+ "model.layers.27.self_attn.q_proj.scales": "model-00003-of-00003.safetensors",
692
+ "model.layers.27.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
693
+ "model.layers.27.self_attn.v_proj.biases": "model-00003-of-00003.safetensors",
694
+ "model.layers.27.self_attn.v_proj.scales": "model-00003-of-00003.safetensors",
695
+ "model.layers.27.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
696
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00003.safetensors",
697
+ "model.layers.3.mlp.gate.weight": "model-00001-of-00003.safetensors",
698
+ "model.layers.3.mlp.shared_experts.down_proj.biases": "model-00001-of-00003.safetensors",
699
+ "model.layers.3.mlp.shared_experts.down_proj.scales": "model-00001-of-00003.safetensors",
700
+ "model.layers.3.mlp.shared_experts.down_proj.weight": "model-00001-of-00003.safetensors",
701
+ "model.layers.3.mlp.shared_experts.gate_proj.biases": "model-00001-of-00003.safetensors",
702
+ "model.layers.3.mlp.shared_experts.gate_proj.scales": "model-00001-of-00003.safetensors",
703
+ "model.layers.3.mlp.shared_experts.gate_proj.weight": "model-00001-of-00003.safetensors",
704
+ "model.layers.3.mlp.shared_experts.up_proj.biases": "model-00001-of-00003.safetensors",
705
+ "model.layers.3.mlp.shared_experts.up_proj.scales": "model-00001-of-00003.safetensors",
706
+ "model.layers.3.mlp.shared_experts.up_proj.weight": "model-00001-of-00003.safetensors",
707
+ "model.layers.3.mlp.switch_mlp.down_proj.biases": "model-00001-of-00003.safetensors",
708
+ "model.layers.3.mlp.switch_mlp.down_proj.scales": "model-00001-of-00003.safetensors",
709
+ "model.layers.3.mlp.switch_mlp.down_proj.weight": "model-00001-of-00003.safetensors",
710
+ "model.layers.3.mlp.switch_mlp.gate_proj.biases": "model-00001-of-00003.safetensors",
711
+ "model.layers.3.mlp.switch_mlp.gate_proj.scales": "model-00001-of-00003.safetensors",
712
+ "model.layers.3.mlp.switch_mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
713
+ "model.layers.3.mlp.switch_mlp.up_proj.biases": "model-00001-of-00003.safetensors",
714
+ "model.layers.3.mlp.switch_mlp.up_proj.scales": "model-00001-of-00003.safetensors",
715
+ "model.layers.3.mlp.switch_mlp.up_proj.weight": "model-00001-of-00003.safetensors",
716
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
717
+ "model.layers.3.self_attn.k_proj.biases": "model-00001-of-00003.safetensors",
718
+ "model.layers.3.self_attn.k_proj.scales": "model-00001-of-00003.safetensors",
719
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
720
+ "model.layers.3.self_attn.o_proj.biases": "model-00001-of-00003.safetensors",
721
+ "model.layers.3.self_attn.o_proj.scales": "model-00001-of-00003.safetensors",
722
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
723
+ "model.layers.3.self_attn.q_proj.biases": "model-00001-of-00003.safetensors",
724
+ "model.layers.3.self_attn.q_proj.scales": "model-00001-of-00003.safetensors",
725
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
726
+ "model.layers.3.self_attn.v_proj.biases": "model-00001-of-00003.safetensors",
727
+ "model.layers.3.self_attn.v_proj.scales": "model-00001-of-00003.safetensors",
728
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
729
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00003.safetensors",
730
+ "model.layers.4.mlp.gate.weight": "model-00001-of-00003.safetensors",
731
+ "model.layers.4.mlp.shared_experts.down_proj.biases": "model-00001-of-00003.safetensors",
732
+ "model.layers.4.mlp.shared_experts.down_proj.scales": "model-00001-of-00003.safetensors",
733
+ "model.layers.4.mlp.shared_experts.down_proj.weight": "model-00001-of-00003.safetensors",
734
+ "model.layers.4.mlp.shared_experts.gate_proj.biases": "model-00001-of-00003.safetensors",
735
+ "model.layers.4.mlp.shared_experts.gate_proj.scales": "model-00001-of-00003.safetensors",
736
+ "model.layers.4.mlp.shared_experts.gate_proj.weight": "model-00001-of-00003.safetensors",
737
+ "model.layers.4.mlp.shared_experts.up_proj.biases": "model-00001-of-00003.safetensors",
738
+ "model.layers.4.mlp.shared_experts.up_proj.scales": "model-00001-of-00003.safetensors",
739
+ "model.layers.4.mlp.shared_experts.up_proj.weight": "model-00001-of-00003.safetensors",
740
+ "model.layers.4.mlp.switch_mlp.down_proj.biases": "model-00001-of-00003.safetensors",
741
+ "model.layers.4.mlp.switch_mlp.down_proj.scales": "model-00001-of-00003.safetensors",
742
+ "model.layers.4.mlp.switch_mlp.down_proj.weight": "model-00001-of-00003.safetensors",
743
+ "model.layers.4.mlp.switch_mlp.gate_proj.biases": "model-00001-of-00003.safetensors",
744
+ "model.layers.4.mlp.switch_mlp.gate_proj.scales": "model-00001-of-00003.safetensors",
745
+ "model.layers.4.mlp.switch_mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
746
+ "model.layers.4.mlp.switch_mlp.up_proj.biases": "model-00001-of-00003.safetensors",
747
+ "model.layers.4.mlp.switch_mlp.up_proj.scales": "model-00001-of-00003.safetensors",
748
+ "model.layers.4.mlp.switch_mlp.up_proj.weight": "model-00001-of-00003.safetensors",
749
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
750
+ "model.layers.4.self_attn.k_proj.biases": "model-00001-of-00003.safetensors",
751
+ "model.layers.4.self_attn.k_proj.scales": "model-00001-of-00003.safetensors",
752
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
753
+ "model.layers.4.self_attn.o_proj.biases": "model-00001-of-00003.safetensors",
754
+ "model.layers.4.self_attn.o_proj.scales": "model-00001-of-00003.safetensors",
755
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
756
+ "model.layers.4.self_attn.q_proj.biases": "model-00001-of-00003.safetensors",
757
+ "model.layers.4.self_attn.q_proj.scales": "model-00001-of-00003.safetensors",
758
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
759
+ "model.layers.4.self_attn.v_proj.biases": "model-00001-of-00003.safetensors",
760
+ "model.layers.4.self_attn.v_proj.scales": "model-00001-of-00003.safetensors",
761
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
762
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00003.safetensors",
763
+ "model.layers.5.mlp.gate.weight": "model-00001-of-00003.safetensors",
764
+ "model.layers.5.mlp.shared_experts.down_proj.biases": "model-00001-of-00003.safetensors",
765
+ "model.layers.5.mlp.shared_experts.down_proj.scales": "model-00001-of-00003.safetensors",
766
+ "model.layers.5.mlp.shared_experts.down_proj.weight": "model-00001-of-00003.safetensors",
767
+ "model.layers.5.mlp.shared_experts.gate_proj.biases": "model-00001-of-00003.safetensors",
768
+ "model.layers.5.mlp.shared_experts.gate_proj.scales": "model-00001-of-00003.safetensors",
769
+ "model.layers.5.mlp.shared_experts.gate_proj.weight": "model-00001-of-00003.safetensors",
770
+ "model.layers.5.mlp.shared_experts.up_proj.biases": "model-00001-of-00003.safetensors",
771
+ "model.layers.5.mlp.shared_experts.up_proj.scales": "model-00001-of-00003.safetensors",
772
+ "model.layers.5.mlp.shared_experts.up_proj.weight": "model-00001-of-00003.safetensors",
773
+ "model.layers.5.mlp.switch_mlp.down_proj.biases": "model-00001-of-00003.safetensors",
774
+ "model.layers.5.mlp.switch_mlp.down_proj.scales": "model-00001-of-00003.safetensors",
775
+ "model.layers.5.mlp.switch_mlp.down_proj.weight": "model-00001-of-00003.safetensors",
776
+ "model.layers.5.mlp.switch_mlp.gate_proj.biases": "model-00001-of-00003.safetensors",
777
+ "model.layers.5.mlp.switch_mlp.gate_proj.scales": "model-00001-of-00003.safetensors",
778
+ "model.layers.5.mlp.switch_mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
779
+ "model.layers.5.mlp.switch_mlp.up_proj.biases": "model-00001-of-00003.safetensors",
780
+ "model.layers.5.mlp.switch_mlp.up_proj.scales": "model-00001-of-00003.safetensors",
781
+ "model.layers.5.mlp.switch_mlp.up_proj.weight": "model-00001-of-00003.safetensors",
782
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
783
+ "model.layers.5.self_attn.k_proj.biases": "model-00001-of-00003.safetensors",
784
+ "model.layers.5.self_attn.k_proj.scales": "model-00001-of-00003.safetensors",
785
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
786
+ "model.layers.5.self_attn.o_proj.biases": "model-00001-of-00003.safetensors",
787
+ "model.layers.5.self_attn.o_proj.scales": "model-00001-of-00003.safetensors",
788
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
789
+ "model.layers.5.self_attn.q_proj.biases": "model-00001-of-00003.safetensors",
790
+ "model.layers.5.self_attn.q_proj.scales": "model-00001-of-00003.safetensors",
791
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
792
+ "model.layers.5.self_attn.v_proj.biases": "model-00001-of-00003.safetensors",
793
+ "model.layers.5.self_attn.v_proj.scales": "model-00001-of-00003.safetensors",
794
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
795
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00003.safetensors",
796
+ "model.layers.6.mlp.gate.weight": "model-00001-of-00003.safetensors",
797
+ "model.layers.6.mlp.shared_experts.down_proj.biases": "model-00001-of-00003.safetensors",
798
+ "model.layers.6.mlp.shared_experts.down_proj.scales": "model-00001-of-00003.safetensors",
799
+ "model.layers.6.mlp.shared_experts.down_proj.weight": "model-00001-of-00003.safetensors",
800
+ "model.layers.6.mlp.shared_experts.gate_proj.biases": "model-00001-of-00003.safetensors",
801
+ "model.layers.6.mlp.shared_experts.gate_proj.scales": "model-00001-of-00003.safetensors",
802
+ "model.layers.6.mlp.shared_experts.gate_proj.weight": "model-00001-of-00003.safetensors",
803
+ "model.layers.6.mlp.shared_experts.up_proj.biases": "model-00001-of-00003.safetensors",
804
+ "model.layers.6.mlp.shared_experts.up_proj.scales": "model-00001-of-00003.safetensors",
805
+ "model.layers.6.mlp.shared_experts.up_proj.weight": "model-00001-of-00003.safetensors",
806
+ "model.layers.6.mlp.switch_mlp.down_proj.biases": "model-00001-of-00003.safetensors",
807
+ "model.layers.6.mlp.switch_mlp.down_proj.scales": "model-00001-of-00003.safetensors",
808
+ "model.layers.6.mlp.switch_mlp.down_proj.weight": "model-00001-of-00003.safetensors",
809
+ "model.layers.6.mlp.switch_mlp.gate_proj.biases": "model-00001-of-00003.safetensors",
810
+ "model.layers.6.mlp.switch_mlp.gate_proj.scales": "model-00001-of-00003.safetensors",
811
+ "model.layers.6.mlp.switch_mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
812
+ "model.layers.6.mlp.switch_mlp.up_proj.biases": "model-00001-of-00003.safetensors",
813
+ "model.layers.6.mlp.switch_mlp.up_proj.scales": "model-00001-of-00003.safetensors",
814
+ "model.layers.6.mlp.switch_mlp.up_proj.weight": "model-00001-of-00003.safetensors",
815
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
816
+ "model.layers.6.self_attn.k_proj.biases": "model-00001-of-00003.safetensors",
817
+ "model.layers.6.self_attn.k_proj.scales": "model-00001-of-00003.safetensors",
818
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
819
+ "model.layers.6.self_attn.o_proj.biases": "model-00001-of-00003.safetensors",
820
+ "model.layers.6.self_attn.o_proj.scales": "model-00001-of-00003.safetensors",
821
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
822
+ "model.layers.6.self_attn.q_proj.biases": "model-00001-of-00003.safetensors",
823
+ "model.layers.6.self_attn.q_proj.scales": "model-00001-of-00003.safetensors",
824
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
825
+ "model.layers.6.self_attn.v_proj.biases": "model-00001-of-00003.safetensors",
826
+ "model.layers.6.self_attn.v_proj.scales": "model-00001-of-00003.safetensors",
827
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
828
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00003.safetensors",
829
+ "model.layers.7.mlp.gate.weight": "model-00001-of-00003.safetensors",
830
+ "model.layers.7.mlp.shared_experts.down_proj.biases": "model-00001-of-00003.safetensors",
831
+ "model.layers.7.mlp.shared_experts.down_proj.scales": "model-00001-of-00003.safetensors",
832
+ "model.layers.7.mlp.shared_experts.down_proj.weight": "model-00001-of-00003.safetensors",
833
+ "model.layers.7.mlp.shared_experts.gate_proj.biases": "model-00001-of-00003.safetensors",
834
+ "model.layers.7.mlp.shared_experts.gate_proj.scales": "model-00001-of-00003.safetensors",
835
+ "model.layers.7.mlp.shared_experts.gate_proj.weight": "model-00001-of-00003.safetensors",
836
+ "model.layers.7.mlp.shared_experts.up_proj.biases": "model-00001-of-00003.safetensors",
837
+ "model.layers.7.mlp.shared_experts.up_proj.scales": "model-00001-of-00003.safetensors",
838
+ "model.layers.7.mlp.shared_experts.up_proj.weight": "model-00001-of-00003.safetensors",
839
+ "model.layers.7.mlp.switch_mlp.down_proj.biases": "model-00001-of-00003.safetensors",
840
+ "model.layers.7.mlp.switch_mlp.down_proj.scales": "model-00001-of-00003.safetensors",
841
+ "model.layers.7.mlp.switch_mlp.down_proj.weight": "model-00001-of-00003.safetensors",
842
+ "model.layers.7.mlp.switch_mlp.gate_proj.biases": "model-00001-of-00003.safetensors",
843
+ "model.layers.7.mlp.switch_mlp.gate_proj.scales": "model-00001-of-00003.safetensors",
844
+ "model.layers.7.mlp.switch_mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
845
+ "model.layers.7.mlp.switch_mlp.up_proj.biases": "model-00001-of-00003.safetensors",
846
+ "model.layers.7.mlp.switch_mlp.up_proj.scales": "model-00001-of-00003.safetensors",
847
+ "model.layers.7.mlp.switch_mlp.up_proj.weight": "model-00001-of-00003.safetensors",
848
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
849
+ "model.layers.7.self_attn.k_proj.biases": "model-00001-of-00003.safetensors",
850
+ "model.layers.7.self_attn.k_proj.scales": "model-00001-of-00003.safetensors",
851
+ "model.layers.7.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
852
+ "model.layers.7.self_attn.o_proj.biases": "model-00001-of-00003.safetensors",
853
+ "model.layers.7.self_attn.o_proj.scales": "model-00001-of-00003.safetensors",
854
+ "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
855
+ "model.layers.7.self_attn.q_proj.biases": "model-00001-of-00003.safetensors",
856
+ "model.layers.7.self_attn.q_proj.scales": "model-00001-of-00003.safetensors",
857
+ "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
858
+ "model.layers.7.self_attn.v_proj.biases": "model-00001-of-00003.safetensors",
859
+ "model.layers.7.self_attn.v_proj.scales": "model-00001-of-00003.safetensors",
860
+ "model.layers.7.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
861
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00003.safetensors",
862
+ "model.layers.8.mlp.gate.weight": "model-00001-of-00003.safetensors",
863
+ "model.layers.8.mlp.shared_experts.down_proj.biases": "model-00001-of-00003.safetensors",
864
+ "model.layers.8.mlp.shared_experts.down_proj.scales": "model-00001-of-00003.safetensors",
865
+ "model.layers.8.mlp.shared_experts.down_proj.weight": "model-00001-of-00003.safetensors",
866
+ "model.layers.8.mlp.shared_experts.gate_proj.biases": "model-00001-of-00003.safetensors",
867
+ "model.layers.8.mlp.shared_experts.gate_proj.scales": "model-00001-of-00003.safetensors",
868
+ "model.layers.8.mlp.shared_experts.gate_proj.weight": "model-00001-of-00003.safetensors",
869
+ "model.layers.8.mlp.shared_experts.up_proj.biases": "model-00001-of-00003.safetensors",
870
+ "model.layers.8.mlp.shared_experts.up_proj.scales": "model-00001-of-00003.safetensors",
871
+ "model.layers.8.mlp.shared_experts.up_proj.weight": "model-00001-of-00003.safetensors",
872
+ "model.layers.8.mlp.switch_mlp.down_proj.biases": "model-00001-of-00003.safetensors",
873
+ "model.layers.8.mlp.switch_mlp.down_proj.scales": "model-00001-of-00003.safetensors",
874
+ "model.layers.8.mlp.switch_mlp.down_proj.weight": "model-00001-of-00003.safetensors",
875
+ "model.layers.8.mlp.switch_mlp.gate_proj.biases": "model-00001-of-00003.safetensors",
876
+ "model.layers.8.mlp.switch_mlp.gate_proj.scales": "model-00001-of-00003.safetensors",
877
+ "model.layers.8.mlp.switch_mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
878
+ "model.layers.8.mlp.switch_mlp.up_proj.biases": "model-00001-of-00003.safetensors",
879
+ "model.layers.8.mlp.switch_mlp.up_proj.scales": "model-00001-of-00003.safetensors",
880
+ "model.layers.8.mlp.switch_mlp.up_proj.weight": "model-00001-of-00003.safetensors",
881
+ "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
882
+ "model.layers.8.self_attn.k_proj.biases": "model-00001-of-00003.safetensors",
883
+ "model.layers.8.self_attn.k_proj.scales": "model-00001-of-00003.safetensors",
884
+ "model.layers.8.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
885
+ "model.layers.8.self_attn.o_proj.biases": "model-00001-of-00003.safetensors",
886
+ "model.layers.8.self_attn.o_proj.scales": "model-00001-of-00003.safetensors",
887
+ "model.layers.8.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
888
+ "model.layers.8.self_attn.q_proj.biases": "model-00001-of-00003.safetensors",
889
+ "model.layers.8.self_attn.q_proj.scales": "model-00001-of-00003.safetensors",
890
+ "model.layers.8.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
891
+ "model.layers.8.self_attn.v_proj.biases": "model-00001-of-00003.safetensors",
892
+ "model.layers.8.self_attn.v_proj.scales": "model-00001-of-00003.safetensors",
893
+ "model.layers.8.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
894
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00003.safetensors",
895
+ "model.layers.9.mlp.gate.weight": "model-00001-of-00003.safetensors",
896
+ "model.layers.9.mlp.shared_experts.down_proj.biases": "model-00001-of-00003.safetensors",
897
+ "model.layers.9.mlp.shared_experts.down_proj.scales": "model-00001-of-00003.safetensors",
898
+ "model.layers.9.mlp.shared_experts.down_proj.weight": "model-00001-of-00003.safetensors",
899
+ "model.layers.9.mlp.shared_experts.gate_proj.biases": "model-00001-of-00003.safetensors",
900
+ "model.layers.9.mlp.shared_experts.gate_proj.scales": "model-00001-of-00003.safetensors",
901
+ "model.layers.9.mlp.shared_experts.gate_proj.weight": "model-00001-of-00003.safetensors",
902
+ "model.layers.9.mlp.shared_experts.up_proj.biases": "model-00001-of-00003.safetensors",
903
+ "model.layers.9.mlp.shared_experts.up_proj.scales": "model-00001-of-00003.safetensors",
904
+ "model.layers.9.mlp.shared_experts.up_proj.weight": "model-00001-of-00003.safetensors",
905
+ "model.layers.9.mlp.switch_mlp.down_proj.biases": "model-00001-of-00003.safetensors",
906
+ "model.layers.9.mlp.switch_mlp.down_proj.scales": "model-00001-of-00003.safetensors",
907
+ "model.layers.9.mlp.switch_mlp.down_proj.weight": "model-00001-of-00003.safetensors",
908
+ "model.layers.9.mlp.switch_mlp.gate_proj.biases": "model-00001-of-00003.safetensors",
909
+ "model.layers.9.mlp.switch_mlp.gate_proj.scales": "model-00001-of-00003.safetensors",
910
+ "model.layers.9.mlp.switch_mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
911
+ "model.layers.9.mlp.switch_mlp.up_proj.biases": "model-00001-of-00003.safetensors",
912
+ "model.layers.9.mlp.switch_mlp.up_proj.scales": "model-00001-of-00003.safetensors",
913
+ "model.layers.9.mlp.switch_mlp.up_proj.weight": "model-00001-of-00003.safetensors",
914
+ "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
915
+ "model.layers.9.self_attn.k_proj.biases": "model-00001-of-00003.safetensors",
916
+ "model.layers.9.self_attn.k_proj.scales": "model-00001-of-00003.safetensors",
917
+ "model.layers.9.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
918
+ "model.layers.9.self_attn.o_proj.biases": "model-00001-of-00003.safetensors",
919
+ "model.layers.9.self_attn.o_proj.scales": "model-00001-of-00003.safetensors",
920
+ "model.layers.9.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
921
+ "model.layers.9.self_attn.q_proj.biases": "model-00001-of-00003.safetensors",
922
+ "model.layers.9.self_attn.q_proj.scales": "model-00001-of-00003.safetensors",
923
+ "model.layers.9.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
924
+ "model.layers.9.self_attn.v_proj.biases": "model-00001-of-00003.safetensors",
925
+ "model.layers.9.self_attn.v_proj.scales": "model-00001-of-00003.safetensors",
926
+ "model.layers.9.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
927
+ "model.norm.weight": "model-00003-of-00003.safetensors"
928
+ }
929
+ }
modelling_deepseek.py ADDED
@@ -0,0 +1,1436 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ """ PyTorch Deepseek Moe model with fixed Rope and updated code."""
3
+ import math
4
+ from typing import List, Optional, Tuple, Union
5
+
6
+ import torch
7
+ import torch.nn.functional as F
8
+ import torch.utils.checkpoint
9
+ from torch import nn
10
+
11
+ from transformers.activations import ACT2FN
12
+ from transformers.cache_utils import Cache, DynamicCache, StaticCache
13
+ from transformers.generation import GenerationMixin
14
+ from transformers.modeling_attn_mask_utils import AttentionMaskConverter
15
+ from transformers.modeling_flash_attention_utils import FlashAttentionKwargs, _flash_attention_forward
16
+ from transformers.modeling_outputs import (
17
+ BaseModelOutputWithPast,
18
+ CausalLMOutputWithPast,
19
+ SequenceClassifierOutputWithPast,
20
+ )
21
+ from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS
22
+ from transformers.modeling_utils import PreTrainedModel
23
+ from transformers.processing_utils import Unpack
24
+ from transformers.pytorch_utils import ALL_LAYERNORM_LAYERS
25
+ from transformers.utils import (
26
+ LossKwargs,
27
+ add_start_docstrings,
28
+ add_start_docstrings_to_model_forward,
29
+ is_flash_attn_greater_or_equal_2_10,
30
+ logging,
31
+ replace_return_docstrings,
32
+ )
33
+ from .configuration_deepseek import DeepseekConfig
34
+
35
+
36
+ logger = logging.get_logger(__name__)
37
+
38
+ _CONFIG_FOR_DOC = "DeepseekConfig"
39
+
40
+
41
+ class DeepseekRMSNorm(nn.Module):
42
+ def __init__(self, hidden_size, eps=1e-6):
43
+ """
44
+ DeepseekRMSNorm is equivalent to T5LayerNorm
45
+ """
46
+ super().__init__()
47
+ self.weight = nn.Parameter(torch.ones(hidden_size))
48
+ self.variance_epsilon = eps
49
+
50
+ def forward(self, hidden_states):
51
+ input_dtype = hidden_states.dtype
52
+ hidden_states = hidden_states.to(torch.float32)
53
+ variance = hidden_states.pow(2).mean(-1, keepdim=True)
54
+ hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
55
+ return self.weight * hidden_states.to(input_dtype)
56
+
57
+ def extra_repr(self):
58
+ return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
59
+
60
+
61
+ ALL_LAYERNORM_LAYERS.append(DeepseekRMSNorm)
62
+
63
+
64
+ class DeepseekRotaryEmbedding(nn.Module):
65
+ def __init__(
66
+ self,
67
+ dim=None,
68
+ max_position_embeddings=2048,
69
+ base=10000,
70
+ device=None,
71
+ scaling_factor=1.0,
72
+ rope_type="default",
73
+ config: Optional[DeepseekConfig] = None,
74
+ ):
75
+ super().__init__()
76
+ # TODO (joao): remove the `if` below, only used for BC
77
+ self.rope_kwargs = {}
78
+ if config is None:
79
+ logger.warning_once(
80
+ "`DeepseekRotaryEmbedding` can now be fully parameterized by passing the model config through the "
81
+ "`config` argument. All other arguments will be removed in v4.46"
82
+ )
83
+ self.rope_kwargs = {
84
+ "rope_type": rope_type,
85
+ "factor": scaling_factor,
86
+ "dim": dim,
87
+ "base": base,
88
+ "max_position_embeddings": max_position_embeddings,
89
+ }
90
+ self.rope_type = rope_type
91
+ self.max_seq_len_cached = max_position_embeddings
92
+ self.original_max_seq_len = max_position_embeddings
93
+ else:
94
+ # BC: "rope_type" was originally "type"
95
+ if config.rope_scaling is not None:
96
+ self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type"))
97
+ else:
98
+ self.rope_type = "default"
99
+ self.max_seq_len_cached = config.max_position_embeddings
100
+ self.original_max_seq_len = config.max_position_embeddings
101
+
102
+ self.config = config
103
+ self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
104
+
105
+ inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device, **self.rope_kwargs)
106
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
107
+ self.original_inv_freq = self.inv_freq
108
+
109
+ def _dynamic_frequency_update(self, position_ids, device):
110
+ """
111
+ dynamic RoPE layers should recompute `inv_freq` in the following situations:
112
+ 1 - growing beyond the cached sequence length (allow scaling)
113
+ 2 - the current sequence length is in the original scale (avoid losing precision with small sequences)
114
+ """
115
+ seq_len = torch.max(position_ids) + 1
116
+ if seq_len > self.max_seq_len_cached: # growth
117
+ inv_freq, self.attention_scaling = self.rope_init_fn(
118
+ self.config, device, seq_len=seq_len, **self.rope_kwargs
119
+ )
120
+ self.register_buffer("inv_freq", inv_freq, persistent=False) # TODO joao: may break with compilation
121
+ self.max_seq_len_cached = seq_len
122
+
123
+ if seq_len < self.original_max_seq_len and self.max_seq_len_cached > self.original_max_seq_len: # reset
124
+ self.register_buffer("inv_freq", self.original_inv_freq, persistent=False)
125
+ self.max_seq_len_cached = self.original_max_seq_len
126
+
127
+ @torch.no_grad()
128
+ def forward(self, x, position_ids):
129
+ if "dynamic" in self.rope_type:
130
+ self._dynamic_frequency_update(position_ids, device=x.device)
131
+
132
+ # Core RoPE block
133
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
134
+ position_ids_expanded = position_ids[:, None, :].float()
135
+ # Force float32 (see https://github.com/huggingface/transformers/pull/29285)
136
+ device_type = x.device.type
137
+ device_type = device_type if isinstance(device_type, str) and device_type != "mps" else "cpu"
138
+ with torch.autocast(device_type=device_type, enabled=False):
139
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
140
+ emb = torch.cat((freqs, freqs), dim=-1)
141
+ cos = emb.cos()
142
+ sin = emb.sin()
143
+
144
+ # Advanced RoPE types (e.g. yarn) apply a post-processing scaling factor, equivalent to scaling attention
145
+ cos = cos * self.attention_scaling
146
+ sin = sin * self.attention_scaling
147
+
148
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
149
+
150
+
151
+ class DeepseekLinearScalingRotaryEmbedding(DeepseekRotaryEmbedding):
152
+ """DeepseekRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
153
+
154
+ def __init__(self, *args, **kwargs):
155
+ logger.warning_once(
156
+ "`DeepseekLinearScalingRotaryEmbedding` is deprecated an will be removed in v4.46. Please use "
157
+ "`DeepseekRotaryEmbedding`, which now also does linear scaling (simply pass the model config to __init__)."
158
+ )
159
+ kwargs["rope_type"] = "linear"
160
+ super().__init__(*args, **kwargs)
161
+
162
+
163
+ class DeepseekDynamicNTKScalingRotaryEmbedding(DeepseekRotaryEmbedding):
164
+ """DeepseekRotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla"""
165
+
166
+ def __init__(self, *args, **kwargs):
167
+ logger.warning_once(
168
+ "`DeepseekDynamicNTKScalingRotaryEmbedding` is deprecated an will be removed in v4.46. Please use "
169
+ "`DeepseekRotaryEmbedding`, which now also does dynamic ntk scaling (simply pass the model config to "
170
+ "__init__)."
171
+ )
172
+ kwargs["rope_type"] = "dynamic"
173
+ super().__init__(*args, **kwargs)
174
+
175
+
176
+ def rotate_half(x):
177
+ """Rotates half the hidden dims of the input."""
178
+ x1 = x[..., : x.shape[-1] // 2]
179
+ x2 = x[..., x.shape[-1] // 2 :]
180
+ return torch.cat((-x2, x1), dim=-1)
181
+
182
+
183
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
184
+ """Applies Rotary Position Embedding to the query and key tensors.
185
+
186
+ Args:
187
+ q (`torch.Tensor`): The query tensor.
188
+ k (`torch.Tensor`): The key tensor.
189
+ cos (`torch.Tensor`): The cosine part of the rotary embedding.
190
+ sin (`torch.Tensor`): The sine part of the rotary embedding.
191
+ position_ids (`torch.Tensor`, *optional*):
192
+ Deprecated and unused.
193
+ unsqueeze_dim (`int`, *optional*, defaults to 1):
194
+ The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
195
+ sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
196
+ that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
197
+ k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
198
+ cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
199
+ the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
200
+ Returns:
201
+ `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
202
+ """
203
+ cos = cos.unsqueeze(unsqueeze_dim)
204
+ sin = sin.unsqueeze(unsqueeze_dim)
205
+ q_embed = (q * cos) + (rotate_half(q) * sin)
206
+ k_embed = (k * cos) + (rotate_half(k) * sin)
207
+ return q_embed, k_embed
208
+
209
+
210
+ class DeepseekMLP(nn.Module):
211
+ def __init__(self, config, hidden_size=None, intermediate_size=None):
212
+ super().__init__()
213
+ self.config = config
214
+ self.hidden_size = config.hidden_size if hidden_size is None else hidden_size
215
+ self.intermediate_size = config.intermediate_size if intermediate_size is None else intermediate_size
216
+
217
+ self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
218
+ self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
219
+ self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
220
+ self.act_fn = ACT2FN[config.hidden_act]
221
+
222
+ def forward(self, x, **kwargs):
223
+ down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
224
+ return down_proj
225
+
226
+
227
+ class MoEGate(nn.Module):
228
+ def __init__(self, config):
229
+ super().__init__()
230
+ self.config = config
231
+ self.top_k = config.num_experts_per_tok
232
+ self.n_routed_experts = config.n_routed_experts
233
+
234
+ self.scoring_func = config.scoring_func
235
+ self.alpha = config.aux_loss_alpha
236
+ self.seq_aux = config.seq_aux
237
+
238
+ # topk selection algorithm
239
+ self.norm_topk_prob = config.norm_topk_prob
240
+ self.gating_dim = config.hidden_size
241
+ self.weight = nn.Parameter(torch.empty((self.n_routed_experts, self.gating_dim)))
242
+
243
+ self.reset_parameters()
244
+
245
+ def reset_parameters(self) -> None:
246
+ import torch.nn.init as init
247
+ init.kaiming_uniform_(self.weight, a=math.sqrt(5))
248
+
249
+ def forward(self, hidden_states):
250
+ bsz, seq_len, h = hidden_states.shape
251
+ # Compute gating score
252
+ hidden_states = hidden_states.view(-1, h)
253
+ logits = F.linear(hidden_states, self.weight, None)
254
+ if self.scoring_func == 'softmax':
255
+ scores = logits.to(torch.float32).softmax(dim=-1)
256
+ else:
257
+ raise NotImplementedError(f'insupportable scoring function for MoE gating: {self.scoring_func}')
258
+
259
+ # Select top-k experts
260
+ topk_weight, topk_idx = torch.topk(scores, k=self.top_k, dim=-1, sorted=False)
261
+
262
+ # Norm gate to sum 1
263
+ if self.top_k > 1 and self.norm_topk_prob:
264
+ denominator = topk_weight.sum(dim=-1, keepdim=True) + 1e-20
265
+ topk_weight = topk_weight / denominator
266
+
267
+ # Expert-level computation auxiliary loss
268
+ # (was absent before)
269
+ if self.training and self.alpha > 0.0:
270
+ scores_for_aux = scores
271
+ aux_topk = self.top_k
272
+ # always compute aux loss based on the naive greedy topk method
273
+ topk_idx_for_aux_loss = topk_idx.view(bsz, -1)
274
+ if self.seq_aux:
275
+ scores_for_seq_aux = scores_for_aux.view(bsz, seq_len, -1)
276
+ ce = torch.zeros(bsz, self.n_routed_experts, device=hidden_states.device, dtype=torch.float32)
277
+ ce.scatter_add_(
278
+ 1,
279
+ topk_idx_for_aux_loss,
280
+ torch.ones(bsz, seq_len * aux_topk, device=hidden_states.device, dtype=torch.float32)
281
+ )
282
+ ce.div_(seq_len * aux_topk / self.n_routed_experts)
283
+ aux_loss = (ce * scores_for_seq_aux.mean(dim=1)).sum(dim=1).mean() * self.alpha
284
+ else:
285
+ mask_ce = F.one_hot(topk_idx_for_aux_loss.view(-1), num_classes=self.n_routed_experts)
286
+ ce = mask_ce.float().mean(0)
287
+ Pi = scores_for_aux.mean(0)
288
+ fi = ce * self.n_routed_experts
289
+ aux_loss = (Pi * fi).sum() * self.alpha
290
+ else:
291
+ aux_loss = None
292
+ return topk_idx, topk_weight.to(hidden_states.dtype), aux_loss
293
+
294
+
295
+ class AddAuxiliaryLoss(torch.autograd.Function):
296
+ """
297
+ The trick function of adding auxiliary (aux) loss,
298
+ which includes the gradient of the aux loss during backpropagation.
299
+ """
300
+
301
+ @staticmethod
302
+ def forward(ctx, x, loss):
303
+ assert loss.numel() == 1
304
+ ctx.dtype = loss.dtype
305
+ ctx.required_aux_loss = loss.requires_grad
306
+ return x
307
+
308
+ @staticmethod
309
+ def backward(ctx, grad_output):
310
+ grad_loss = None
311
+ if ctx.required_aux_loss:
312
+ grad_loss = torch.ones(1, dtype=ctx.dtype, device=grad_output.device)
313
+ return grad_output, grad_loss
314
+
315
+
316
+ class DeepseekMoE(nn.Module):
317
+ """
318
+ A mixed expert module containing shared experts.
319
+ """
320
+
321
+ def __init__(self, config):
322
+ super().__init__()
323
+ self.config = config
324
+ self.num_experts_per_tok = config.num_experts_per_tok
325
+ self.experts = nn.ModuleList(
326
+ [DeepseekMLP(config, intermediate_size=config.moe_intermediate_size) for i in
327
+ range(config.n_routed_experts)])
328
+ self.gate = MoEGate(config)
329
+ if config.n_shared_experts is not None:
330
+ intermediate_size = config.moe_intermediate_size * config.n_shared_experts
331
+ self.shared_experts = DeepseekMLP(config=config, intermediate_size=intermediate_size)
332
+
333
+ def forward(self, hidden_states):
334
+ identity = hidden_states
335
+ orig_shape = hidden_states.shape
336
+ topk_idx, topk_weight, aux_loss = self.gate(hidden_states)
337
+ hidden_states = hidden_states.view(-1, hidden_states.shape[-1])
338
+ flat_topk_idx = topk_idx.view(-1)
339
+ if self.training:
340
+ y = self.moe_train(hidden_states, flat_topk_idx, topk_weight) # removed unnecessary .view(-1, 1)
341
+ y = y.view(*orig_shape)
342
+ y = AddAuxiliaryLoss.apply(y, aux_loss)
343
+ else:
344
+ y = self.moe_infer(hidden_states, flat_topk_idx, topk_weight).view(*orig_shape) # removed unnecessary .view(-1, 1)
345
+ if self.config.n_shared_experts is not None:
346
+ y = y + self.shared_experts(identity)
347
+ return y
348
+
349
+ def moe_train(self, hidden_states, flat_topk_idx, topk_weight):
350
+ hidden_states = hidden_states.repeat_interleave(self.num_experts_per_tok, dim=0)
351
+ y = torch.empty_like(hidden_states)
352
+ for i, expert in enumerate(self.experts):
353
+ y[flat_topk_idx == i] = expert(hidden_states[flat_topk_idx == i])
354
+ y = (y.view(*topk_weight.shape, -1) * topk_weight.unsqueeze(-1)).sum(dim=1)
355
+ return y.to(hidden_states.dtype) # .sum() in previous line returns fp32 tensor
356
+
357
+ @torch.no_grad()
358
+ def moe_infer(self, x, flat_expert_indices, flat_expert_weights):
359
+ expert_cache = torch.zeros_like(x)
360
+ idxs = flat_expert_indices.argsort()
361
+ tokens_per_expert = flat_expert_indices.bincount().cpu().numpy().cumsum(0)
362
+ token_idxs = idxs // self.num_experts_per_tok
363
+ for i, end_idx in enumerate(tokens_per_expert):
364
+ start_idx = 0 if i == 0 else tokens_per_expert[i - 1]
365
+ if start_idx == end_idx:
366
+ continue
367
+ expert = self.experts[i]
368
+ exp_token_idx = token_idxs[start_idx:end_idx]
369
+ expert_tokens = x[exp_token_idx]
370
+ expert_out = expert(expert_tokens)
371
+ expert_out.mul_(flat_expert_weights[idxs[start_idx:end_idx]])
372
+ expert_cache.scatter_reduce_(0, exp_token_idx.view(-1, 1).repeat(1, x.shape[-1]), expert_out, reduce='sum')
373
+ return expert_cache
374
+
375
+
376
+ Deepseek_MOE_CLASSES = {
377
+ 'eager': DeepseekMoE,
378
+ }
379
+
380
+ # Copied from transformers.models.llama.modeling_llama.repeat_kv
381
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
382
+ """
383
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
384
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
385
+ """
386
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
387
+ if n_rep == 1:
388
+ return hidden_states
389
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
390
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
391
+
392
+
393
+ # Copied from transformers.models.llama.modeling_llama.LlamaAttention with Llama->Deepseek
394
+ class DeepseekAttention(nn.Module):
395
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
396
+
397
+ def __init__(self, config: DeepseekConfig, layer_idx: Optional[int] = None):
398
+ super().__init__()
399
+ self.config = config
400
+ self.layer_idx = layer_idx
401
+ if layer_idx is None:
402
+ logger.warning_once(
403
+ f"Instantiating {self.__class__.__name__} without passing a `layer_idx` is not recommended and will "
404
+ "lead to errors during the forward call if caching is used. Please make sure to provide a `layer_idx` "
405
+ "when creating this class."
406
+ )
407
+
408
+ self.attention_dropout = config.attention_dropout
409
+ self.hidden_size = config.hidden_size
410
+ self.num_heads = config.num_attention_heads
411
+ self.head_dim = getattr(config, "head_dim", self.hidden_size // self.num_heads)
412
+ self.num_key_value_heads = config.num_key_value_heads
413
+ self.num_key_value_groups = self.num_heads // self.num_key_value_heads
414
+ self.max_position_embeddings = config.max_position_embeddings
415
+ self.rope_theta = config.rope_theta
416
+ self.is_causal = True
417
+
418
+ self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=config.attention_bias)
419
+ self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
420
+ self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
421
+ self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=config.attention_bias)
422
+
423
+ # TODO (joao): remove in v4.46 (RoPE is computed in the model, not in the decoder layers)
424
+ self.rotary_emb = DeepseekRotaryEmbedding(config=self.config)
425
+
426
+ def forward(
427
+ self,
428
+ hidden_states: torch.Tensor,
429
+ attention_mask: Optional[torch.Tensor] = None,
430
+ position_ids: Optional[torch.LongTensor] = None,
431
+ past_key_value: Optional[Cache] = None,
432
+ output_attentions: bool = False,
433
+ use_cache: bool = False,
434
+ cache_position: Optional[torch.LongTensor] = None,
435
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # will become mandatory in v4.46
436
+ **kwargs,
437
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
438
+ bsz, q_len, _ = hidden_states.size()
439
+
440
+ query_states = self.q_proj(hidden_states)
441
+ key_states = self.k_proj(hidden_states)
442
+ value_states = self.v_proj(hidden_states)
443
+
444
+ # use -1 to infer num_heads and num_key_value_heads as they may vary if tensor parallel is used
445
+ query_states = query_states.view(bsz, q_len, -1, self.head_dim).transpose(1, 2)
446
+ key_states = key_states.view(bsz, q_len, -1, self.head_dim).transpose(1, 2)
447
+ value_states = value_states.view(bsz, q_len, -1, self.head_dim).transpose(1, 2)
448
+
449
+ if position_embeddings is None:
450
+ logger.warning_once(
451
+ "The attention layers in this model are transitioning from computing the RoPE embeddings internally "
452
+ "through `position_ids` (2D tensor with the indexes of the tokens), to using externally computed "
453
+ "`position_embeddings` (Tuple of tensors, containing cos and sin). In v4.46 `position_ids` will be "
454
+ "removed and `position_embeddings` will be mandatory."
455
+ )
456
+ cos, sin = self.rotary_emb(value_states, position_ids)
457
+ else:
458
+ cos, sin = position_embeddings
459
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
460
+
461
+ if past_key_value is not None:
462
+ # sin and cos are specific to RoPE models; cache_position needed for the static cache
463
+ cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
464
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
465
+
466
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
467
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
468
+ attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
469
+
470
+ if attention_mask is not None: # no matter the length, we just slice it
471
+ causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
472
+ attn_weights = attn_weights + causal_mask
473
+
474
+ # upcast attention to fp32
475
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
476
+ attn_weights = nn.functional.dropout(attn_weights, p=self.attention_dropout, training=self.training)
477
+ attn_output = torch.matmul(attn_weights, value_states)
478
+
479
+ if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
480
+ raise ValueError(
481
+ f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
482
+ f" {attn_output.size()}"
483
+ )
484
+
485
+ attn_output = attn_output.transpose(1, 2).contiguous()
486
+
487
+ attn_output = attn_output.reshape(bsz, q_len, -1)
488
+
489
+ attn_output = self.o_proj(attn_output)
490
+
491
+ if not output_attentions:
492
+ attn_weights = None
493
+
494
+ return attn_output, attn_weights, past_key_value
495
+
496
+
497
+ # Copied from transformers.models.llama.modeling_llama.LlamaFlashAttention2 with Llama->Deepseek
498
+ class DeepseekFlashAttention2(DeepseekAttention):
499
+ """
500
+ Deepseek flash attention module. This module inherits from `DeepseekAttention` as the weights of the module stays
501
+ untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
502
+ flash attention and deal with padding tokens in case the input contains any of them.
503
+ """
504
+
505
+ def __init__(self, *args, **kwargs):
506
+ super().__init__(*args, **kwargs)
507
+
508
+ # TODO: Should be removed once Flash Attention for RoCm is bumped to 2.1.
509
+ # flash_attn<2.1 generates top-left aligned causal mask, while what is needed here is bottom-right alignement, that was made default for flash_attn>=2.1. This attribute is used to handle this difference. Reference: https://github.com/Dao-AILab/flash-attention/releases/tag/v2.1.0.
510
+ # Beware that with flash_attn<2.1, using q_seqlen != k_seqlen (except for the case q_seqlen == 1) produces a wrong mask (top-left).
511
+ self._flash_attn_uses_top_left_mask = not is_flash_attn_greater_or_equal_2_10()
512
+
513
+ def forward(
514
+ self,
515
+ hidden_states: torch.Tensor,
516
+ attention_mask: Optional[torch.LongTensor] = None,
517
+ position_ids: Optional[torch.LongTensor] = None,
518
+ past_key_value: Optional[Cache] = None,
519
+ output_attentions: bool = False,
520
+ use_cache: bool = False,
521
+ cache_position: Optional[torch.LongTensor] = None,
522
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # will become mandatory in v4.46
523
+ **kwargs: Unpack[FlashAttentionKwargs],
524
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
525
+ if isinstance(past_key_value, StaticCache):
526
+ raise ValueError(
527
+ "`static` cache implementation is not compatible with `attn_implementation==flash_attention_2` "
528
+ "make sure to use `sdpa` in the mean time, and open an issue at https://github.com/huggingface/transformers"
529
+ )
530
+
531
+ output_attentions = False
532
+
533
+ bsz, q_len, _ = hidden_states.size()
534
+
535
+ query_states = self.q_proj(hidden_states)
536
+ key_states = self.k_proj(hidden_states)
537
+ value_states = self.v_proj(hidden_states)
538
+
539
+ # Flash attention requires the input to have the shape
540
+ # batch_size x seq_length x head_dim x hidden_dim
541
+ # therefore we just need to keep the original shape
542
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
543
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
544
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
545
+
546
+ if position_embeddings is None:
547
+ logger.warning_once(
548
+ "The attention layers in this model are transitioning from computing the RoPE embeddings internally "
549
+ "through `position_ids` (2D tensor with the indexes of the tokens), to using externally computed "
550
+ "`position_embeddings` (Tuple of tensors, containing cos and sin). In v4.46 `position_ids` will be "
551
+ "removed and `position_embeddings` will be mandatory."
552
+ )
553
+ cos, sin = self.rotary_emb(value_states, position_ids)
554
+ else:
555
+ cos, sin = position_embeddings
556
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
557
+
558
+ if past_key_value is not None:
559
+ # sin and cos are specific to RoPE models; cache_position needed for the static cache
560
+ cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
561
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
562
+
563
+ # TODO: These transpose are quite inefficient but Flash Attention requires the layout [batch_size, sequence_length, num_heads, head_dim]. We would need to refactor the KV cache
564
+ # to be able to avoid many of these transpose/reshape/view.
565
+ query_states = query_states.transpose(1, 2)
566
+ key_states = key_states.transpose(1, 2)
567
+ value_states = value_states.transpose(1, 2)
568
+
569
+ dropout_rate = self.attention_dropout if self.training else 0.0
570
+
571
+ # In PEFT, usually we cast the layer norms in float32 for training stability reasons
572
+ # therefore the input hidden states gets silently casted in float32. Hence, we need
573
+ # cast them back in the correct dtype just to be sure everything works as expected.
574
+ # This might slowdown training & inference so it is recommended to not cast the LayerNorms
575
+ # in fp32. (DeepseekRMSNorm handles it correctly)
576
+
577
+ input_dtype = query_states.dtype
578
+ if input_dtype == torch.float32:
579
+ if torch.is_autocast_enabled():
580
+ target_dtype = torch.get_autocast_gpu_dtype()
581
+ # Handle the case where the model is quantized
582
+ elif hasattr(self.config, "_pre_quantization_dtype"):
583
+ target_dtype = self.config._pre_quantization_dtype
584
+ else:
585
+ target_dtype = self.q_proj.weight.dtype
586
+
587
+ logger.warning_once(
588
+ f"The input hidden states seems to be silently casted in float32, this might be related to"
589
+ f" the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
590
+ f" {target_dtype}."
591
+ )
592
+
593
+ query_states = query_states.to(target_dtype)
594
+ key_states = key_states.to(target_dtype)
595
+ value_states = value_states.to(target_dtype)
596
+
597
+ attn_output = _flash_attention_forward(
598
+ query_states,
599
+ key_states,
600
+ value_states,
601
+ attention_mask,
602
+ q_len,
603
+ position_ids=position_ids,
604
+ dropout=dropout_rate,
605
+ sliding_window=getattr(self, "sliding_window", None),
606
+ use_top_left_mask=self._flash_attn_uses_top_left_mask,
607
+ is_causal=self.is_causal,
608
+ **kwargs,
609
+ )
610
+
611
+ attn_output = attn_output.reshape(bsz, q_len, -1).contiguous()
612
+ attn_output = self.o_proj(attn_output)
613
+
614
+ if not output_attentions:
615
+ attn_weights = None
616
+
617
+ return attn_output, attn_weights, past_key_value
618
+
619
+ # Copied from transformers.models.llama.modeling_llama.LlamaSdpaAttention with Llama->Deepseek
620
+ class DeepseekSdpaAttention(DeepseekAttention):
621
+ """
622
+ Deepseek attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
623
+ `DeepseekAttention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to
624
+ SDPA API.
625
+ """
626
+
627
+ # Adapted from DeepseekAttention.forward
628
+ def forward(
629
+ self,
630
+ hidden_states: torch.Tensor,
631
+ attention_mask: Optional[torch.Tensor] = None,
632
+ position_ids: Optional[torch.LongTensor] = None,
633
+ past_key_value: Optional[Cache] = None,
634
+ output_attentions: bool = False,
635
+ use_cache: bool = False,
636
+ cache_position: Optional[torch.LongTensor] = None,
637
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # will become mandatory in v4.46
638
+ **kwargs,
639
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
640
+ if output_attentions:
641
+ # TODO: Improve this warning with e.g. `model.config.attn_implementation = "manual"` once this is implemented.
642
+ logger.warning_once(
643
+ "DeepseekModel is using DeepseekSdpaAttention, but `torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. Falling back to the manual attention implementation, "
644
+ 'but specifying the manual implementation will be required from Transformers version v5.0.0 onwards. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.'
645
+ )
646
+ return super().forward(
647
+ hidden_states=hidden_states,
648
+ attention_mask=attention_mask,
649
+ position_ids=position_ids,
650
+ past_key_value=past_key_value,
651
+ output_attentions=output_attentions,
652
+ use_cache=use_cache,
653
+ cache_position=cache_position,
654
+ position_embeddings=position_embeddings,
655
+ )
656
+
657
+ bsz, q_len, _ = hidden_states.size()
658
+
659
+ query_states = self.q_proj(hidden_states)
660
+ key_states = self.k_proj(hidden_states)
661
+ value_states = self.v_proj(hidden_states)
662
+
663
+ # use -1 to infer num_heads and num_key_value_heads as they may vary if tensor parallel is used
664
+ query_states = query_states.view(bsz, q_len, -1, self.head_dim).transpose(1, 2)
665
+ key_states = key_states.view(bsz, q_len, -1, self.head_dim).transpose(1, 2)
666
+ value_states = value_states.view(bsz, q_len, -1, self.head_dim).transpose(1, 2)
667
+
668
+ if position_embeddings is None:
669
+ logger.warning_once(
670
+ "The attention layers in this model are transitioning from computing the RoPE embeddings internally "
671
+ "through `position_ids` (2D tensor with the indexes of the tokens), to using externally computed "
672
+ "`position_embeddings` (Tuple of tensors, containing cos and sin). In v4.46 `position_ids` will be "
673
+ "removed and `position_embeddings` will be mandatory."
674
+ )
675
+ cos, sin = self.rotary_emb(value_states, position_ids)
676
+ else:
677
+ cos, sin = position_embeddings
678
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
679
+
680
+ if past_key_value is not None:
681
+ # sin and cos are specific to RoPE models; cache_position needed for the static cache
682
+ cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
683
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
684
+
685
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
686
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
687
+
688
+ causal_mask = attention_mask
689
+ if attention_mask is not None:
690
+ causal_mask = causal_mask[:, :, :, : key_states.shape[-2]]
691
+
692
+ # SDPA with memory-efficient backend is currently (torch==2.1.2) bugged with non-contiguous inputs with custom attn_mask,
693
+ # Reference: https://github.com/pytorch/pytorch/issues/112577.
694
+ if query_states.device.type == "cuda" and causal_mask is not None:
695
+ query_states = query_states.contiguous()
696
+ key_states = key_states.contiguous()
697
+ value_states = value_states.contiguous()
698
+
699
+ # We dispatch to SDPA's Flash Attention or Efficient kernels via this `is_causal` if statement instead of an inline conditional assignment
700
+ # in SDPA to support both torch.compile's dynamic shapes and full graph options. An inline conditional prevents dynamic shapes from compiling.
701
+ is_causal = True if causal_mask is None and q_len > 1 else False
702
+
703
+ attn_output = torch.nn.functional.scaled_dot_product_attention(
704
+ query_states,
705
+ key_states,
706
+ value_states,
707
+ attn_mask=causal_mask,
708
+ dropout_p=self.attention_dropout if self.training else 0.0,
709
+ is_causal=is_causal,
710
+ )
711
+
712
+ attn_output = attn_output.transpose(1, 2).contiguous()
713
+ attn_output = attn_output.view(bsz, q_len, -1)
714
+
715
+ attn_output = self.o_proj(attn_output)
716
+
717
+ return attn_output, None, past_key_value
718
+
719
+
720
+ Deepseek_ATTENTION_CLASSES = {
721
+ "eager": DeepseekAttention,
722
+ "flash_attention_2": DeepseekFlashAttention2,
723
+ "sdpa": DeepseekSdpaAttention,
724
+ }
725
+
726
+
727
+ class DeepseekDecoderLayer(nn.Module):
728
+ def __init__(self, config: DeepseekConfig, layer_idx: int):
729
+ super().__init__()
730
+ self.hidden_size = config.hidden_size
731
+
732
+ self.self_attn = Deepseek_ATTENTION_CLASSES[config._attn_implementation](config=config,
733
+ layer_idx=layer_idx)
734
+
735
+ self.mlp = Deepseek_MOE_CLASSES[config.moe_implementation](config) if (config.n_routed_experts is not None and \
736
+ layer_idx >= config.first_k_dense_replace and layer_idx % config.moe_layer_freq == 0) \
737
+ else DeepseekMLP(config)
738
+ self.input_layernorm = DeepseekRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
739
+ self.post_attention_layernorm = DeepseekRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
740
+
741
+ def forward(
742
+ self,
743
+ hidden_states: torch.Tensor,
744
+ attention_mask: Optional[torch.Tensor] = None,
745
+ position_ids: Optional[torch.LongTensor] = None,
746
+ past_key_value: Optional[Cache] = None,
747
+ output_attentions: Optional[bool] = False,
748
+ use_cache: Optional[bool] = False,
749
+ cache_position: Optional[torch.LongTensor] = None,
750
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # will become mandatory in v4.46
751
+ **kwargs,
752
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
753
+ """
754
+ Args:
755
+ hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
756
+ attention_mask (`torch.FloatTensor`, *optional*):
757
+ attention mask of size `(batch_size, sequence_length)` if flash attention is used or `(batch_size, 1,
758
+ query_sequence_length, key_sequence_length)` if default attention is used.
759
+ output_attentions (`bool`, *optional*):
760
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under
761
+ returned tensors for more detail.
762
+ use_cache (`bool`, *optional*):
763
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
764
+ (see `past_key_values`).
765
+ past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
766
+ cache_position (`torch.LongTensor` of shape `(sequence_length)`, *optional*):
767
+ Indices depicting the position of the input sequence tokens in the sequence
768
+ position_embeddings (`Tuple[torch.FloatTensor, torch.FloatTensor]`, *optional*):
769
+ Tuple containing the cosine and sine positional embeddings of shape `(batch_size, seq_len, head_dim)`,
770
+ with `head_dim` being the embedding dimension of each attention head.
771
+ kwargs (`dict`, *optional*):
772
+ Arbitrary kwargs to be ignored, used for FSDP and other methods that injects code
773
+ into the model
774
+ """
775
+ residual = hidden_states
776
+
777
+ hidden_states = self.input_layernorm(hidden_states)
778
+
779
+ # Self Attention
780
+ hidden_states, self_attn_weights, present_key_value = self.self_attn(
781
+ hidden_states=hidden_states,
782
+ attention_mask=attention_mask,
783
+ position_ids=position_ids,
784
+ past_key_value=past_key_value,
785
+ output_attentions=output_attentions,
786
+ use_cache=use_cache,
787
+ cache_position=cache_position,
788
+ position_embeddings=position_embeddings,
789
+ **kwargs,
790
+ )
791
+ hidden_states = residual + hidden_states
792
+
793
+ # Fully Connected
794
+ residual = hidden_states
795
+ hidden_states = self.post_attention_layernorm(hidden_states)
796
+ hidden_states = self.mlp(hidden_states)
797
+ hidden_states = residual + hidden_states
798
+
799
+ outputs = (hidden_states,)
800
+
801
+ if output_attentions:
802
+ outputs += (self_attn_weights,)
803
+
804
+ if use_cache:
805
+ outputs += (present_key_value,)
806
+
807
+ return outputs
808
+
809
+
810
+ Deepseek_START_DOCSTRING = r"""
811
+ This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
812
+ library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
813
+ etc.)
814
+
815
+ This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
816
+ Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
817
+ and behavior.
818
+
819
+ Parameters:
820
+ config ([`DeepseekConfig`]):
821
+ Model configuration class with all the parameters of the model. Initializing with a config file does not
822
+ load the weights associated with the model, only the configuration. Check out the
823
+ [`~PreTrainedModel.from_pretrained`] method to load the model weights.
824
+ """
825
+
826
+
827
+ @add_start_docstrings(
828
+ "The bare Deepseek Model outputting raw hidden-states without any specific head on top.",
829
+ Deepseek_START_DOCSTRING,
830
+ )
831
+ class DeepseekPreTrainedModel(PreTrainedModel):
832
+ config_class = DeepseekConfig
833
+ base_model_prefix = "model"
834
+ supports_gradient_checkpointing = True
835
+ _no_split_modules = ["DeepseekDecoderLayer"]
836
+ _skip_keys_device_placement = "past_key_values"
837
+ _supports_flash_attn_2 = True
838
+ _supports_sdpa = True
839
+ _supports_cache_class = True
840
+ _supports_quantized_cache = True
841
+ _supports_static_cache = True
842
+
843
+ def _init_weights(self, module):
844
+ std = self.config.initializer_range
845
+ if isinstance(module, nn.Linear):
846
+ module.weight.data.normal_(mean=0.0, std=std)
847
+ if module.bias is not None:
848
+ module.bias.data.zero_()
849
+ elif isinstance(module, nn.Embedding):
850
+ module.weight.data.normal_(mean=0.0, std=std)
851
+ if module.padding_idx is not None:
852
+ module.weight.data[module.padding_idx].zero_()
853
+
854
+
855
+ Deepseek_INPUTS_DOCSTRING = r"""
856
+ Args:
857
+ input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
858
+ Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
859
+ it.
860
+
861
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
862
+ [`PreTrainedTokenizer.__call__`] for details.
863
+
864
+ [What are input IDs?](../glossary#input-ids)
865
+ attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
866
+ Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
867
+
868
+ - 1 for tokens that are **not masked**,
869
+ - 0 for tokens that are **masked**.
870
+
871
+ [What are attention masks?](../glossary#attention-mask)
872
+
873
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
874
+ [`PreTrainedTokenizer.__call__`] for details.
875
+
876
+ If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
877
+ `past_key_values`).
878
+
879
+ If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
880
+ and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
881
+ information on the default strategy.
882
+
883
+ - 1 indicates the head is **not masked**,
884
+ - 0 indicates the head is **masked**.
885
+ position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
886
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
887
+ config.n_positions - 1]`.
888
+
889
+ [What are position IDs?](../glossary#position-ids)
890
+ past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
891
+ Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
892
+ blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
893
+ returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.
894
+
895
+ Two formats are allowed:
896
+ - a [`~cache_utils.Cache`] instance, see our
897
+ [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache);
898
+ - Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
899
+ shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
900
+ cache format.
901
+
902
+ The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
903
+ legacy cache format will be returned.
904
+
905
+ If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
906
+ have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
907
+ of shape `(batch_size, sequence_length)`.
908
+ inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
909
+ Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
910
+ is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
911
+ model's internal embedding lookup matrix.
912
+ use_cache (`bool`, *optional*):
913
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
914
+ `past_key_values`).
915
+ output_attentions (`bool`, *optional*):
916
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
917
+ tensors for more detail.
918
+ output_hidden_states (`bool`, *optional*):
919
+ Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
920
+ more detail.
921
+ return_dict (`bool`, *optional*):
922
+ Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
923
+ cache_position (`torch.LongTensor` of shape `(sequence_length)`, *optional*):
924
+ Indices depicting the position of the input sequence tokens in the sequence. Contrarily to `position_ids`,
925
+ this tensor is not affected by padding. It is used to update the cache in the correct position and to infer
926
+ the complete sequence length.
927
+ """
928
+
929
+
930
+ @add_start_docstrings(
931
+ "The bare Deepseek Model outputting raw hidden-states without any specific head on top.",
932
+ Deepseek_START_DOCSTRING,
933
+ )
934
+ class DeepseekModel(DeepseekPreTrainedModel):
935
+ """
936
+ Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`DeepseekDecoderLayer`]
937
+
938
+ Args:
939
+ config: DeepseekConfig
940
+ """
941
+
942
+ def __init__(self, config: DeepseekConfig):
943
+ super().__init__(config)
944
+ self.padding_idx = config.pad_token_id
945
+ self.vocab_size = config.vocab_size
946
+
947
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
948
+ self.layers = nn.ModuleList(
949
+ [DeepseekDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
950
+ )
951
+ self.norm = DeepseekRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
952
+ self.rotary_emb = DeepseekRotaryEmbedding(config=config)
953
+
954
+ self.gradient_checkpointing = False
955
+ if getattr(config, "pretraining_tp", 1) != 1:
956
+ logger.warn("`pretraining_tp` is deprecated, please use `model.tensor_parallel` instead.")
957
+
958
+ # Initialize weights and apply final processing
959
+ self.post_init()
960
+
961
+ def get_input_embeddings(self):
962
+ return self.embed_tokens
963
+
964
+ def set_input_embeddings(self, value):
965
+ self.embed_tokens = value
966
+
967
+ @add_start_docstrings_to_model_forward(Deepseek_INPUTS_DOCSTRING)
968
+ def forward(
969
+ self,
970
+ input_ids: torch.LongTensor = None,
971
+ attention_mask: Optional[torch.Tensor] = None,
972
+ position_ids: Optional[torch.LongTensor] = None,
973
+ past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
974
+ inputs_embeds: Optional[torch.FloatTensor] = None,
975
+ use_cache: Optional[bool] = None,
976
+ output_attentions: Optional[bool] = None,
977
+ output_hidden_states: Optional[bool] = None,
978
+ return_dict: Optional[bool] = None,
979
+ cache_position: Optional[torch.LongTensor] = None,
980
+ **flash_attn_kwargs: Unpack[FlashAttentionKwargs],
981
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
982
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
983
+ output_hidden_states = (
984
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
985
+ )
986
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
987
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
988
+
989
+ if (input_ids is None) ^ (inputs_embeds is not None):
990
+ raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
991
+
992
+ if self.gradient_checkpointing and self.training and use_cache:
993
+ logger.warning_once(
994
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`."
995
+ )
996
+ use_cache = False
997
+
998
+ if inputs_embeds is None:
999
+ inputs_embeds = self.embed_tokens(input_ids)
1000
+
1001
+ # kept for BC (non `Cache` `past_key_values` inputs)
1002
+ return_legacy_cache = False
1003
+ if use_cache and not isinstance(past_key_values, Cache):
1004
+ return_legacy_cache = True
1005
+ if past_key_values is None:
1006
+ past_key_values = DynamicCache()
1007
+ else:
1008
+ past_key_values = DynamicCache.from_legacy_cache(past_key_values)
1009
+ logger.warning_once(
1010
+ "We detected that you are passing `past_key_values` as a tuple of tuples. This is deprecated and "
1011
+ "will be removed in v4.47. Please convert your cache or use an appropriate `Cache` class "
1012
+ "(https://huggingface.co/docs/transformers/kv_cache#legacy-cache-format)"
1013
+ )
1014
+
1015
+ if cache_position is None:
1016
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
1017
+ cache_position = torch.arange(
1018
+ past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device
1019
+ )
1020
+ if position_ids is None:
1021
+ position_ids = cache_position.unsqueeze(0)
1022
+
1023
+ causal_mask = self._update_causal_mask(
1024
+ attention_mask, inputs_embeds, cache_position, past_key_values, output_attentions
1025
+ )
1026
+ hidden_states = inputs_embeds
1027
+
1028
+ # create position embeddings to be shared across the decoder layers
1029
+ position_embeddings = self.rotary_emb(hidden_states, position_ids)
1030
+
1031
+ # decoder layers
1032
+ all_hidden_states = () if output_hidden_states else None
1033
+ all_self_attns = () if output_attentions else None
1034
+ next_decoder_cache = None
1035
+
1036
+ for decoder_layer in self.layers[: self.config.num_hidden_layers]:
1037
+ if output_hidden_states:
1038
+ all_hidden_states += (hidden_states,)
1039
+
1040
+ if self.gradient_checkpointing and self.training:
1041
+ layer_outputs = self._gradient_checkpointing_func(
1042
+ decoder_layer.__call__,
1043
+ hidden_states,
1044
+ causal_mask,
1045
+ position_ids,
1046
+ past_key_values,
1047
+ output_attentions,
1048
+ use_cache,
1049
+ cache_position,
1050
+ position_embeddings,
1051
+ )
1052
+ else:
1053
+ layer_outputs = decoder_layer(
1054
+ hidden_states,
1055
+ attention_mask=causal_mask,
1056
+ position_ids=position_ids,
1057
+ past_key_value=past_key_values,
1058
+ output_attentions=output_attentions,
1059
+ use_cache=use_cache,
1060
+ cache_position=cache_position,
1061
+ position_embeddings=position_embeddings,
1062
+ **flash_attn_kwargs,
1063
+ )
1064
+
1065
+ hidden_states = layer_outputs[0]
1066
+
1067
+ if use_cache:
1068
+ next_decoder_cache = layer_outputs[2 if output_attentions else 1]
1069
+
1070
+ if output_attentions:
1071
+ all_self_attns += (layer_outputs[1],)
1072
+
1073
+ hidden_states = self.norm(hidden_states)
1074
+
1075
+ # add hidden states from the last decoder layer
1076
+ if output_hidden_states:
1077
+ all_hidden_states += (hidden_states,)
1078
+
1079
+ next_cache = next_decoder_cache if use_cache else None
1080
+ if return_legacy_cache:
1081
+ next_cache = next_cache.to_legacy_cache()
1082
+
1083
+ if not return_dict:
1084
+ return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
1085
+ return BaseModelOutputWithPast(
1086
+ last_hidden_state=hidden_states,
1087
+ past_key_values=next_cache,
1088
+ hidden_states=all_hidden_states,
1089
+ attentions=all_self_attns,
1090
+ )
1091
+
1092
+ def _update_causal_mask(
1093
+ self,
1094
+ attention_mask: torch.Tensor,
1095
+ input_tensor: torch.Tensor,
1096
+ cache_position: torch.Tensor,
1097
+ past_key_values: Cache,
1098
+ output_attentions: bool,
1099
+ ):
1100
+ if self.config._attn_implementation == "flash_attention_2":
1101
+ if attention_mask is not None and 0.0 in attention_mask:
1102
+ return attention_mask
1103
+ return None
1104
+
1105
+ # For SDPA, when possible, we will rely on its `is_causal` argument instead of its `attn_mask` argument, in
1106
+ # order to dispatch on Flash Attention 2. This feature is not compatible with static cache, as SDPA will fail
1107
+ # to infer the attention mask.
1108
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
1109
+ using_static_cache = isinstance(past_key_values, StaticCache)
1110
+
1111
+ # When output attentions is True, sdpa implementation's forward method calls the eager implementation's forward
1112
+ if self.config._attn_implementation == "sdpa" and not using_static_cache and not output_attentions:
1113
+ if AttentionMaskConverter._ignore_causal_mask_sdpa(
1114
+ attention_mask,
1115
+ inputs_embeds=input_tensor,
1116
+ past_key_values_length=past_seen_tokens,
1117
+ is_training=self.training,
1118
+ ):
1119
+ return None
1120
+
1121
+ dtype, device = input_tensor.dtype, input_tensor.device
1122
+ sequence_length = input_tensor.shape[1]
1123
+ if using_static_cache:
1124
+ target_length = past_key_values.get_max_cache_shape()
1125
+ else:
1126
+ target_length = (
1127
+ attention_mask.shape[-1]
1128
+ if isinstance(attention_mask, torch.Tensor)
1129
+ else past_seen_tokens + sequence_length + 1
1130
+ )
1131
+
1132
+ # In case the provided `attention` mask is 2D, we generate a causal mask here (4D).
1133
+ causal_mask = self._prepare_4d_causal_attention_mask_with_cache_position(
1134
+ attention_mask,
1135
+ sequence_length=sequence_length,
1136
+ target_length=target_length,
1137
+ dtype=dtype,
1138
+ device=device,
1139
+ cache_position=cache_position,
1140
+ batch_size=input_tensor.shape[0],
1141
+ )
1142
+
1143
+ if (
1144
+ self.config._attn_implementation == "sdpa"
1145
+ and attention_mask is not None
1146
+ and attention_mask.device.type == "cuda"
1147
+ and not output_attentions
1148
+ ):
1149
+ # Attend to all tokens in fully masked rows in the causal_mask, for example the relevant first rows when
1150
+ # using left padding. This is required by F.scaled_dot_product_attention memory-efficient attention path.
1151
+ # Details: https://github.com/pytorch/pytorch/issues/110213
1152
+ min_dtype = torch.finfo(dtype).min
1153
+ causal_mask = AttentionMaskConverter._unmask_unattended(causal_mask, min_dtype)
1154
+
1155
+ return causal_mask
1156
+
1157
+ @staticmethod
1158
+ def _prepare_4d_causal_attention_mask_with_cache_position(
1159
+ attention_mask: torch.Tensor,
1160
+ sequence_length: int,
1161
+ target_length: int,
1162
+ dtype: torch.dtype,
1163
+ device: torch.device,
1164
+ cache_position: torch.Tensor,
1165
+ batch_size: int,
1166
+ **kwargs,
1167
+ ):
1168
+ """
1169
+ Creates a causal 4D mask of shape `(batch_size, 1, query_length, key_value_length)` from a 2D mask of shape
1170
+ `(batch_size, key_value_length)`, or if the input `attention_mask` is already 4D, do nothing.
1171
+
1172
+ Args:
1173
+ attention_mask (`torch.Tensor`):
1174
+ A 2D attention mask of shape `(batch_size, key_value_length)` or a 4D attention mask of shape
1175
+ `(batch_size, 1, query_length, key_value_length)`.
1176
+ sequence_length (`int`):
1177
+ The sequence length being processed.
1178
+ target_length (`int`):
1179
+ The target length: when generating with static cache, the mask should be as long as the static cache,
1180
+ to account for the 0 padding, the part of the cache that is not filled yet.
1181
+ dtype (`torch.dtype`):
1182
+ The dtype to use for the 4D attention mask.
1183
+ device (`torch.device`):
1184
+ The device to plcae the 4D attention mask on.
1185
+ cache_position (`torch.Tensor`):
1186
+ Indices depicting the position of the input sequence tokens in the sequence.
1187
+ batch_size (`torch.Tensor`):
1188
+ Batch size.
1189
+ """
1190
+ if attention_mask is not None and attention_mask.dim() == 4:
1191
+ # In this case we assume that the mask comes already in inverted form and requires no inversion or slicing.
1192
+ causal_mask = attention_mask
1193
+ else:
1194
+ min_dtype = torch.finfo(dtype).min
1195
+ causal_mask = torch.full(
1196
+ (sequence_length, target_length), fill_value=min_dtype, dtype=dtype, device=device
1197
+ )
1198
+ if sequence_length != 1:
1199
+ causal_mask = torch.triu(causal_mask, diagonal=1)
1200
+ causal_mask *= torch.arange(target_length, device=device) > cache_position.reshape(-1, 1)
1201
+ causal_mask = causal_mask[None, None, :, :].expand(batch_size, 1, -1, -1)
1202
+ if attention_mask is not None:
1203
+ causal_mask = causal_mask.clone() # copy to contiguous memory for in-place edit
1204
+ mask_length = attention_mask.shape[-1]
1205
+ padding_mask = causal_mask[:, :, :, :mask_length] + attention_mask[:, None, None, :]
1206
+ padding_mask = padding_mask == 0
1207
+ causal_mask[:, :, :, :mask_length] = causal_mask[:, :, :, :mask_length].masked_fill(
1208
+ padding_mask, min_dtype
1209
+ )
1210
+
1211
+ return causal_mask
1212
+
1213
+
1214
+ class KwargsForCausalLM(FlashAttentionKwargs, LossKwargs): ...
1215
+
1216
+
1217
+ class DeepseekForCausalLM(DeepseekPreTrainedModel, GenerationMixin):
1218
+ _tied_weights_keys = ["lm_head.weight"]
1219
+
1220
+ def __init__(self, config):
1221
+ super().__init__(config)
1222
+ self.model = DeepseekModel(config)
1223
+ self.vocab_size = config.vocab_size
1224
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
1225
+
1226
+ # Initialize weights and apply final processing
1227
+ self.post_init()
1228
+
1229
+ def get_input_embeddings(self):
1230
+ return self.model.embed_tokens
1231
+
1232
+ def set_input_embeddings(self, value):
1233
+ self.model.embed_tokens = value
1234
+
1235
+ def get_output_embeddings(self):
1236
+ return self.lm_head
1237
+
1238
+ def set_output_embeddings(self, new_embeddings):
1239
+ self.lm_head = new_embeddings
1240
+
1241
+ def set_decoder(self, decoder):
1242
+ self.model = decoder
1243
+
1244
+ def get_decoder(self):
1245
+ return self.model
1246
+
1247
+ @add_start_docstrings_to_model_forward(Deepseek_INPUTS_DOCSTRING)
1248
+ @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
1249
+ def forward(
1250
+ self,
1251
+ input_ids: torch.LongTensor = None,
1252
+ attention_mask: Optional[torch.Tensor] = None,
1253
+ position_ids: Optional[torch.LongTensor] = None,
1254
+ past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
1255
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1256
+ labels: Optional[torch.LongTensor] = None,
1257
+ use_cache: Optional[bool] = None,
1258
+ output_attentions: Optional[bool] = None,
1259
+ output_hidden_states: Optional[bool] = None,
1260
+ return_dict: Optional[bool] = None,
1261
+ cache_position: Optional[torch.LongTensor] = None,
1262
+ num_logits_to_keep: int = 0,
1263
+ **kwargs: Unpack[KwargsForCausalLM],
1264
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
1265
+ r"""
1266
+ Args:
1267
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
1268
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
1269
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
1270
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
1271
+
1272
+ num_logits_to_keep (`int`, *optional*):
1273
+ Calculate logits for the last `num_logits_to_keep` tokens. If `0`, calculate logits for all
1274
+ `input_ids` (special case). Only last token logits are needed for generation, and calculating them only for that
1275
+ token can save memory, which becomes pretty significant for long sequences or large vocabulary size.
1276
+
1277
+ Returns:
1278
+
1279
+ Example:
1280
+
1281
+ ```python
1282
+ >>> from transformers import AutoTokenizer
1283
+
1284
+ >>> model = DeepseekForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)
1285
+ >>> tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)
1286
+
1287
+ >>> prompt = "Hey, are you conscious? Can you talk to me?"
1288
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
1289
+
1290
+ >>> # Generate
1291
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
1292
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
1293
+ "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
1294
+ ```"""
1295
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1296
+ output_hidden_states = (
1297
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1298
+ )
1299
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1300
+
1301
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
1302
+ outputs = self.model(
1303
+ input_ids=input_ids,
1304
+ attention_mask=attention_mask,
1305
+ position_ids=position_ids,
1306
+ past_key_values=past_key_values,
1307
+ inputs_embeds=inputs_embeds,
1308
+ use_cache=use_cache,
1309
+ output_attentions=output_attentions,
1310
+ output_hidden_states=output_hidden_states,
1311
+ return_dict=return_dict,
1312
+ )
1313
+
1314
+ hidden_states = outputs[0]
1315
+ # Only compute necessary logits, and do not upcast them to float if we are not computing the loss
1316
+ logits = self.lm_head(hidden_states[:, -num_logits_to_keep:, :])
1317
+
1318
+ loss = None
1319
+ if labels is not None:
1320
+ loss = self.loss_function(logits=logits, labels=labels, vocab_size=self.config.vocab_size, **kwargs)
1321
+
1322
+ if not return_dict:
1323
+ output = (logits,) + outputs[1:]
1324
+ return (loss,) + output if loss is not None else output
1325
+
1326
+ return CausalLMOutputWithPast(
1327
+ loss=loss,
1328
+ logits=logits,
1329
+ past_key_values=outputs.past_key_values,
1330
+ hidden_states=outputs.hidden_states,
1331
+ attentions=outputs.attentions,
1332
+ )
1333
+
1334
+
1335
+ @add_start_docstrings(
1336
+ """
1337
+ The Deepseek Model transformer with a sequence classification head on top (linear layer).
1338
+
1339
+ [`DeepseekForSequenceClassification`] uses the last token in order to do the classification, as other causal models
1340
+ (e.g. GPT-2) do.
1341
+
1342
+ Since it does classification on the last token, it requires to know the position of the last token. If a
1343
+ `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
1344
+ no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
1345
+ padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
1346
+ each row of the batch).
1347
+ """,
1348
+ Deepseek_START_DOCSTRING,
1349
+ )
1350
+ class DeepseekForSequenceClassification(DeepseekPreTrainedModel):
1351
+ def __init__(self, config):
1352
+ super().__init__(config)
1353
+ self.num_labels = config.num_labels
1354
+ self.model = DeepseekModel(config)
1355
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
1356
+
1357
+ # Initialize weights and apply final processing
1358
+ self.post_init()
1359
+
1360
+ def get_input_embeddings(self):
1361
+ return self.model.embed_tokens
1362
+
1363
+ def set_input_embeddings(self, value):
1364
+ self.model.embed_tokens = value
1365
+
1366
+ @add_start_docstrings_to_model_forward(Deepseek_INPUTS_DOCSTRING)
1367
+ def forward(
1368
+ self,
1369
+ input_ids: Optional[torch.LongTensor] = None,
1370
+ attention_mask: Optional[torch.Tensor] = None,
1371
+ position_ids: Optional[torch.LongTensor] = None,
1372
+ past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
1373
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1374
+ labels: Optional[torch.LongTensor] = None,
1375
+ use_cache: Optional[bool] = None,
1376
+ output_attentions: Optional[bool] = None,
1377
+ output_hidden_states: Optional[bool] = None,
1378
+ return_dict: Optional[bool] = None,
1379
+ ) -> Union[Tuple, SequenceClassifierOutputWithPast]:
1380
+ r"""
1381
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1382
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1383
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1384
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1385
+ """
1386
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1387
+
1388
+ transformer_outputs = self.model(
1389
+ input_ids,
1390
+ attention_mask=attention_mask,
1391
+ position_ids=position_ids,
1392
+ past_key_values=past_key_values,
1393
+ inputs_embeds=inputs_embeds,
1394
+ use_cache=use_cache,
1395
+ output_attentions=output_attentions,
1396
+ output_hidden_states=output_hidden_states,
1397
+ return_dict=return_dict,
1398
+ )
1399
+ hidden_states = transformer_outputs[0]
1400
+ logits = self.score(hidden_states)
1401
+
1402
+ if input_ids is not None:
1403
+ batch_size = input_ids.shape[0]
1404
+ else:
1405
+ batch_size = inputs_embeds.shape[0]
1406
+
1407
+ if self.config.pad_token_id is None and batch_size != 1:
1408
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
1409
+ if self.config.pad_token_id is None:
1410
+ sequence_lengths = -1
1411
+ else:
1412
+ if input_ids is not None:
1413
+ # if no pad token found, use modulo instead of reverse indexing for ONNX compatibility
1414
+ sequence_lengths = torch.eq(input_ids, self.config.pad_token_id).int().argmax(-1) - 1
1415
+ sequence_lengths = sequence_lengths % input_ids.shape[-1]
1416
+ sequence_lengths = sequence_lengths.to(logits.device)
1417
+ else:
1418
+ sequence_lengths = -1
1419
+
1420
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
1421
+
1422
+ loss = None
1423
+ if labels is not None:
1424
+ loss = self.loss_function(logits=logits, labels=labels, pooled_logits=pooled_logits, config=self.config)
1425
+
1426
+ if not return_dict:
1427
+ output = (pooled_logits,) + transformer_outputs[1:]
1428
+ return ((loss,) + output) if loss is not None else output
1429
+
1430
+ return SequenceClassifierOutputWithPast(
1431
+ loss=loss,
1432
+ logits=pooled_logits,
1433
+ past_key_values=transformer_outputs.past_key_values,
1434
+ hidden_states=transformer_outputs.hidden_states,
1435
+ attentions=transformer_outputs.attentions,
1436
+ )
special_tokens_map.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|role_sep|>",
4
+ "<|message_sep|>",
5
+ "[",
6
+ "]",
7
+ "<|role_sep|>",
8
+ "<|message_sep|>",
9
+ "[",
10
+ "]"
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": "<|message_sep|>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false
25
+ }
26
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6fc8146adda45ec7f4876d832f80b55e8dd3e1fa648fbd54d059a601ee73cea3
3
+ size 10678892
tokenizer_config.json ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens": {
3
+ "1": {
4
+ "content": "<s>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "128000": {
12
+ "content": "<|role_sep|>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "128001": {
20
+ "content": "<|message_sep|>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "61": {
28
+ "content": "[",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "63": {
36
+ "content": "]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "added_tokens_decoder": {
45
+ "1": {
46
+ "content": "<s>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "61": {
54
+ "content": "[",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "63": {
62
+ "content": "]",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "128000": {
70
+ "content": "<|role_sep|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "128001": {
78
+ "content": "<|message_sep|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ }
85
+ },
86
+ "additional_special_tokens": [
87
+ "<|role_sep|>",
88
+ "<|message_sep|>",
89
+ "[",
90
+ "]",
91
+ "<|role_sep|>",
92
+ "<|message_sep|>",
93
+ "[",
94
+ "]"
95
+ ],
96
+ "bos_token": "<s>",
97
+ "clean_up_tokenization_spaces": true,
98
+ "eos_token": "<|message_sep|>",
99
+ "extra_special_tokens": {},
100
+ "model_max_length": 1000000000000000019884624838656,
101
+ "tokenizer_class": "PreTrainedTokenizer",
102
+ "unk_token": null
103
+ }