haoyang-amd commited on
Commit
5b00a04
·
verified ·
1 Parent(s): d2658dc

new model

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. chat_template.jinja +101 -0
  2. config.json +190 -0
  3. configuration_deepseek.py +199 -0
  4. generation_config.json +9 -0
  5. model-00001-of-00076.safetensors +3 -0
  6. model-00002-of-00076.safetensors +3 -0
  7. model-00003-of-00076.safetensors +3 -0
  8. model-00004-of-00076.safetensors +3 -0
  9. model-00005-of-00076.safetensors +3 -0
  10. model-00006-of-00076.safetensors +3 -0
  11. model-00007-of-00076.safetensors +3 -0
  12. model-00008-of-00076.safetensors +3 -0
  13. model-00009-of-00076.safetensors +3 -0
  14. model-00010-of-00076.safetensors +3 -0
  15. model-00011-of-00076.safetensors +3 -0
  16. model-00012-of-00076.safetensors +3 -0
  17. model-00013-of-00076.safetensors +3 -0
  18. model-00014-of-00076.safetensors +3 -0
  19. model-00015-of-00076.safetensors +3 -0
  20. model-00016-of-00076.safetensors +3 -0
  21. model-00017-of-00076.safetensors +3 -0
  22. model-00018-of-00076.safetensors +3 -0
  23. model-00019-of-00076.safetensors +3 -0
  24. model-00020-of-00076.safetensors +3 -0
  25. model-00021-of-00076.safetensors +3 -0
  26. model-00022-of-00076.safetensors +3 -0
  27. model-00023-of-00076.safetensors +3 -0
  28. model-00024-of-00076.safetensors +3 -0
  29. model-00025-of-00076.safetensors +3 -0
  30. model-00026-of-00076.safetensors +3 -0
  31. model-00027-of-00076.safetensors +3 -0
  32. model-00028-of-00076.safetensors +3 -0
  33. model-00029-of-00076.safetensors +3 -0
  34. model-00030-of-00076.safetensors +3 -0
  35. model-00031-of-00076.safetensors +3 -0
  36. model-00032-of-00076.safetensors +3 -0
  37. model-00033-of-00076.safetensors +3 -0
  38. model-00034-of-00076.safetensors +3 -0
  39. model-00035-of-00076.safetensors +3 -0
  40. model-00036-of-00076.safetensors +3 -0
  41. model-00037-of-00076.safetensors +3 -0
  42. model-00038-of-00076.safetensors +3 -0
  43. model-00039-of-00076.safetensors +3 -0
  44. model-00040-of-00076.safetensors +3 -0
  45. model-00041-of-00076.safetensors +3 -0
  46. model-00042-of-00076.safetensors +3 -0
  47. model-00043-of-00076.safetensors +3 -0
  48. model-00044-of-00076.safetensors +3 -0
  49. model-00045-of-00076.safetensors +3 -0
  50. model-00046-of-00076.safetensors +3 -0
chat_template.jinja ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if not add_generation_prompt is defined %}
2
+ {%- set add_generation_prompt = false %}
3
+ {%- endif %}
4
+ {%- set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='', is_first_sp=true, is_last_user=false) %}
5
+ {%- for message in messages %}
6
+ {%- if message['role'] == 'system' %}
7
+ {%- if ns.is_first_sp %}
8
+ {%- set ns.system_prompt = ns.system_prompt + message['content'] %}
9
+ {%- set ns.is_first_sp = false %}
10
+ {%- else %}
11
+ {%- set ns.system_prompt = ns.system_prompt + '\n\n' + message['content'] %}
12
+ {%- endif %}
13
+ {%- endif %}
14
+ {%- endfor %}
15
+
16
+ {#- Adapted from https://github.com/sgl-project/sglang/blob/main/examples/chat_template/tool_chat_template_deepseekr1.jinja #}
17
+ {%- if tools is defined and tools is not none %}
18
+ {%- set tool_ns = namespace(text='You are a helpful assistant with tool calling capabilities. ' + 'When a tool call is needed, you MUST use the following format to issue the call:\n' + '<|tool▁calls▁begin|><|tool▁call▁begin|>function<|tool▁sep|>FUNCTION_NAME\n' + '```json\n{"param1": "value1", "param2": "value2"}\n```<|tool▁call▁end|><|tool▁calls▁end|>\n\n' + 'Make sure the JSON is valid.' + '## Tools\n\n### Function\n\nYou have the following functions available:\n\n') %}
19
+ {%- for tool in tools %}
20
+ {%- set tool_ns.text = tool_ns.text + '\n```json\n' + (tool | tojson) + '\n```\n' %}
21
+ {%- endfor %}
22
+ {%- if ns.system_prompt|length != 0 %}
23
+ {%- set ns.system_prompt = ns.system_prompt + '\n\n' + tool_ns.text %}
24
+ {%- else %}
25
+ {%- set ns.system_prompt = tool_ns.text %}
26
+ {%- endif %}
27
+ {%- endif %}
28
+ {{- bos_token }}
29
+ {{- ns.system_prompt }}
30
+ {%- set last_index = (messages|length - 1) %}
31
+ {%- for message in messages %}
32
+ {%- set content = message['content'] %}
33
+ {%- if message['role'] == 'user' %}
34
+ {%- set ns.is_tool = false -%}
35
+ {%- set ns.is_first = false -%}
36
+ {%- set ns.is_last_user = true -%}
37
+ {%- if loop.index0 == last_index %}
38
+ {{- '<|User|>' + content }}
39
+ {%- else %}
40
+ {{- '<|User|>' + content + '<|Assistant|>'}}
41
+ {%- endif %}
42
+ {%- endif %}
43
+ {%- if message['role'] == 'assistant' %}
44
+ {%- if '</think>' in content %}
45
+ {%- set content = (content.split('</think>')|last) %}
46
+ {%- endif %}
47
+ {%- endif %}
48
+ {%- if message['role'] == 'assistant' and message['tool_calls'] is defined and message['tool_calls'] is not none %}
49
+ {%- set ns.is_last_user = false -%}
50
+ {%- if ns.is_tool %}
51
+ {{- '<|tool▁outputs▁end|>'}}
52
+ {%- endif %}
53
+ {%- set ns.is_first = false %}
54
+ {%- set ns.is_tool = false -%}
55
+ {%- set ns.is_output_first = true %}
56
+ {%- for tool in message['tool_calls'] %}
57
+ {%- set arguments = tool['function']['arguments'] %}
58
+ {%- if arguments is not string %}
59
+ {%- set arguments = arguments|tojson %}
60
+ {%- endif %}
61
+ {%- if not ns.is_first %}
62
+ {%- if content is none %}
63
+ {{- '<|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + arguments + '\n' + '```' + '<|tool▁call▁end|>'}}
64
+ }
65
+ {%- else %}
66
+ {{- content + '<|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + arguments + '\n' + '```' + '<|tool▁call▁end|>'}}
67
+ {%- endif %}
68
+ {%- set ns.is_first = true -%}
69
+ {%- else %}
70
+ {{- '\n' + '<|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + arguments + '\n' + '```' + '<|tool▁call▁end|>'}}
71
+ {%- endif %}
72
+ {%- endfor %}
73
+ {{- '<|tool▁calls▁end|><|end▁of▁sentence|>'}}
74
+ {%- endif %}
75
+ {%- if message['role'] == 'assistant' and (message['tool_calls'] is not defined or message['tool_calls'] is none) %}
76
+ {%- set ns.is_last_user = false -%}
77
+ {%- if ns.is_tool %}
78
+ {{- '<|tool▁outputs▁end|>' + content + '<|end▁of▁sentence|>'}}
79
+ {%- set ns.is_tool = false -%}
80
+ {%- else %}
81
+ {{- content + '<|end▁of▁sentence|>'}}
82
+ {%- endif %}
83
+ {%- endif %}
84
+ {%- if message['role'] == 'tool' %}
85
+ {%- set ns.is_last_user = false -%}
86
+ {%- set ns.is_tool = true -%}
87
+ {%- if ns.is_output_first %}
88
+ {{- '<|tool▁outputs▁begin|><|tool▁output▁begin|>' + content + '<|tool▁output▁end|>'}}
89
+ {%- set ns.is_output_first = false %}
90
+ {%- else %}
91
+ {{- '\n<|tool▁output▁begin|>' + content + '<|tool▁output▁end|>'}}
92
+ {%- endif %}
93
+ {%- endif %}
94
+ {%- endfor -%}
95
+ {%- if ns.is_tool %}
96
+ {{- '<|tool▁outputs▁end|>'}}
97
+ {%- endif %}
98
+ {#- if add_generation_prompt and not ns.is_last_user and not ns.is_tool #}
99
+ {%- if add_generation_prompt and not ns.is_tool %}
100
+ {{- '<|Assistant|>'}}
101
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DeepseekV3ForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_deepseek.DeepseekV3Config",
9
+ "AutoModel": "modeling_deepseek.DeepseekV3Model",
10
+ "AutoModelForCausalLM": "modeling_deepseek.DeepseekV3ForCausalLM"
11
+ },
12
+ "bos_token_id": 0,
13
+ "dtype": "bfloat16",
14
+ "eos_token_id": 1,
15
+ "ep_size": 1,
16
+ "first_k_dense_replace": 3,
17
+ "hidden_act": "silu",
18
+ "hidden_size": 7168,
19
+ "initializer_range": 0.02,
20
+ "intermediate_size": 18432,
21
+ "kv_lora_rank": 512,
22
+ "max_position_embeddings": 163840,
23
+ "model_type": "deepseek_v3",
24
+ "moe_intermediate_size": 2048,
25
+ "moe_layer_freq": 1,
26
+ "n_group": 8,
27
+ "n_routed_experts": 256,
28
+ "n_shared_experts": 1,
29
+ "norm_topk_prob": true,
30
+ "num_attention_heads": 128,
31
+ "num_experts_per_tok": 8,
32
+ "num_hidden_layers": 61,
33
+ "num_key_value_heads": 128,
34
+ "num_nextn_predict_layers": 1,
35
+ "pad_token_id": 2,
36
+ "q_lora_rank": 1536,
37
+ "qk_nope_head_dim": 128,
38
+ "qk_rope_head_dim": 64,
39
+ "quantization_config": {
40
+ "algo_config": null,
41
+ "exclude": [
42
+ "model.layers.61.embed_tokens",
43
+ "model.layers.61.eh_proj",
44
+ "model.layers.61.shared_head.head",
45
+ "lm_head"
46
+ ],
47
+ "export": {
48
+ "kv_cache_group": [],
49
+ "min_kv_scale": 0.0,
50
+ "pack_method": "reorder",
51
+ "weight_format": "real_quantized",
52
+ "weight_merge_groups": null
53
+ },
54
+ "global_quant_config": {
55
+ "bias": null,
56
+ "input_tensors": {
57
+ "ch_axis": -1,
58
+ "dtype": "fp4",
59
+ "group_size": 32,
60
+ "is_dynamic": true,
61
+ "is_scale_quant": false,
62
+ "mx_element_dtype": null,
63
+ "observer_cls": "PerBlockMXObserver",
64
+ "qscheme": "per_group",
65
+ "round_method": "half_even",
66
+ "scale_calculation_mode": "even",
67
+ "scale_format": "e8m0",
68
+ "scale_type": "float",
69
+ "symmetric": null
70
+ },
71
+ "output_tensors": null,
72
+ "target_device": null,
73
+ "weight": {
74
+ "ch_axis": -1,
75
+ "dtype": "fp4",
76
+ "group_size": 32,
77
+ "is_dynamic": false,
78
+ "is_scale_quant": false,
79
+ "mx_element_dtype": null,
80
+ "observer_cls": "PerBlockMXObserver",
81
+ "qscheme": "per_group",
82
+ "round_method": "half_even",
83
+ "scale_calculation_mode": "even",
84
+ "scale_format": "e8m0",
85
+ "scale_type": "float",
86
+ "symmetric": null
87
+ }
88
+ },
89
+ "kv_cache_post_rope": false,
90
+ "kv_cache_quant_config": {},
91
+ "layer_quant_config": {
92
+ "*self_attn*": {
93
+ "bias": null,
94
+ "input_tensors": {
95
+ "ch_axis": 1,
96
+ "dtype": "fp8_e4m3",
97
+ "group_size": null,
98
+ "is_dynamic": true,
99
+ "is_scale_quant": false,
100
+ "mx_element_dtype": null,
101
+ "observer_cls": "PerChannelMinMaxObserver",
102
+ "qscheme": "per_channel",
103
+ "round_method": "half_even",
104
+ "scale_calculation_mode": null,
105
+ "scale_format": null,
106
+ "scale_type": "float",
107
+ "symmetric": true
108
+ },
109
+ "output_tensors": null,
110
+ "target_device": null,
111
+ "weight": {
112
+ "ch_axis": 0,
113
+ "dtype": "fp8_e4m3",
114
+ "group_size": null,
115
+ "is_dynamic": false,
116
+ "is_scale_quant": false,
117
+ "mx_element_dtype": null,
118
+ "observer_cls": "PerChannelMinMaxObserver",
119
+ "qscheme": "per_channel",
120
+ "round_method": "half_even",
121
+ "scale_calculation_mode": null,
122
+ "scale_format": null,
123
+ "scale_type": "float",
124
+ "symmetric": true
125
+ }
126
+ },
127
+ "model.layers.61.*": {
128
+ "bias": null,
129
+ "input_tensors": {
130
+ "ch_axis": -1,
131
+ "dtype": "fp4",
132
+ "group_size": 32,
133
+ "is_dynamic": true,
134
+ "is_scale_quant": false,
135
+ "mx_element_dtype": null,
136
+ "observer_cls": "PerBlockMXObserver",
137
+ "qscheme": "per_group",
138
+ "round_method": "half_even",
139
+ "scale_calculation_mode": "even",
140
+ "scale_format": "e8m0",
141
+ "scale_type": "float",
142
+ "symmetric": null
143
+ },
144
+ "output_tensors": null,
145
+ "target_device": null,
146
+ "weight": {
147
+ "ch_axis": -1,
148
+ "dtype": "fp4",
149
+ "group_size": 32,
150
+ "is_dynamic": false,
151
+ "is_scale_quant": false,
152
+ "mx_element_dtype": null,
153
+ "observer_cls": "PerBlockMXObserver",
154
+ "qscheme": "per_group",
155
+ "round_method": "half_even",
156
+ "scale_calculation_mode": "even",
157
+ "scale_format": "e8m0",
158
+ "scale_type": "float",
159
+ "symmetric": null
160
+ }
161
+ }
162
+ },
163
+ "layer_type_quant_config": {},
164
+ "quant_method": "quark",
165
+ "quant_mode": "eager_mode",
166
+ "softmax_quant_spec": null,
167
+ "version": "0.11.1"
168
+ },
169
+ "rms_norm_eps": 1e-06,
170
+ "rope_scaling": {
171
+ "beta_fast": 32,
172
+ "beta_slow": 1,
173
+ "factor": 40,
174
+ "mscale": 1.0,
175
+ "mscale_all_dim": 1.0,
176
+ "original_max_position_embeddings": 4096,
177
+ "type": "yarn"
178
+ },
179
+ "rope_theta": 10000,
180
+ "routed_scaling_factor": 2.5,
181
+ "scoring_func": "sigmoid",
182
+ "tie_word_embeddings": false,
183
+ "topk_group": 4,
184
+ "topk_method": "noaux_tc",
185
+ "transformers_version": "4.57.6",
186
+ "unsloth_fixed": true,
187
+ "use_cache": true,
188
+ "v_head_dim": 128,
189
+ "vocab_size": 129280
190
+ }
configuration_deepseek.py ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers.configuration_utils import PretrainedConfig
2
+ from transformers.utils import logging
3
+
4
+ logger = logging.get_logger(__name__)
5
+
6
+ DEEPSEEK_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
7
+ class DeepseekV3Config(PretrainedConfig):
8
+ r"""
9
+ This is the configuration class to store the configuration of a [`DeepseekV3Model`]. It is used to instantiate an DeepSeek
10
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
11
+ defaults will yield a similar configuration to that of the DeepSeek-V3.
12
+
13
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
14
+ documentation from [`PretrainedConfig`] for more information.
15
+
16
+
17
+ Args:
18
+ vocab_size (`int`, *optional*, defaults to 129280):
19
+ Vocabulary size of the Deep model. Defines the number of different tokens that can be represented by the
20
+ `inputs_ids` passed when calling [`DeepseekV3Model`]
21
+ hidden_size (`int`, *optional*, defaults to 4096):
22
+ Dimension of the hidden representations.
23
+ intermediate_size (`int`, *optional*, defaults to 11008):
24
+ Dimension of the MLP representations.
25
+ moe_intermediate_size (`int`, *optional*, defaults to 1407):
26
+ Dimension of the MoE representations.
27
+ num_hidden_layers (`int`, *optional*, defaults to 32):
28
+ Number of hidden layers in the Transformer decoder.
29
+ num_nextn_predict_layers (`int`, *optional*, defaults to 1):
30
+ Number of nextn predict layers in the DeepSeekV3 Model.
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
+ routed_scaling_factor (`float`, *optional*, defaults to 1.0):
38
+ Scaling factor or routed experts.
39
+ topk_method (`str`, *optional*, defaults to `gready`):
40
+ Topk method used in routed gate.
41
+ n_group (`int`, *optional*, defaults to None):
42
+ Number of groups for routed experts.
43
+ topk_group (`int`, *optional*, defaults to None):
44
+ Number of selected groups for each token(for each token, ensuring the selected experts is only within `topk_group` groups).
45
+ num_experts_per_tok (`int`, *optional*, defaults to None):
46
+ Number of selected experts, None means dense model.
47
+ moe_layer_freq (`int`, *optional*, defaults to 1):
48
+ The frequency of the MoE layer: one expert layer for every `moe_layer_freq - 1` dense layers.
49
+ first_k_dense_replace (`int`, *optional*, defaults to 0):
50
+ Number of dense layers in shallow layers(embed->dense->dense->...->dense->moe->moe...->lm_head).
51
+ \--k dense layers--/
52
+ norm_topk_prob (`bool`, *optional*, defaults to False):
53
+ Whether to normalize the weights of the routed experts.
54
+ scoring_func (`str`, *optional*, defaults to 'softmax'):
55
+ Method of computing expert weights.
56
+ aux_loss_alpha (`float`, *optional*, defaults to 0.001):
57
+ Auxiliary loss weight coefficient.
58
+ seq_aux = (`bool`, *optional*, defaults to True):
59
+ Whether to compute the auxiliary loss for each individual sample.
60
+ num_key_value_heads (`int`, *optional*):
61
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
62
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
63
+ `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
64
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
65
+ by meanpooling all the original heads within that group. For more details checkout [this
66
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
67
+ `num_attention_heads`.
68
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
69
+ The non-linear activation function (function or string) in the decoder.
70
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
71
+ The maximum sequence length that this model might ever be used with.
72
+ initializer_range (`float`, *optional*, defaults to 0.02):
73
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
74
+ rms_norm_eps (`float`, *optional*, defaults to 1e-06):
75
+ The epsilon used by the rms normalization layers.
76
+ use_cache (`bool`, *optional*, defaults to `True`):
77
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
78
+ relevant if `config.is_decoder=True`.
79
+ pad_token_id (`int`, *optional*):
80
+ Padding token id.
81
+ bos_token_id (`int`, *optional*, defaults to 1):
82
+ Beginning of stream token id.
83
+ eos_token_id (`int`, *optional*, defaults to 2):
84
+ End of stream token id.
85
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
86
+ Whether to tie weight embeddings
87
+ rope_theta (`float`, *optional*, defaults to 10000.0):
88
+ The base period of the RoPE embeddings.
89
+ rope_scaling (`Dict`, *optional*):
90
+ Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
91
+ strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
92
+ `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
93
+ `max_position_embeddings` to the expected new maximum.
94
+ attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
95
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
96
+ attention_dropout (`float`, *optional*, defaults to 0.0):
97
+ The dropout ratio for the attention probabilities.
98
+
99
+ ```python
100
+ >>> from transformers import DeepseekV3Model, DeepseekV3Config
101
+
102
+ >>> # Initializing a Deepseek-V3 style configuration
103
+ >>> configuration = DeepseekV3Config()
104
+
105
+ >>> # Accessing the model configuration
106
+ >>> configuration = model.config
107
+ ```"""
108
+
109
+ model_type = "deepseek_v3"
110
+ keys_to_ignore_at_inference = ["past_key_values"]
111
+
112
+ def __init__(
113
+ self,
114
+ vocab_size=129280,
115
+ hidden_size=7168,
116
+ intermediate_size=18432,
117
+ moe_intermediate_size = 2048,
118
+ num_hidden_layers=61,
119
+ num_nextn_predict_layers=1,
120
+ num_attention_heads=128,
121
+ num_key_value_heads=128,
122
+ n_shared_experts = 1,
123
+ n_routed_experts = 256,
124
+ ep_size = 1,
125
+ routed_scaling_factor = 2.5,
126
+ kv_lora_rank = 512,
127
+ q_lora_rank = 1536,
128
+ qk_rope_head_dim = 64,
129
+ v_head_dim = 128,
130
+ qk_nope_head_dim = 128,
131
+ topk_method = 'noaux_tc',
132
+ n_group = 8,
133
+ topk_group = 4,
134
+ num_experts_per_tok = 8,
135
+ moe_layer_freq = 1,
136
+ first_k_dense_replace = 3,
137
+ norm_topk_prob = True,
138
+ scoring_func = 'sigmoid',
139
+ hidden_act="silu",
140
+ max_position_embeddings=4096,
141
+ initializer_range=0.02,
142
+ rms_norm_eps=1e-6,
143
+ use_cache=True,
144
+ pad_token_id=None,
145
+ bos_token_id=0,
146
+ eos_token_id=1,
147
+ tie_word_embeddings=False,
148
+ rope_theta=10000.0,
149
+ rope_scaling=None,
150
+ attention_bias=False,
151
+ attention_dropout=0.0,
152
+ **kwargs,
153
+ ):
154
+ self.vocab_size = vocab_size
155
+ self.max_position_embeddings = max_position_embeddings
156
+ self.hidden_size = hidden_size
157
+ self.intermediate_size = intermediate_size
158
+ self.moe_intermediate_size = moe_intermediate_size
159
+ self.num_hidden_layers = num_hidden_layers
160
+ self.num_nextn_predict_layers = num_nextn_predict_layers
161
+ self.num_attention_heads = num_attention_heads
162
+ self.n_shared_experts = n_shared_experts
163
+ self.n_routed_experts = n_routed_experts
164
+ self.ep_size = ep_size
165
+ self.routed_scaling_factor = routed_scaling_factor
166
+ self.kv_lora_rank = kv_lora_rank
167
+ self.q_lora_rank = q_lora_rank
168
+ self.qk_rope_head_dim = qk_rope_head_dim
169
+ self.v_head_dim = v_head_dim
170
+ self.qk_nope_head_dim = qk_nope_head_dim
171
+ self.topk_method = topk_method
172
+ self.n_group = n_group
173
+ self.topk_group = topk_group
174
+ self.num_experts_per_tok = num_experts_per_tok
175
+ self.moe_layer_freq = moe_layer_freq
176
+ self.first_k_dense_replace = first_k_dense_replace
177
+ self.norm_topk_prob = norm_topk_prob
178
+ self.scoring_func = scoring_func
179
+ # for backward compatibility
180
+ if num_key_value_heads is None:
181
+ num_key_value_heads = num_attention_heads
182
+
183
+ self.num_key_value_heads = num_key_value_heads
184
+ self.hidden_act = hidden_act
185
+ self.initializer_range = initializer_range
186
+ self.rms_norm_eps = rms_norm_eps
187
+ self.use_cache = use_cache
188
+ self.rope_theta = rope_theta
189
+ self.rope_scaling = rope_scaling
190
+ self.attention_bias = attention_bias
191
+ self.attention_dropout = attention_dropout
192
+
193
+ super().__init__(
194
+ pad_token_id=pad_token_id,
195
+ bos_token_id=bos_token_id,
196
+ eos_token_id=eos_token_id,
197
+ tie_word_embeddings=tie_word_embeddings,
198
+ **kwargs,
199
+ )
generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "do_sample": true,
5
+ "eos_token_id": 1,
6
+ "temperature": 0.6,
7
+ "top_p": 0.95,
8
+ "transformers_version": "4.57.6"
9
+ }
model-00001-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc9d00e11f82c9af55b9aafbc69c7d10cd62347fdac9b3c3731e06bec2783b56
3
+ size 4996706336
model-00002-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d00e6582e2a34f1cd723f2a353d4b4692cec4207505a4cd23028181de9c5ee2
3
+ size 4995148712
model-00003-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e928b85055c236d9a965ecca91457e736371e0e8490cd063019a7119c03da4d6
3
+ size 4999180664
model-00004-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:218e63e69a4251a0d92c55bcf59fff5d41a3c76f3650cf840f70ea5935b61c39
3
+ size 4995148408
model-00005-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:11a63e063c9cb18dc5c25058a34b38c6c0be1dee62659c99f70a6eb7e63994d7
3
+ size 4995148408
model-00006-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:816c007eff1d3d89631c7a5bd4beadfa8798175de1ca356f836508375ce279c9
3
+ size 4995148512
model-00007-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7328160f3b04c2c3aacdad732fc2d592dfa6f64a3538481e17fe2439a1a2a5c4
3
+ size 4995148712
model-00008-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d07fa36c26334c6b868d29c2de483e3f0765e88792fae2705ef1eca63906864
3
+ size 4999180704
model-00009-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f7f505e1e91a348dc2108e5424bd6031af79edda4a9b39814494d55d8b9fc4e
3
+ size 4995148408
model-00010-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9beb352a38b502785f70cead261072e98888e8db3ad6a0a5370c1d7512c027d2
3
+ size 4995149240
model-00011-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c0b969695d04d6748cf4433381c8b25f6508a2869a4e2695602a6dac55d4b149
3
+ size 4995149720
model-00012-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ac8cad884efb28032c5d29234bd02ac5d540004512334d367baa58dfb9e3fad5
3
+ size 4995149960
model-00013-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb90a0ddfd3dbca6e869b064328e5eed0800833fb17c5814ffa53255342d4f0e
3
+ size 4999182032
model-00014-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2bef1943634b6c3bf469f30b94e66de181d3d71acb9a1ae93b32280373ce4eba
3
+ size 4995149656
model-00015-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:33c93f28a46dbbbe2202a8b40328b14a6efd4fc580fcf30ea5fa8fac5edaf977
3
+ size 4995149656
model-00016-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e07ed315d2fb14b58b7fed2b3fdeb1f378cd3dfcdf4ead73d2413124b88b0fe8
3
+ size 4995149680
model-00017-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f7dc28429c32b7fc4d51d1ef9b1965161b9f49a6cf79cf0cbe0433c4419e14d7
3
+ size 4995149960
model-00018-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7296182d799b02fa3e0b934e95b80c70fedf065ecfbb7b0217149363af150d31
3
+ size 4982702128
model-00019-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c088fe230215e9af12e543cbf995d111bcbb4a512c22c2b18d2a94f7c2fc1b5a
3
+ size 4996031512
model-00020-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7bfc719da337507abb63f9e853ff4a3a40dc32cf69f902d630a43e2277337c5a
3
+ size 4995149656
model-00021-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:254fb0da68fe75dc020d560430cd77481f9e2185cf733dce040eb72c39acd3b2
3
+ size 4995149656
model-00022-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20a326b8394726596a02ef2b802dd76d74cb21f9db11f4f8be45e436fe7aa4c3
3
+ size 4995149952
model-00023-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b61d24c35e5c382bcaac0bf7a6bed4974ca2019670632992efa77dffed5b31a6
3
+ size 4893292936
model-00024-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6dd33df5112e203e25538db2b3e9bf4bccb5b43666940220eed09a1c7e53bf00
3
+ size 4999651368
model-00025-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a25995623d6e5b95f10dbeac5e83e20979b6d77beb94abbc5f6424ebcd9f38dc
3
+ size 4995149656
model-00026-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f15481f628b2cca43326730382b81d814729835507d96100e012ce7ea04721bb
3
+ size 4995149656
model-00027-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8bb682794cc86517d9d9aab3724524390d0066134395cd11b2e4b2c4777c9b86
3
+ size 4995149928
model-00028-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ce442ac12fc7f63496b478194d59df1807a700e338b059a1243bcae95760b5bf
3
+ size 4995150016
model-00029-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f22166c0b3afdc8a2db7f4f6b8ae3bedd7232ab8d4a17177be124dbbebc86c59
3
+ size 4999181768
model-00030-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2762b79056f5015d444a5a68f7fde5834a62f3448aba96e8e476faf8e0a256af
3
+ size 4995149656
model-00031-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c97e970066da2eb362af7efc4b0029a51e9aaaac36f8a5abe249690d77dd7e1
3
+ size 4995149656
model-00032-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ef15a42f8ac0de94eee7bf5e9fdd4b26c867e412ecb0cbdb482d03452614141
3
+ size 4995149888
model-00033-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7894349584003816b0e7cf54e14236155b8916e1864db9593f6c403384b89df0
3
+ size 4995149968
model-00034-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d9d16712836abc0279b596b717e5518bd0afc04c201921581c7b8f678712707f
3
+ size 4999181848
model-00035-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:26fd60795780100286b6274b79d069ab32d09eda1bb498daf43619250f2e39a7
3
+ size 4995149656
model-00036-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb20289f7a816596129a5b245d094b4b9abbb091451baab213e2a0cb7899e751
3
+ size 4995149656
model-00037-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1acf2caae26d79c6bf3db918fc3693f2bc43f9c630310fccf09025d290f81c99
3
+ size 4995149848
model-00038-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:823d0c3e77509be96aee69be98c4fdf3978122c16fd39bc10e4bf6859de9f72f
3
+ size 4995149968
model-00039-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:610c554c62767a25f5904f41f11e77011b062e2be6bda35186f782fc8ae8b62c
3
+ size 4999181896
model-00040-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2a0e91565a4210c920931943a5eed51d56e8022e7e80728ce48ae4813aed6844
3
+ size 4995149656
model-00041-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e1339f3d8e1a422d20faf4b07fa40e12d3eee36e5e8f3dc08397216b1250f722
3
+ size 4995149656
model-00042-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0b1ce69017f8d1ba7cbf6fd88b957c1489780ac64ab9a60f3ecc4b142aefef57
3
+ size 4995149808
model-00043-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1958af77c7a1b0312cfb85badeec2488b7b90cc9ebd0fe3664ede510120c5085
3
+ size 4995149968
model-00044-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:112d167a780a79744aa050e6fde08717c95b5bc177bcc70b14331ebaaa6fad26
3
+ size 4999181936
model-00045-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0002b376e180bb2079d41f43d2d63aa5604827be791f185277ddea472ae27fe5
3
+ size 4995149656
model-00046-of-00076.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6708e902f55277959d6d18e35a5b1ea9f85b97b81977c4f513513fac3afc60b6
3
+ size 4995149656