bdellabe commited on
Commit
d75d6d6
·
verified ·
1 Parent(s): fec01c2

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. LICENSE +9 -0
  3. README.md +156 -0
  4. config.json +146 -0
  5. configuration_deepseek.py +248 -0
  6. generation_config.json +9 -0
  7. model-00001-of-00080.safetensors +3 -0
  8. model-00003-of-00080.safetensors +3 -0
  9. model-00006-of-00080.safetensors +3 -0
  10. model-00008-of-00080.safetensors +3 -0
  11. model-00012-of-00080.safetensors +3 -0
  12. model-00013-of-00080.safetensors +3 -0
  13. model-00014-of-00080.safetensors +3 -0
  14. model-00015-of-00080.safetensors +3 -0
  15. model-00017-of-00080.safetensors +3 -0
  16. model-00020-of-00080.safetensors +3 -0
  17. model-00023-of-00080.safetensors +3 -0
  18. model-00029-of-00080.safetensors +3 -0
  19. model-00032-of-00080.safetensors +3 -0
  20. model-00034-of-00080.safetensors +3 -0
  21. model-00035-of-00080.safetensors +3 -0
  22. model-00036-of-00080.safetensors +3 -0
  23. model-00039-of-00080.safetensors +3 -0
  24. model-00040-of-00080.safetensors +3 -0
  25. model-00045-of-00080.safetensors +3 -0
  26. model-00047-of-00080.safetensors +3 -0
  27. model-00048-of-00080.safetensors +3 -0
  28. model-00049-of-00080.safetensors +3 -0
  29. model-00051-of-00080.safetensors +3 -0
  30. model-00053-of-00080.safetensors +3 -0
  31. model-00054-of-00080.safetensors +3 -0
  32. model-00055-of-00080.safetensors +3 -0
  33. model-00057-of-00080.safetensors +3 -0
  34. model-00058-of-00080.safetensors +3 -0
  35. model-00059-of-00080.safetensors +3 -0
  36. model-00060-of-00080.safetensors +3 -0
  37. model-00061-of-00080.safetensors +3 -0
  38. model-00062-of-00080.safetensors +3 -0
  39. model-00063-of-00080.safetensors +3 -0
  40. model-00064-of-00080.safetensors +3 -0
  41. model-00065-of-00080.safetensors +3 -0
  42. model-00066-of-00080.safetensors +3 -0
  43. model-00068-of-00080.safetensors +3 -0
  44. model-00069-of-00080.safetensors +3 -0
  45. model-00070-of-00080.safetensors +3 -0
  46. model-00072-of-00080.safetensors +3 -0
  47. model-00080-of-00080.safetensors +3 -0
  48. model.safetensors.index.json +3 -0
  49. tokenizer.json +0 -0
  50. tokenizer_config.json +35 -0
.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
+ model.safetensors.index.json filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+ Copyright (c) 2025 Nvidia
3
+ Copyright (c) 2023 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
README.md ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: text-generation
3
+ base_model:
4
+ - deepseek-ai/DeepSeek-R1
5
+ license: mit
6
+ ---
7
+ # Model Overview
8
+
9
+ ## Description:
10
+ The NVIDIA DeepSeek R1 FP4 model is the quantized version of the DeepSeek AI's DeepSeek R1 model, which is an auto-regressive language model that uses an optimized transformer architecture. For more information, please check [here](https://huggingface.co/deepseek-ai/DeepSeek-R1). The NVIDIA DeepSeek R1 FP4 model is quantized with [TensorRT Model Optimizer](https://github.com/NVIDIA/TensorRT-Model-Optimizer).
11
+
12
+ This model is ready for commercial/non-commercial use. <br>
13
+
14
+ ## Third-Party Community Consideration
15
+ This model is not owned or developed by NVIDIA. This model has been developed and built to a third-party’s requirements for this application and use case; see link to Non-NVIDIA [(DeepSeek R1) Model Card](https://huggingface.co/deepseek-ai/DeepSeek-R1).
16
+
17
+ ### License/Terms of Use:
18
+ [MIT](https://huggingface.co/datasets/choosealicense/licenses/blob/main/markdown/mit.md)
19
+
20
+
21
+ ## Model Architecture:
22
+ **Architecture Type:** Transformers <br>
23
+ **Network Architecture:** DeepSeek R1 <br>
24
+
25
+ ## Input:
26
+ **Input Type(s):** Text <br>
27
+ **Input Format(s):** String <br>
28
+ **Input Parameters:** One Dimensional(1D): Sequences <br>
29
+ **Other Properties Related to Input:** Context length up to 128K <br>
30
+
31
+ ## Output:
32
+ **Output Type(s):** Text <br>
33
+ **Output Format:** String <br>
34
+ **Output Parameters:** 1D: Sequences <br>
35
+ **Other Properties Related to Output:** N/A <br>
36
+
37
+ ## Software Integration:
38
+ **Supported Runtime Engine(s):** <br>
39
+ * TensorRT-LLM <br>
40
+
41
+ **Supported Hardware Microarchitecture Compatibility:** <br>
42
+ * NVIDIA Blackwell <br>
43
+
44
+ **Preferred Operating System(s):** <br>
45
+ * Linux <br>
46
+
47
+ ## Model Version(s):
48
+ The model is quantized with nvidia-modelopt **v0.23.0** <br>
49
+
50
+ ## Datasets:
51
+ * Calibration Dataset: [cnn_dailymail](https://huggingface.co/datasets/abisee/cnn_dailymail) <br>
52
+ ** Data collection method: Automated. <br>
53
+ ** Labeling method: Unknown. <br>
54
+ * Evaluation Dataset: [MMLU](https://github.com/hendrycks/test) <br>
55
+ ** Data collection method: Unknown. <br>
56
+ ** Labeling method: N/A. <br>
57
+
58
+
59
+ ## Inference:
60
+ **Engine:** TensorRT-LLM <br>
61
+ **Test Hardware:** B200 <br>
62
+
63
+ ## Post Training Quantization
64
+ This model was obtained by quantizing the weights and activations of DeepSeek R1 to FP4 data type, ready for inference with TensorRT-LLM. Only the weights and activations of the linear operators within transformers blocks are quantized. This optimization reduces the number of bits per parameter from 8 to 4, reducing the disk size and GPU memory requirements by approximately 1.6x.
65
+
66
+ ## Usage
67
+
68
+ ### Deploy with TensorRT-LLM
69
+
70
+ To deploy the quantized FP4 checkpoint with [TensorRT-LLM](https://github.com/NVIDIA/TensorRT-LLM) LLM API, follow the sample codes below (you need 8xB200 GPU and TensorRT LLM built from source with the latest main branch):
71
+
72
+ * LLM API sample usage:
73
+ ```
74
+ from tensorrt_llm import SamplingParams
75
+ from tensorrt_llm._torch import LLM
76
+
77
+ def main():
78
+
79
+ prompts = [
80
+ "Hello, my name is",
81
+ "The president of the United States is",
82
+ "The capital of France is",
83
+ "The future of AI is",
84
+ ]
85
+ sampling_params = SamplingParams(max_tokens=32)
86
+
87
+ llm = LLM(model="nvidia/DeepSeek-R1-FP4", tensor_parallel_size=8, enable_attention_dp=True)
88
+
89
+ outputs = llm.generate(prompts, sampling_params)
90
+
91
+ # Print the outputs.
92
+ for output in outputs:
93
+ prompt = output.prompt
94
+ generated_text = output.outputs[0].text
95
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
96
+
97
+
98
+ # The entry point of the program need to be protected for spawning processes.
99
+ if __name__ == '__main__':
100
+ main()
101
+
102
+ ```
103
+
104
+ ### Evaluation
105
+ The accuracy benchmark results are presented in the table below:
106
+ <table>
107
+ <tr>
108
+ <td><strong>Precision</strong>
109
+ </td>
110
+ <td><strong>MMLU</strong>
111
+ </td>
112
+ <td><strong>GSM8K</strong>
113
+ </td>
114
+ <td><strong>AIME2024</strong>
115
+ </td>
116
+ <td><strong>GPQA Diamond</strong>
117
+ </td>
118
+ <td><strong>MATH-500</strong>
119
+ </td>
120
+ </tr>
121
+ <tr>
122
+ <td>FP8
123
+ </td>
124
+ <td>90.8
125
+ </td>
126
+ <td>96.3
127
+ </td>
128
+ <td>80.0
129
+ </td>
130
+ <td>69.7
131
+ </td>
132
+ <td>95.4
133
+ </td>
134
+ </tr>
135
+ <tr>
136
+ <td>FP4
137
+ </td>
138
+ <td>90.7
139
+ </td>
140
+ <td>96.1
141
+ </td>
142
+ <td>80.0
143
+ </td>
144
+ <td>69.2
145
+ </td>
146
+ <td>94.2
147
+ </td>
148
+ </tr>
149
+ <tr>
150
+ </table>
151
+
152
+ ## Ethical Considerations
153
+
154
+ NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.
155
+
156
+ Please report security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).
config.json ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "aux_loss_alpha": 0.001,
13
+ "bos_token_id": 0,
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
+ "pretraining_tp": 1,
36
+ "q_lora_rank": 1536,
37
+ "qk_nope_head_dim": 128,
38
+ "qk_rope_head_dim": 64,
39
+ "quantization_config": {
40
+ "config_groups": {
41
+ "config_group_0": {
42
+ "targets": [
43
+ "re:.*self_attn.(o_proj|q_b_proj).*"
44
+ ],
45
+ "weights": {
46
+ "num_bits": 8,
47
+ "type": "float",
48
+ "symmetric": true,
49
+ "group_size": null,
50
+ "strategy": "block",
51
+ "block_structure": [
52
+ 128,
53
+ 128
54
+ ],
55
+ "dynamic": false,
56
+ "actorder": null,
57
+ "scale_dtype": null,
58
+ "zp_dtype": null,
59
+ "observer": "static_minmax",
60
+ "observer_kwargs": {}
61
+ },
62
+ "input_activations": {
63
+ "num_bits": 8,
64
+ "type": "float",
65
+ "symmetric": true,
66
+ "group_size": 128,
67
+ "strategy": "group",
68
+ "block_structure": null,
69
+ "dynamic": true,
70
+ "actorder": null,
71
+ "scale_dtype": null,
72
+ "zp_dtype": null,
73
+ "observer": null,
74
+ "observer_kwargs": {}
75
+ },
76
+ "output_activations": null,
77
+ "format": "float-quantized"
78
+ },
79
+ "config_group_1": {
80
+ "targets": [
81
+ "re:.*mlp.*\\.(gate_up|gate|up|down)_proj$"
82
+ ],
83
+ "weights": {
84
+ "num_bits": 4,
85
+ "type": "float",
86
+ "symmetric": true,
87
+ "group_size": 16,
88
+ "strategy": "tensor_group",
89
+ "block_structure": null,
90
+ "dynamic": false,
91
+ "actorder": null,
92
+ "scale_dtype": "torch.float8_e4m3fn",
93
+ "zp_dtype": null,
94
+ "observer": "static_minmax",
95
+ "observer_kwargs": {}
96
+ },
97
+ "input_activations": {
98
+ "num_bits": 4,
99
+ "type": "float",
100
+ "symmetric": true,
101
+ "group_size": 16,
102
+ "strategy": "tensor_group",
103
+ "block_structure": null,
104
+ "dynamic": "local",
105
+ "actorder": null,
106
+ "scale_dtype": "torch.float8_e4m3fn",
107
+ "zp_dtype": null,
108
+ "observer": "static_minmax",
109
+ "observer_kwargs": {}
110
+ },
111
+ "output_activations": null,
112
+ "format": "nvfp4-pack-quantized"
113
+ }
114
+ },
115
+ "quant_method": "compressed-tensors",
116
+ "kv_cache_scheme": null,
117
+ "format": "mixed-precision",
118
+ "quantization_status": "compressed",
119
+ "global_compression_ratio": null,
120
+ "ignore": [
121
+ "re:.*self_attn.(kv_a_proj_with_mqa|kv_b_proj|q_a_proj)$"
122
+ ]
123
+ },
124
+ "rms_norm_eps": 1e-06,
125
+ "rope_scaling": {
126
+ "beta_fast": 32,
127
+ "beta_slow": 1,
128
+ "factor": 40,
129
+ "mscale": 1.0,
130
+ "mscale_all_dim": 1.0,
131
+ "original_max_position_embeddings": 4096,
132
+ "type": "yarn"
133
+ },
134
+ "rope_theta": 10000,
135
+ "routed_scaling_factor": 2.5,
136
+ "scoring_func": "sigmoid",
137
+ "seq_aux": true,
138
+ "tie_word_embeddings": false,
139
+ "topk_group": 4,
140
+ "topk_method": "noaux_tc",
141
+ "torch_dtype": "bfloat16",
142
+ "transformers_version": "4.46.3",
143
+ "use_cache": true,
144
+ "v_head_dim": 128,
145
+ "vocab_size": 129280
146
+ }
configuration_deepseek.py ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Adapted from https://huggingface.co/deepseek-ai/DeepSeek-R1/blob/main/configuration_deepseek.py
2
+ # MIT License
3
+
4
+ # Copyright (c) 2023 DeepSeek
5
+
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ # SPDX-FileCopyrightText: Copyright (c) 2023-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
25
+ # SPDX-License-Identifier: Apache-2.0
26
+ #
27
+ # Licensed under the Apache License, Version 2.0 (the "License");
28
+ # you may not use this file except in compliance with the License.
29
+ # You may obtain a copy of the License at
30
+ #
31
+ # http://www.apache.org/licenses/LICENSE-2.0
32
+ #
33
+ # Unless required by applicable law or agreed to in writing, software
34
+ # distributed under the License is distributed on an "AS IS" BASIS,
35
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36
+ # See the License for the specific language governing permissions and
37
+ # limitations under the License.
38
+
39
+ from transformers.configuration_utils import PretrainedConfig
40
+ from transformers.utils import logging
41
+
42
+ logger = logging.get_logger(__name__)
43
+
44
+ DEEPSEEK_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
45
+ class DeepseekV3Config(PretrainedConfig):
46
+ r"""
47
+ This is the configuration class to store the configuration of a [`DeepseekV3Model`]. It is used to instantiate an DeepSeek
48
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
49
+ defaults will yield a similar configuration to that of the DeepSeek-V3.
50
+
51
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
52
+ documentation from [`PretrainedConfig`] for more information.
53
+
54
+
55
+ Args:
56
+ vocab_size (`int`, *optional*, defaults to 129280):
57
+ Vocabulary size of the Deep model. Defines the number of different tokens that can be represented by the
58
+ `inputs_ids` passed when calling [`DeepseekV3Model`]
59
+ hidden_size (`int`, *optional*, defaults to 4096):
60
+ Dimension of the hidden representations.
61
+ intermediate_size (`int`, *optional*, defaults to 11008):
62
+ Dimension of the MLP representations.
63
+ moe_intermediate_size (`int`, *optional*, defaults to 1407):
64
+ Dimension of the MoE representations.
65
+ num_hidden_layers (`int`, *optional*, defaults to 32):
66
+ Number of hidden layers in the Transformer decoder.
67
+ num_nextn_predict_layers (`int`, *optional*, defaults to 1):
68
+ Number of nextn predict layers in the DeepSeekV3 Model.
69
+ num_attention_heads (`int`, *optional*, defaults to 32):
70
+ Number of attention heads for each attention layer in the Transformer decoder.
71
+ n_shared_experts (`int`, *optional*, defaults to None):
72
+ Number of shared experts, None means dense model.
73
+ n_routed_experts (`int`, *optional*, defaults to None):
74
+ Number of routed experts, None means dense model.
75
+ routed_scaling_factor (`float`, *optional*, defaults to 1.0):
76
+ Scaling factor or routed experts.
77
+ topk_method (`str`, *optional*, defaults to `gready`):
78
+ Topk method used in routed gate.
79
+ n_group (`int`, *optional*, defaults to None):
80
+ Number of groups for routed experts.
81
+ topk_group (`int`, *optional*, defaults to None):
82
+ Number of selected groups for each token(for each token, ensuring the selected experts is only within `topk_group` groups).
83
+ num_experts_per_tok (`int`, *optional*, defaults to None):
84
+ Number of selected experts, None means dense model.
85
+ moe_layer_freq (`int`, *optional*, defaults to 1):
86
+ The frequency of the MoE layer: one expert layer for every `moe_layer_freq - 1` dense layers.
87
+ first_k_dense_replace (`int`, *optional*, defaults to 0):
88
+ Number of dense layers in shallow layers(embed->dense->dense->...->dense->moe->moe...->lm_head).
89
+ \--k dense layers--/
90
+ norm_topk_prob (`bool`, *optional*, defaults to False):
91
+ Whether to normalize the weights of the routed experts.
92
+ scoring_func (`str`, *optional*, defaults to 'softmax'):
93
+ Method of computing expert weights.
94
+ aux_loss_alpha (`float`, *optional*, defaults to 0.001):
95
+ Auxiliary loss weight coefficient.
96
+ seq_aux = (`bool`, *optional*, defaults to True):
97
+ Whether to compute the auxiliary loss for each individual sample.
98
+ num_key_value_heads (`int`, *optional*):
99
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
100
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
101
+ `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
102
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
103
+ by meanpooling all the original heads within that group. For more details checkout [this
104
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
105
+ `num_attention_heads`.
106
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
107
+ The non-linear activation function (function or string) in the decoder.
108
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
109
+ The maximum sequence length that this model might ever be used with.
110
+ initializer_range (`float`, *optional*, defaults to 0.02):
111
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
112
+ rms_norm_eps (`float`, *optional*, defaults to 1e-06):
113
+ The epsilon used by the rms normalization layers.
114
+ use_cache (`bool`, *optional*, defaults to `True`):
115
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
116
+ relevant if `config.is_decoder=True`.
117
+ pad_token_id (`int`, *optional*):
118
+ Padding token id.
119
+ bos_token_id (`int`, *optional*, defaults to 1):
120
+ Beginning of stream token id.
121
+ eos_token_id (`int`, *optional*, defaults to 2):
122
+ End of stream token id.
123
+ pretraining_tp (`int`, *optional*, defaults to 1):
124
+ Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
125
+ document](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value is
126
+ necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
127
+ issue](https://github.com/pytorch/pytorch/issues/76232).
128
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
129
+ Whether to tie weight embeddings
130
+ rope_theta (`float`, *optional*, defaults to 10000.0):
131
+ The base period of the RoPE embeddings.
132
+ rope_scaling (`Dict`, *optional*):
133
+ Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
134
+ strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
135
+ `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
136
+ `max_position_embeddings` to the expected new maximum.
137
+ attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
138
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
139
+ attention_dropout (`float`, *optional*, defaults to 0.0):
140
+ The dropout ratio for the attention probabilities.
141
+
142
+ ```python
143
+ >>> from transformers import DeepseekV3Model, DeepseekV3Config
144
+
145
+ >>> # Initializing a Deepseek-V3 style configuration
146
+ >>> configuration = DeepseekV3Config()
147
+
148
+ >>> # Accessing the model configuration
149
+ >>> configuration = model.config
150
+ ```"""
151
+
152
+ model_type = "deepseek_v3"
153
+ keys_to_ignore_at_inference = ["past_key_values"]
154
+
155
+ def __init__(
156
+ self,
157
+ vocab_size=129280,
158
+ hidden_size=7168,
159
+ intermediate_size=18432,
160
+ moe_intermediate_size = 2048,
161
+ num_hidden_layers=61,
162
+ num_nextn_predict_layers=1,
163
+ num_attention_heads=128,
164
+ num_key_value_heads=128,
165
+ n_shared_experts = 1,
166
+ n_routed_experts = 256,
167
+ ep_size = 1,
168
+ routed_scaling_factor = 2.5,
169
+ kv_lora_rank = 512,
170
+ q_lora_rank = 1536,
171
+ qk_rope_head_dim = 64,
172
+ v_head_dim = 128,
173
+ qk_nope_head_dim = 128,
174
+ topk_method = 'noaux_tc',
175
+ n_group = 8,
176
+ topk_group = 4,
177
+ num_experts_per_tok = 8,
178
+ moe_layer_freq = 1,
179
+ first_k_dense_replace = 3,
180
+ norm_topk_prob = True,
181
+ scoring_func = 'sigmoid',
182
+ aux_loss_alpha = 0.001,
183
+ seq_aux = True,
184
+ hidden_act="silu",
185
+ max_position_embeddings=4096,
186
+ initializer_range=0.02,
187
+ rms_norm_eps=1e-6,
188
+ use_cache=True,
189
+ pad_token_id=None,
190
+ bos_token_id=0,
191
+ eos_token_id=1,
192
+ pretraining_tp=1,
193
+ tie_word_embeddings=False,
194
+ rope_theta=10000.0,
195
+ rope_scaling=None,
196
+ attention_bias=False,
197
+ attention_dropout=0.0,
198
+ **kwargs,
199
+ ):
200
+ self.vocab_size = vocab_size
201
+ self.max_position_embeddings = max_position_embeddings
202
+ self.hidden_size = hidden_size
203
+ self.intermediate_size = intermediate_size
204
+ self.moe_intermediate_size = moe_intermediate_size
205
+ self.num_hidden_layers = num_hidden_layers
206
+ self.num_nextn_predict_layers = num_nextn_predict_layers
207
+ self.num_attention_heads = num_attention_heads
208
+ self.n_shared_experts = n_shared_experts
209
+ self.n_routed_experts = n_routed_experts
210
+ self.ep_size = ep_size
211
+ self.routed_scaling_factor = routed_scaling_factor
212
+ self.kv_lora_rank = kv_lora_rank
213
+ self.q_lora_rank = q_lora_rank
214
+ self.qk_rope_head_dim = qk_rope_head_dim
215
+ self.v_head_dim = v_head_dim
216
+ self.qk_nope_head_dim = qk_nope_head_dim
217
+ self.topk_method = topk_method
218
+ self.n_group = n_group
219
+ self.topk_group = topk_group
220
+ self.num_experts_per_tok = num_experts_per_tok
221
+ self.moe_layer_freq = moe_layer_freq
222
+ self.first_k_dense_replace = first_k_dense_replace
223
+ self.norm_topk_prob = norm_topk_prob
224
+ self.scoring_func = scoring_func
225
+ self.aux_loss_alpha = aux_loss_alpha
226
+ self.seq_aux = seq_aux
227
+ # for backward compatibility
228
+ if num_key_value_heads is None:
229
+ num_key_value_heads = num_attention_heads
230
+
231
+ self.num_key_value_heads = num_key_value_heads
232
+ self.hidden_act = hidden_act
233
+ self.initializer_range = initializer_range
234
+ self.rms_norm_eps = rms_norm_eps
235
+ self.pretraining_tp = pretraining_tp
236
+ self.use_cache = use_cache
237
+ self.rope_theta = rope_theta
238
+ self.rope_scaling = rope_scaling
239
+ self.attention_bias = attention_bias
240
+ self.attention_dropout = attention_dropout
241
+
242
+ super().__init__(
243
+ pad_token_id=pad_token_id,
244
+ bos_token_id=bos_token_id,
245
+ eos_token_id=eos_token_id,
246
+ tie_word_embeddings=tie_word_embeddings,
247
+ **kwargs,
248
+ )
generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": 1,
5
+ "do_sample": true,
6
+ "temperature": 0.6,
7
+ "top_p": 0.95,
8
+ "transformers_version": "4.39.3"
9
+ }
model-00001-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c577c1f8f9039f367a10f952371d685462562194dd8bcf413428b38dd13f4916
3
+ size 4747304092
model-00003-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37bae77e9794030d439280a70fc4418869137614a5404f7e43577d7e2f4e4e75
3
+ size 5210583888
model-00006-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a34b7e4c9ff546b44d918774a8e1ab4f5c6bfc0d2787dc2443301354c1cfbef9
3
+ size 5367751104
model-00008-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0baafdbe7d4aeaded563fe4b0eef3e6e66dacefe972fa477c11930b700b290d
3
+ size 5210569368
model-00012-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7eafaa841dbc4a8fdf18a3b6c3e78a71e8ecb8f97e2e67346918bb62a914ace0
3
+ size 5367753896
model-00013-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bf9e4834a74d8344a10a095329582843d6173cd663fef17118ac4915b8f74d3a
3
+ size 5210571728
model-00014-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:553ccfd57d0d093d16f4b8bde805a16b5e60c0cb3200b13c10bf6e8aac092aa5
3
+ size 5210600712
model-00015-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a11d0b87f06a1962bc808e1dc1f47b9fc83f97f3332c2e50c64d696f262197c0
3
+ size 5210600728
model-00017-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0ecb572a8ed62d65d7e9864bb933d412f3e71b3893ac141c7cfd5045dbcc0ac
3
+ size 5210586800
model-00020-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a38165ff3220725f456f9775cdd53a462ba503e31b7f5c71b6403d7da4455ba
3
+ size 5148980796
model-00023-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1bb473b6be1e4d8817356fe24222a6302a7677ffcf8523112ddf8f0fd37face3
3
+ size 5210586120
model-00029-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a30ac8b1afa9b920c53f488660eff7870a9ac66aefc4d16e580d93997746550
3
+ size 5210600984
model-00032-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1540a5594d1b931fcc62d576750719cf02db33b2337db3470a03746dcb2a1961
3
+ size 5206914204
model-00034-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dab5fcebc49b46e58963501164212bed091ed15ab899b0057c376527f2f8b484
3
+ size 5210600712
model-00035-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c009f8db36a0df3ef7b5e5d7f0f9c133d69efac73c9b2c79bb91882a88693e0e
3
+ size 5210601128
model-00036-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a06cc6405be724303e77572c991b5f103934e67b5784e7228347998a70f1de6b
3
+ size 5367753872
model-00039-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:94e1986cfc701337fc85132e586930face20dca6d74729d728cc781dfb091c38
3
+ size 5210601064
model-00040-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c32e2502793ce7ae4e52c98654d65471a0f19a025a89cbbdba47f744d32df32
3
+ size 5367753440
model-00045-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3c59c2f007f79796204f89282f735ecfee822c67901c8b81f83ee9337c9a468
3
+ size 5210601272
model-00047-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:079e31b088d7881605cda369c7cd3131443740899e051536ccc591d58d0a8afe
3
+ size 5210586216
model-00048-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be635e4ecb2aa548a67edbb833b0c0d2faa8a745713d591ba2270ba716be1257
3
+ size 5210586120
model-00049-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a87ea0bff10f23b1166e523bb3ccab1a353142d9ce6202b56641a6758089af35
3
+ size 5210601064
model-00051-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6820b57b4e50972a8dd8d1198efb54c17a44e9e1567dbe1c16761aee27c771e1
3
+ size 5210601296
model-00053-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c3ad59caf1d15a60792bf816bc7a7126a69aceb0520af4c8fc79e0cec2e0e4ec
3
+ size 5210600656
model-00054-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:24136263254bd6b9b79239c02263ffc760ba4602a0898490ae45d5cf270e3338
3
+ size 5210600624
model-00055-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b9c9442436b8f42c58099db37411c7e3552b548e7c440069709ec7993540d96c
3
+ size 5210601344
model-00057-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa6c081e4019de03663da490be08981a938110ca3b4f51cc0b5b65efcfe25476
3
+ size 5210600552
model-00058-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:746ad6c5a47a9d6413ab84370b8c658f895ed539c2b95126869857d3269ef741
3
+ size 5210586120
model-00059-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aac4fd532921ac8aac9550b51087aa555b7eff86bee0e6fb4e0ca65dbd29f4bf
3
+ size 5210601064
model-00060-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:114464e5dc3b3931e95439171da05aaa57d18bb94b0ed4deb422681d1f776cfd
3
+ size 5367753760
model-00061-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae76c6a28746bc155809b4496bf6a6b06f79acb1e4ead97d8d2d01bf232379f1
3
+ size 5210586704
model-00062-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b186ce6995b7989b774c929b62d486f5f250d578a1e003f225b39809e59ef9e6
3
+ size 5210586120
model-00063-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5a97a576984bce18ce109e442bbf3e5491fc742aa226be5c7264e2fdf916c68b
3
+ size 5210600800
model-00064-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee721352cb5a425bb3dac45d330e3d7d9da5615108b25fe50136aa97ab87516c
3
+ size 5264593356
model-00065-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:85f4b1b2524d166423d9cfff312e3d92d9b11ca12514942785b89702c1e4e66a
3
+ size 5213746996
model-00066-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8264d594762ed8db1c7bc88fe872abbc130eb53b3f42c56202ee24ae121cd05b
3
+ size 5211504456
model-00068-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:272c51491b7a9c1b70796bd6f7e4831cacda185b9e10472f519409689eb17365
3
+ size 5210600944
model-00069-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db974f88235f91d3b8641ea60902c01450808fd7e1aa874a63dba8e27890d1a0
3
+ size 5367753352
model-00070-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a1e30db5c5c9a00692000704543814e138015b70d0f50670e4e8709b11d42402
3
+ size 5165247420
model-00072-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f11222b0fc6542f8af8223ab8580f4c3ae3b2261ee60c8dc7d78fdc4ee76298
3
+ size 5211504000
model-00080-of-00080.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:122f0f2f22b4b691476275f0118be76e32cf72592d2ef1f05d67e30d64bd9ff0
3
+ size 1853372656
model.safetensors.index.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:752ecdc83164e3bfd02f906dcd790c6e3fdbc9dcf0e7b88d3ab78d8b9cd331f2
3
+ size 18089328
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "bos_token": {
5
+ "__type": "AddedToken",
6
+ "content": "<|begin▁of▁sentence|>",
7
+ "lstrip": false,
8
+ "normalized": true,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "clean_up_tokenization_spaces": false,
13
+ "eos_token": {
14
+ "__type": "AddedToken",
15
+ "content": "<|end▁of▁sentence|>",
16
+ "lstrip": false,
17
+ "normalized": true,
18
+ "rstrip": false,
19
+ "single_word": false
20
+ },
21
+ "legacy": true,
22
+ "model_max_length": 16384,
23
+ "pad_token": {
24
+ "__type": "AddedToken",
25
+ "content": "<|end▁of▁sentence|>",
26
+ "lstrip": false,
27
+ "normalized": true,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ },
31
+ "sp_model_kwargs": {},
32
+ "unk_token": null,
33
+ "tokenizer_class": "LlamaTokenizerFast",
34
+ "chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='', is_first_sp=true) %}{%- for message in messages %}{%- if message['role'] == 'system' %}{%- if ns.is_first_sp %}{% set ns.system_prompt = ns.system_prompt + message['content'] %}{% set ns.is_first_sp = false %}{%- else %}{% set ns.system_prompt = ns.system_prompt + '\\n\\n' + message['content'] %}{%- endif %}{%- endif %}{%- endfor %}{{ bos_token }}{{ ns.system_prompt }}{%- for message in messages %}{%- if message['role'] == 'user' %}{%- set ns.is_tool = false -%}{{'<|User|>' + message['content']}}{%- endif %}{%- if message['role'] == 'assistant' and 'tool_calls' in message %}{%- set ns.is_tool = false -%}{%- for tool in message['tool_calls'] %}{%- if not ns.is_first %}{%- if message['content'] is none %}{{'<|Assistant|><|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<|tool▁call▁end|>'}}{%- else %}{{'<|Assistant|>' + message['content'] + '<|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<|tool▁call▁end|>'}}{%- endif %}{%- set ns.is_first = true -%}{%- else %}{{'\\n' + '<|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<|tool▁call▁end|>'}}{%- endif %}{%- endfor %}{{'<|tool▁calls▁end|><|end▁of▁sentence|>'}}{%- endif %}{%- if message['role'] == 'assistant' and 'tool_calls' not in message %}{%- if ns.is_tool %}{{'<|tool▁outputs▁end|>' + message['content'] + '<|end▁of▁sentence|>'}}{%- set ns.is_tool = false -%}{%- else %}{% set content = message['content'] %}{% if '</think>' in content %}{% set content = content.split('</think>')[-1] %}{% endif %}{{'<|Assistant|>' + content + '<|end▁of▁sentence|>'}}{%- endif %}{%- endif %}{%- if message['role'] == 'tool' %}{%- set ns.is_tool = true -%}{%- if ns.is_output_first %}{{'<|tool▁outputs▁begin|><|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- set ns.is_output_first = false %}{%- else %}{{'<|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- endif %}{%- endif %}{%- endfor -%}{% if ns.is_tool %}{{'<|tool▁outputs▁end|>'}}{% endif %}{% if add_generation_prompt and not ns.is_tool %}{{'<|Assistant|><think>\\n'}}{% endif %}"
35
+ }