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