vltnmmdv commited on
Commit
41adb6c
·
verified ·
1 Parent(s): 8b26ca3

Add files using upload-large-folder tool

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
config.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DeepseekForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "ai-sage/GigaChat-20B-A3B-base--configuration_deepseek.DeepseekConfig",
9
+ "AutoModel": "ai-sage/GigaChat-20B-A3B-base--modelling_deepseek.DeepseekModel",
10
+ "AutoModelForCausalLM": "ai-sage/GigaChat-20B-A3B-base--modelling_deepseek.DeepseekForCausalLM"
11
+ },
12
+ "aux_loss_alpha": 0.001,
13
+ "bos_token_id": 1,
14
+ "eos_token_id": 128001,
15
+ "first_k_dense_replace": 1,
16
+ "hidden_act": "silu",
17
+ "hidden_size": 2048,
18
+ "initializer_range": 0.006,
19
+ "intermediate_size": 14336,
20
+ "max_position_embeddings": 131072,
21
+ "moe_implementation": "eager",
22
+ "moe_intermediate_size": 1792,
23
+ "moe_layer_freq": 1,
24
+ "n_routed_experts": 64,
25
+ "n_shared_experts": 2,
26
+ "norm_topk_prob": false,
27
+ "num_attention_heads": 16,
28
+ "num_experts_per_tok": 6,
29
+ "num_hidden_layers": 28,
30
+ "num_key_value_heads": 8,
31
+ "pad_token_id": 1,
32
+ "pretraining_tp": 1,
33
+ "quantization_config": {
34
+ "_load_in_4bit": false,
35
+ "_load_in_8bit": true,
36
+ "bnb_4bit_compute_dtype": "float32",
37
+ "bnb_4bit_quant_storage": "uint8",
38
+ "bnb_4bit_quant_type": "fp4",
39
+ "bnb_4bit_use_double_quant": false,
40
+ "llm_int8_enable_fp32_cpu_offload": false,
41
+ "llm_int8_has_fp16_weight": false,
42
+ "llm_int8_skip_modules": null,
43
+ "llm_int8_threshold": 6.0,
44
+ "load_in_4bit": false,
45
+ "load_in_8bit": true,
46
+ "quant_method": "bitsandbytes"
47
+ },
48
+ "return_dict": false,
49
+ "rms_norm_eps": 1e-05,
50
+ "rope_scaling": null,
51
+ "rope_theta": 1400000,
52
+ "scoring_func": "softmax",
53
+ "seq_aux": true,
54
+ "tie_word_embeddings": false,
55
+ "torch_dtype": "float16",
56
+ "transformers_version": "4.48.0",
57
+ "use_cache": true,
58
+ "vocab_size": 128256
59
+ }
configuration_deepseek_fixed.py ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional
2
+
3
+ from transformers.configuration_utils import PretrainedConfig
4
+ from transformers.utils import logging
5
+
6
+ logger = logging.get_logger(__name__)
7
+
8
+ DEEPSEEK_FIXES_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
9
+ class DeepseekFixedConfig(PretrainedConfig):
10
+ r"""
11
+ This is the configuration class to store the configuration of a DeepseekWithConcentrationekModel`]. It is used to instantiate an DeepSeek
12
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
13
+ defaults will yield a similar configuration to that of the DeepseekWithConcentration-7B.
14
+
15
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
16
+ documentation from [`PretrainedConfig`] for more information.
17
+
18
+
19
+ Args:
20
+ vocab_size (`int`, *optional*, defaults to 102400):
21
+ Vocabulary size of the Deep model. Defines the number of different tokens that can be represented by the
22
+ `inputs_ids` passed when calling [`DeepseekWithConcentrationModel`]
23
+ hidden_size (`int`, *optional*, defaults to 4096):
24
+ Dimension of the hidden representations.
25
+ intermediate_size (`int`, *optional*, defaults to 11008):
26
+ Dimension of the MLP representations.
27
+ moe_intermediate_size (`int`, *optional*, defaults to 1407):
28
+ Dimension of the MoE representations.
29
+ num_hidden_layers (`int`, *optional*, defaults to 32):
30
+ Number of hidden layers in the Transformer decoder.
31
+ num_attention_heads (`int`, *optional*, defaults to 32):
32
+ Number of attention heads for each attention layer in the Transformer decoder.
33
+ n_shared_experts (`int`, *optional*, defaults to None):
34
+ Number of shared experts, None means dense model.
35
+ n_routed_experts (`int`, *optional*, defaults to None):
36
+ Number of routed experts, None means dense model.
37
+ num_experts_per_tok (`int`, *optional*, defaults to None):
38
+ Number of selected experts, None means dense model.
39
+ moe_layer_freq (`int`, *optional*, defaults to 1):
40
+ The frequency of the MoE layer: one expert layer for every `moe_layer_freq - 1` dense layers.
41
+ first_k_dense_replace (`int`, *optional*, defaults to 0):
42
+ Number of dense layers in shallow layers(embed->dense->dense->...->dense->moe->moe...->lm_head).
43
+ \--k dense layers--/
44
+ norm_topk_prob (`bool`, *optional*, defaults to False):
45
+ Whether to normalize the weights of the routed experts.
46
+ scoring_func (`str`, *optional*, defaults to 'softmax'):
47
+ Method of computing expert weights.
48
+ aux_loss_alpha (`float`, *optional*, defaults to 0.001):
49
+ Auxiliary loss weight coefficient.
50
+ seq_aux = (`bool`, *optional*, defaults to True):
51
+ Whether to compute the auxiliary loss for each individual sample.
52
+ num_key_value_heads (`int`, *optional*):
53
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
54
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
55
+ `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
56
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
57
+ by meanpooling all the original heads within that group. For more details checkout [this
58
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
59
+ `num_attention_heads`.
60
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
61
+ The non-linear activation function (function or string) in the decoder.
62
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
63
+ The maximum sequence length that this model might ever be used with.
64
+ initializer_range (`float`, *optional*, defaults to 0.02):
65
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
66
+ rms_norm_eps (`float`, *optional*, defaults to 1e-06):
67
+ The epsilon used by the rms normalization layers.
68
+ use_cache (`bool`, *optional*, defaults to `True`):
69
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
70
+ relevant if `config.is_decoder=True`.
71
+ pad_token_id (`int`, *optional*):
72
+ Padding token id.
73
+ bos_token_id (`int`, *optional*, defaults to 1):
74
+ Beginning of stream token id.
75
+ eos_token_id (`int`, *optional*, defaults to 2):
76
+ End of stream token id.
77
+ pretraining_tp (`int`, *optional*, defaults to 1):
78
+ Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
79
+ document](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value is
80
+ necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
81
+ issue](https://github.com/pytorch/pytorch/issues/76232).
82
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
83
+ Whether to tie weight embeddings
84
+ rope_theta (`float`, *optional*, defaults to 10000.0):
85
+ The base period of the RoPE embeddings.
86
+ rope_scaling (`Dict`, *optional*):
87
+ Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
88
+ strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
89
+ `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
90
+ `max_position_embeddings` to the expected new maximum.
91
+ attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
92
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
93
+ attention_dropout (`float`, *optional*, defaults to 0.0):
94
+ The dropout ratio for the attention probabilities.
95
+
96
+ ```python
97
+ >>> from transformers import DeepseekWithConcentrationModel, DeepseekWithConcentrationConfig
98
+
99
+ >>> # Initializing a DeepseekWithConcentration DeepseekWithConcentration-7b style configuration
100
+ >>> configuration = DeepseekWithConcentrationConfig()
101
+
102
+ >>> # Accessing the model configuration
103
+ >>> configuration = model.config
104
+ ```"""
105
+
106
+ model_type = "deepseek_with_concentration"
107
+ keys_to_ignore_at_inference = ["past_key_values"]
108
+
109
+ def __init__(
110
+ self,
111
+ vocab_size=102400,
112
+ hidden_size=4096,
113
+ intermediate_size=11008,
114
+ moe_intermediate_size = 1407,
115
+ num_hidden_layers=30,
116
+ num_attention_heads=32,
117
+ num_key_value_heads=32,
118
+ n_shared_experts = None,
119
+ n_routed_experts = None,
120
+ num_experts_per_tok = None,
121
+ moe_layer_freq = 1,
122
+ first_k_dense_replace = 0,
123
+ norm_topk_prob = False,
124
+ scoring_func = 'softmax',
125
+ aux_loss_alpha = 0.001,
126
+ seq_aux = True,
127
+ hidden_act="silu",
128
+ max_position_embeddings=2048,
129
+ initializer_range=0.02,
130
+ rms_norm_eps=1e-6,
131
+ use_cache=True,
132
+ pad_token_id=None,
133
+ bos_token_id=100000,
134
+ eos_token_id=100001,
135
+ pretraining_tp=1,
136
+ tie_word_embeddings=False,
137
+ rope_theta=10000.0,
138
+ rope_scaling=None,
139
+ attention_bias=False,
140
+ attention_dropout=0.0,
141
+ moe_implementation="eager",
142
+ **kwargs,
143
+ ):
144
+ assert moe_implementation in ('eager', 'megablocks'), "Invalid moe_implementation value. Choose from 'eager' or 'megablocks'."
145
+ self.vocab_size = vocab_size
146
+ self.max_position_embeddings = max_position_embeddings
147
+ self.hidden_size = hidden_size
148
+ self.intermediate_size = intermediate_size
149
+ self.moe_intermediate_size = moe_intermediate_size
150
+ self.num_hidden_layers = num_hidden_layers
151
+ self.num_attention_heads = num_attention_heads
152
+ self.n_shared_experts = n_shared_experts
153
+ self.n_routed_experts = n_routed_experts
154
+ self.num_experts_per_tok = num_experts_per_tok
155
+ self.moe_layer_freq = moe_layer_freq
156
+ self.first_k_dense_replace = first_k_dense_replace
157
+ self.norm_topk_prob = norm_topk_prob
158
+ self.scoring_func = scoring_func
159
+ self.aux_loss_alpha = aux_loss_alpha
160
+ self.seq_aux = seq_aux
161
+
162
+ # for backward compatibility
163
+ if num_key_value_heads is None:
164
+ num_key_value_heads = num_attention_heads
165
+
166
+ self.num_key_value_heads = num_key_value_heads
167
+ self.hidden_act = hidden_act
168
+ self.initializer_range = initializer_range
169
+ self.rms_norm_eps = rms_norm_eps
170
+ self.pretraining_tp = pretraining_tp
171
+ self.use_cache = use_cache
172
+ self.rope_theta = rope_theta
173
+ self.rope_scaling = rope_scaling
174
+ self._rope_scaling_validation()
175
+ self.attention_bias = attention_bias
176
+ self.attention_dropout = attention_dropout
177
+ self.moe_implementation = moe_implementation
178
+
179
+ super().__init__(
180
+ pad_token_id=pad_token_id,
181
+ bos_token_id=bos_token_id,
182
+ eos_token_id=eos_token_id,
183
+ tie_word_embeddings=tie_word_embeddings,
184
+ **kwargs,
185
+ )
186
+
187
+ def _rope_scaling_validation(self):
188
+ """
189
+ Validate the `rope_scaling` configuration.
190
+ """
191
+ if self.rope_scaling is None:
192
+ return
193
+
194
+ if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 2:
195
+ raise ValueError(
196
+ "`rope_scaling` must be a dictionary with with two fields, `type` and `factor`, "
197
+ f"got {self.rope_scaling}"
198
+ )
199
+ rope_scaling_type = self.rope_scaling.get("type", None)
200
+ rope_scaling_factor = self.rope_scaling.get("factor", None)
201
+ if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
202
+ raise ValueError(
203
+ f"`rope_scaling`'s type field must be one of ['linear', 'dynamic'], got {rope_scaling_type}"
204
+ )
205
+ if rope_scaling_factor is None or not isinstance(rope_scaling_factor, float) or rope_scaling_factor <= 1.0:
206
+ raise ValueError(f"`rope_scaling`'s factor field must be a float > 1, got {rope_scaling_factor}")
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "pad_token_id": 2,
6
+ "transformers_version": "4.48.0"
7
+ }
model-00001-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:089011a67df73f9ec123bf2cf6e7b7fe56e0284ad7796e8aae267c902cffdda3
3
+ size 4998878848
model-00002-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:49f3811ea9beb1f1769fbbe457c94ed6eb04b3498dc1c57d485c3b945c7b3a67
3
+ size 5000060126
model-00003-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d04e9cb80700a357c9075789ff7a9847423071396d521de8538986b3d52a584a
3
+ size 5000061998
model-00004-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5080e89a6d9cd303ab99a5604fef9eb981f9bf7f0534a05cde7d3c6b8f2d00d3
3
+ size 5000062006
model-00005-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f9ce0805bc70e87ead49eb11c7842408e2cd543a9f348299ae49cfc7ed580232
3
+ size 1161875578
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
special_tokens_map.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|role_sep|>",
4
+ "<|message_sep|>",
5
+ "[",
6
+ "]",
7
+ "<|role_sep|>",
8
+ "<|message_sep|>",
9
+ "[",
10
+ "]"
11
+ ],
12
+ "bos_token": {
13
+ "content": "<s>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false
18
+ },
19
+ "eos_token": {
20
+ "content": "<|message_sep|>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false
25
+ }
26
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6fc8146adda45ec7f4876d832f80b55e8dd3e1fa648fbd54d059a601ee73cea3
3
+ size 10678892
tokenizer_config.json ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_eos_token": false,
3
+ "added_tokens": {
4
+ "1": {
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "128000": {
13
+ "content": "<|role_sep|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "128001": {
21
+ "content": "<|message_sep|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "61": {
29
+ "content": "[",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "63": {
37
+ "content": "]",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "added_tokens_decoder": {
46
+ "1": {
47
+ "content": "<s>",
48
+ "lstrip": false,
49
+ "normalized": false,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": true
53
+ },
54
+ "61": {
55
+ "content": "[",
56
+ "lstrip": false,
57
+ "normalized": false,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": true
61
+ },
62
+ "63": {
63
+ "content": "]",
64
+ "lstrip": false,
65
+ "normalized": false,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": true
69
+ },
70
+ "128000": {
71
+ "content": "<|role_sep|>",
72
+ "lstrip": false,
73
+ "normalized": false,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": true
77
+ },
78
+ "128001": {
79
+ "content": "<|message_sep|>",
80
+ "lstrip": false,
81
+ "normalized": false,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": true
85
+ }
86
+ },
87
+ "additional_special_tokens": [
88
+ "<|role_sep|>",
89
+ "<|message_sep|>",
90
+ "[",
91
+ "]",
92
+ "<|role_sep|>",
93
+ "<|message_sep|>",
94
+ "[",
95
+ "]"
96
+ ],
97
+ "bos_token": "<s>",
98
+ "chat_template": "{% if messages[0]['role'] == 'system' -%}\n {%- set loop_messages = messages[1:] -%}\n {%- set system_message = bos_token + messages[0]['content'] + additional_special_tokens[1] -%}\n{%- else -%}\n {%- set loop_messages = messages -%}\n {%- set system_message = bos_token + '' -%}\n{%- endif -%}\n{%- for message in loop_messages %}\n {% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}\n {{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}\n {% endif %}\n \n {%- if loop.index0 == 0 -%}\n {{ system_message -}}\n {%- endif -%}\n {%- if message['role'] == 'user' -%}\n {{ message['role'] + additional_special_tokens[0] + message['content'] + additional_special_tokens[1] -}}\n {{ 'available functions' + additional_special_tokens[0] + additional_special_tokens[2] + additional_special_tokens[3] + additional_special_tokens[1] -}}\n {%- endif -%}\n {%- if message['role'] == 'assistant' -%}\n {{ message['role'] + additional_special_tokens[0] + message['content'] + additional_special_tokens[1] -}}\n {%- endif -%}\n {%- if loop.last and add_generation_prompt -%}\n {{ 'assistant' + additional_special_tokens[0] -}}\n {%- endif -%}\n{%- endfor %}",
99
+ "clean_up_tokenization_spaces": true,
100
+ "eos_token": "<|message_sep|>",
101
+ "extra_special_tokens": {},
102
+ "legacy": true,
103
+ "model_max_length": 1000000000000000019884624838656,
104
+ "tokenizer_class": "PreTrainedTokenizerFast",
105
+ "unk_token": null
106
+ }