luisra commited on
Commit
22b52e3
·
verified ·
1 Parent(s): 598b80c

Upload 2 files

Browse files
Files changed (2) hide show
  1. LICENSE +21 -0
  2. README.md +219 -0
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: transformers
4
+ ---
5
+ # DeepSeek-V3.1
6
+
7
+ <!-- markdownlint-disable first-line-h1 -->
8
+ <!-- markdownlint-disable html -->
9
+ <!-- markdownlint-disable no-duplicate-header -->
10
+
11
+ <div align="center">
12
+ <img src="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/logo.svg?raw=true" width="60%" alt="DeepSeek-V3" />
13
+ </div>
14
+ <hr>
15
+ <div align="center" style="line-height: 1;">
16
+ <a href="https://www.deepseek.com/" target="_blank" style="margin: 2px;">
17
+ <img alt="Homepage" src="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/badge.svg?raw=true" style="display: inline-block; vertical-align: middle;"/>
18
+ </a>
19
+ <a href="https://chat.deepseek.com/" target="_blank" style="margin: 2px;">
20
+ <img alt="Chat" src="https://img.shields.io/badge/🤖%20Chat-DeepSeek%20V3-536af5?color=536af5&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
21
+ </a>
22
+ <a href="https://huggingface.co/deepseek-ai" target="_blank" style="margin: 2px;">
23
+ <img alt="Hugging Face" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-DeepSeek%20AI-ffc107?color=ffc107&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
24
+ </a>
25
+ </div>
26
+
27
+ <div align="center" style="line-height: 1;">
28
+ <a href="https://discord.gg/Tc7c45Zzu5" target="_blank" style="margin: 2px;">
29
+ <img alt="Discord" src="https://img.shields.io/badge/Discord-DeepSeek%20AI-7289da?logo=discord&logoColor=white&color=7289da" style="display: inline-block; vertical-align: middle;"/>
30
+ </a>
31
+ <a href="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/qr.jpeg?raw=true" target="_blank" style="margin: 2px;">
32
+ <img alt="Wechat" src="https://img.shields.io/badge/WeChat-DeepSeek%20AI-brightgreen?logo=wechat&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
33
+ </a>
34
+ <a href="https://twitter.com/deepseek_ai" target="_blank" style="margin: 2px;">
35
+ <img alt="Twitter Follow" src="https://img.shields.io/badge/Twitter-deepseek_ai-white?logo=x&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
36
+ </a>
37
+ </div>
38
+
39
+ <div align="center" style="line-height: 1;">
40
+ <a href="LICENSE" style="margin: 2px;">
41
+ <img alt="License" src="https://img.shields.io/badge/License-MIT-f5de53?&color=f5de53" style="display: inline-block; vertical-align: middle;"/>
42
+ </a>
43
+ </div>
44
+
45
+ ## Introduction
46
+
47
+ DeepSeek-V3.1 is a hybrid model that supports both thinking mode and non-thinking mode. Compared to the previous version, this upgrade brings improvements in multiple aspects:
48
+
49
+ - **Hybrid thinking mode**: One model supports both thinking mode and non-thinking mode by changing the chat template.
50
+
51
+ - **Smarter tool calling**: Through post-training optimization, the model's performance in tool usage and agent tasks has significantly improved.
52
+
53
+ - **Higher thinking efficiency**: DeepSeek-V3.1-Think achieves comparable answer quality to DeepSeek-R1-0528, while responding more quickly.
54
+
55
+ DeepSeek-V3.1 is post-trained on the top of DeepSeek-V3.1-Base, which is built upon the original V3 base checkpoint through a two-phase long context extension approach, following the methodology outlined in the original DeepSeek-V3 report. We have expanded our dataset by collecting additional long documents and substantially extending both training phases. The 32K extension phase has been increased 10-fold to 630B tokens, while the 128K extension phase has been extended by 3.3x to 209B tokens. Additionally, DeepSeek-V3.1 is trained using the UE8M0 FP8 scale data format to ensure compatibility with microscaling data formats.
56
+
57
+ ## Model Downloads
58
+
59
+ <div align="center">
60
+
61
+ | **Model** | **#Total Params** | **#Activated Params** | **Context Length** | **Download** |
62
+ | :------------: | :------------: | :------------: | :------------: | :------------: |
63
+ | DeepSeek-V3.1-Base | 671B | 37B | 128K | [HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-V3.1-Base) \| [ModelScope](https://modelscope.cn/models/deepseek-ai/DeepSeek-V3.1-Base) |
64
+ | DeepSeek-V3.1 | 671B | 37B | 128K | [HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-V3.1) \| [ModelScope](https://modelscope.cn/models/deepseek-ai/DeepSeek-V3.1) |
65
+
66
+ </div>
67
+
68
+ ## Chat Template
69
+
70
+ The details of our chat template is described in `tokenizer_config.json` and `assets/chat_template.jinja`. Here is a brief description.
71
+
72
+ ### Non-Thinking
73
+
74
+ #### First-Turn
75
+
76
+ Prefix:
77
+ `<|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|></think>`
78
+
79
+ With the given prefix, DeepSeek V3.1 generates responses to queries in non-thinking mode. Unlike DeepSeek V3, it introduces an additional token `</think>`.
80
+
81
+ #### Multi-Turn
82
+ Context:
83
+ `<|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|></think>{response}<|end▁of▁sentence|>...<|User|>{query}<|Assistant|></think>{response}<|end▁of▁sentence|>`
84
+
85
+ Prefix:
86
+ `<|User|>{query}<|Assistant|></think>`
87
+
88
+ By concatenating the context and the prefix, we obtain the correct prompt for the query.
89
+
90
+ ### Thinking
91
+
92
+ #### First-Turn
93
+ Prefix:
94
+ `<|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|><think>`
95
+
96
+ The prefix of thinking mode is similar to DeepSeek-R1.
97
+
98
+
99
+ #### Multi-Turn
100
+ Context:
101
+ `<|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|></think>{response}<|end▁of▁sentence|>...<|User|>{query}<|Assistant|></think>{response}<|end▁of▁sentence|>`
102
+
103
+ Prefix:
104
+ `<|User|>{query}<|Assistant|><think>`
105
+
106
+ The multi-turn template is the same with non-thinking multi-turn chat template. It means the thinking token in the last turn will be dropped but the `</think>` is retained in every turn of context.
107
+
108
+ ### ToolCall
109
+ Toolcall is supported in non-thinking mode. The format is:
110
+
111
+ `<|begin▁of▁sentence|>{system prompt}{tool_description}<|User|>{query}<|Assistant|></think>` where the tool_description is
112
+
113
+ ```
114
+ ## Tools
115
+ You have access to the following tools:
116
+
117
+ ### {tool_name1}
118
+ Description: {description}
119
+
120
+ Parameters: {json.dumps(parameters)}
121
+
122
+ IMPORTANT: ALWAYS adhere to this exact format for tool use:
123
+ <|tool▁calls▁begin|><|tool▁call▁begin|>tool_call_name<|tool▁sep|>tool_call_arguments<|tool▁call▁end|>{{additional_tool_calls}}<|tool▁calls▁end|>
124
+
125
+ Where:
126
+ - `tool_call_name` must be an exact match to one of the available tools
127
+ - `tool_call_arguments` must be valid JSON that strictly follows the tool's Parameters Schema
128
+ - For multiple tool calls, chain them directly without separators or spaces
129
+ ```
130
+
131
+ ### Code-Agent
132
+ We support various code agent frameworks. Please refer to the above toolcall format to create your own code agents. An example is shown in `assets/code_agent_trajectory.html`.
133
+
134
+ ### Search-Agent
135
+ We design a specific format for searching toolcall in thinking mode, to support search agent.
136
+
137
+ For complex questions that require accessing external or up-to-date information, DeepSeek-V3.1 can leverage a user-provided search tool through a multi-turn tool-calling process.
138
+
139
+ Please refer to the `assets/search_tool_trajectory.html` and `assets/search_python_tool_trajectory.html` for the detailed template.
140
+
141
+ ## Evaluation
142
+ | Category | Benchmark (Metric) | DeepSeek V3.1-NonThinking | DeepSeek V3 0324 | DeepSeek V3.1-Thinking | DeepSeek R1 0528
143
+ |----------|----------------------------------|-----------------|---|---|---|
144
+ | General |
145
+ | | MMLU-Redux (EM) | 91.8 | 90.5 | 93.7 | 93.4
146
+ | | MMLU-Pro (EM) | 83.7 | 81.2 | 84.8 | 85.0
147
+ | | GPQA-Diamond (Pass@1) | 74.9 | 68.4 | 80.1 | 81.0
148
+ | | Humanity's Last Exam (Pass@1) | - | - | 15.9 | 17.7
149
+ |Search Agent|
150
+ | | BrowseComp | - | - | 30.0 | 8.9
151
+ | | BrowseComp_zh | - | - | 49.2 | 35.7
152
+ | | Humanity's Last Exam (Python + Search) |- | - | 29.8 | 24.8
153
+ | | SimpleQA | - | - | 93.4 | 92.3
154
+ | Code |
155
+ | | LiveCodeBench (2408-2505) (Pass@1) | 56.4 | 43.0 | 74.8 | 73.3
156
+ | | Codeforces-Div1 (Rating) | - | - | 2091 | 1930
157
+ | | Aider-Polyglot (Acc.) | 68.4 | 55.1 | 76.3 | 71.6
158
+ | Code Agent|
159
+ | | SWE Verified (Agent mode) | 66.0 | 45.4 | - | 44.6
160
+ | | SWE-bench Multilingual (Agent mode) | 54.5 | 29.3 | - | 30.5
161
+ | | Terminal-bench (Terminus 1 framework) | 31.3 | 13.3 | - | 5.7
162
+ | Math |
163
+ | | AIME 2024 (Pass@1) | 66.3 | 59.4 | 93.1 | 91.4
164
+ | | AIME 2025 (Pass@1) | 49.8 | 51.3 | 88.4 | 87.5
165
+ | | HMMT 2025 (Pass@1) | 33.5 | 29.2 | 84.2 | 79.4 |
166
+
167
+ Note:
168
+ - Search agents are evaluated with our internal search framework, which uses a commercial search API + webpage filter + 128K context window. Seach agent results of R1-0528 are evaluated with a pre-defined workflow.
169
+
170
+ - SWE-bench is evaluated with our internal code agent framework.
171
+
172
+ - HLE is evaluated with the text-only subset.
173
+
174
+ ### Usage Example
175
+
176
+ ```python
177
+ import transformers
178
+
179
+ tokenizer = transformers.AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-V3.1")
180
+
181
+ messages = [
182
+ {"role": "system", "content": "You are a helpful assistant"},
183
+ {"role": "user", "content": "Who are you?"},
184
+ {"role": "assistant", "content": "<think>Hmm</think>I am DeepSeek"},
185
+ {"role": "user", "content": "1+1=?"}
186
+ ]
187
+
188
+ tokenizer.apply_chat_template(messages, tokenize=False, thinking=True, add_generation_prompt=True)
189
+ # '<|begin▁of▁sentence|>You are a helpful assistant<|User|>Who are you?<|Assistant|></think>I am DeepSeek<|end▁of▁sentence|><|User|>1+1=?<|Assistant|><think>'
190
+
191
+ tokenizer.apply_chat_template(messages, tokenize=False, thinking=False, add_generation_prompt=True)
192
+ # '<|begin▁of▁sentence��>You are a helpful assistant<|User|>Who are you?<|Assistant|></think>I am DeepSeek<|end▁of▁sentence|><|User|>1+1=?<|Assistant|></think>'
193
+ ```
194
+
195
+ ## How to Run Locally
196
+
197
+ The model structure of DeepSeek-V3.1 is the same as DeepSeek-V3. Please visit [DeepSeek-V3](https://github.com/deepseek-ai/DeepSeek-V3) repo for more information about running this model locally.
198
+
199
+ ## License
200
+
201
+ This repository and the model weights are licensed under the [MIT License](LICENSE).
202
+
203
+ ## Citation
204
+
205
+ ```
206
+ @misc{deepseekai2024deepseekv3technicalreport,
207
+ title={DeepSeek-V3 Technical Report},
208
+ author={DeepSeek-AI},
209
+ year={2024},
210
+ eprint={2412.19437},
211
+ archivePrefix={arXiv},
212
+ primaryClass={cs.CL},
213
+ url={https://arxiv.org/abs/2412.19437},
214
+ }
215
+ ```
216
+
217
+ ## Contact
218
+
219
+ If you have any questions, please raise an issue or contact us at [service@deepseek.com](service@deepseek.com).