Update README.md
#1
by
shimmyshimmer
- opened
README.md
CHANGED
@@ -7,4 +7,219 @@ tags:
|
|
7 |
- unsloth
|
8 |
pipeline_tag: text-generation
|
9 |
library_name: transformers
|
10 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
- unsloth
|
8 |
pipeline_tag: text-generation
|
9 |
library_name: transformers
|
10 |
+
---
|
11 |
+
# DeepSeek-V3.1
|
12 |
+
|
13 |
+
<!-- markdownlint-disable first-line-h1 -->
|
14 |
+
<!-- markdownlint-disable html -->
|
15 |
+
<!-- markdownlint-disable no-duplicate-header -->
|
16 |
+
|
17 |
+
<div align="center">
|
18 |
+
<img src="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/logo.svg?raw=true" width="60%" alt="DeepSeek-V3" />
|
19 |
+
</div>
|
20 |
+
<hr>
|
21 |
+
<div align="center" style="line-height: 1;">
|
22 |
+
<a href="https://www.deepseek.com/" target="_blank" style="margin: 2px;">
|
23 |
+
<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;"/>
|
24 |
+
</a>
|
25 |
+
<a href="https://chat.deepseek.com/" target="_blank" style="margin: 2px;">
|
26 |
+
<img alt="Chat" src="https://img.shields.io/badge/🤖%20Chat-DeepSeek%20V3-536af5?color=536af5&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
|
27 |
+
</a>
|
28 |
+
<a href="https://huggingface.co/deepseek-ai" target="_blank" style="margin: 2px;">
|
29 |
+
<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;"/>
|
30 |
+
</a>
|
31 |
+
</div>
|
32 |
+
|
33 |
+
<div align="center" style="line-height: 1;">
|
34 |
+
<a href="https://discord.gg/Tc7c45Zzu5" target="_blank" style="margin: 2px;">
|
35 |
+
<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;"/>
|
36 |
+
</a>
|
37 |
+
<a href="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/qr.jpeg?raw=true" target="_blank" style="margin: 2px;">
|
38 |
+
<img alt="Wechat" src="https://img.shields.io/badge/WeChat-DeepSeek%20AI-brightgreen?logo=wechat&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
|
39 |
+
</a>
|
40 |
+
<a href="https://twitter.com/deepseek_ai" target="_blank" style="margin: 2px;">
|
41 |
+
<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;"/>
|
42 |
+
</a>
|
43 |
+
</div>
|
44 |
+
|
45 |
+
<div align="center" style="line-height: 1;">
|
46 |
+
<a href="LICENSE" style="margin: 2px;">
|
47 |
+
<img alt="License" src="https://img.shields.io/badge/License-MIT-f5de53?&color=f5de53" style="display: inline-block; vertical-align: middle;"/>
|
48 |
+
</a>
|
49 |
+
</div>
|
50 |
+
|
51 |
+
## Introduction
|
52 |
+
|
53 |
+
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:
|
54 |
+
|
55 |
+
- **Hybrid thinking mode**: One model supports both thinking mode and non-thinking mode by changing the chat template.
|
56 |
+
|
57 |
+
- **Smarter tool calling**: Through post-training optimization, the model's performance in tool usage and agent tasks has significantly improved.
|
58 |
+
|
59 |
+
- **Higher thinking efficiency**: DeepSeek-V3.1-Think achieves comparable answer quality to DeepSeek-R1-0528, while responding more quickly.
|
60 |
+
|
61 |
+
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.
|
62 |
+
|
63 |
+
## Model Downloads
|
64 |
+
|
65 |
+
<div align="center">
|
66 |
+
|
67 |
+
| **Model** | **#Total Params** | **#Activated Params** | **Context Length** | **Download** |
|
68 |
+
| :------------: | :------------: | :------------: | :------------: | :------------: |
|
69 |
+
| 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) |
|
70 |
+
| 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) |
|
71 |
+
|
72 |
+
</div>
|
73 |
+
|
74 |
+
## Chat Template
|
75 |
+
|
76 |
+
The details of our chat template is described in `tokenizer_config.json` and `assets/chat_template.jinja`. Here is a brief description.
|
77 |
+
|
78 |
+
### Non-Thinking
|
79 |
+
|
80 |
+
#### First-Turn
|
81 |
+
|
82 |
+
Prefix:
|
83 |
+
`<|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|></think>`
|
84 |
+
|
85 |
+
With the given prefix, DeepSeek V3.1 generates responses to queries in non-thinking mode. Unlike DeepSeek V3, it introduces an additional token `</think>`.
|
86 |
+
|
87 |
+
#### Multi-Turn
|
88 |
+
Context:
|
89 |
+
`<|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|></think>{response}<|end▁of▁sentence|>...<|User|>{query}<|Assistant|></think>{response}<|end▁of▁sentence|>`
|
90 |
+
|
91 |
+
Prefix:
|
92 |
+
`<|User|>{query}<|Assistant|></think>`
|
93 |
+
|
94 |
+
By concatenating the context and the prefix, we obtain the correct prompt for the query.
|
95 |
+
|
96 |
+
### Thinking
|
97 |
+
|
98 |
+
#### First-Turn
|
99 |
+
Prefix:
|
100 |
+
`<|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|><think>`
|
101 |
+
|
102 |
+
The prefix of thinking mode is similar to DeepSeek-R1.
|
103 |
+
|
104 |
+
|
105 |
+
#### Multi-Turn
|
106 |
+
Context:
|
107 |
+
`<|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|></think>{response}<|end▁of▁sentence|>...<|User|>{query}<|Assistant|></think>{response}<|end▁of▁sentence|>`
|
108 |
+
|
109 |
+
Prefix:
|
110 |
+
`<|User|>{query}<|Assistant|><think>`
|
111 |
+
|
112 |
+
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.
|
113 |
+
|
114 |
+
### ToolCall
|
115 |
+
Toolcall is supported in non-thinking mode. The format is:
|
116 |
+
|
117 |
+
`<|begin▁of▁sentence|>{system prompt}{tool_description}<|User|>{query}<|Assistant|></think>` where the tool_description is
|
118 |
+
|
119 |
+
```
|
120 |
+
## Tools
|
121 |
+
You have access to the following tools:
|
122 |
+
|
123 |
+
### {tool_name1}
|
124 |
+
Description: {description}
|
125 |
+
|
126 |
+
Parameters: {json.dumps(parameters)}
|
127 |
+
|
128 |
+
IMPORTANT: ALWAYS adhere to this exact format for tool use:
|
129 |
+
<|tool▁calls▁begin|><|tool▁call▁begin|>tool_call_name<|tool▁sep|>tool_call_arguments<|tool▁call▁end|>{{additional_tool_calls}}<|tool▁calls▁end|>
|
130 |
+
|
131 |
+
Where:
|
132 |
+
- `tool_call_name` must be an exact match to one of the available tools
|
133 |
+
- `tool_call_arguments` must be valid JSON that strictly follows the tool's Parameters Schema
|
134 |
+
- For multiple tool calls, chain them directly without separators or spaces
|
135 |
+
```
|
136 |
+
|
137 |
+
### Code-Agent
|
138 |
+
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`.
|
139 |
+
|
140 |
+
### Search-Agent
|
141 |
+
We design a specific format for searching toolcall in thinking mode, to support search agent.
|
142 |
+
|
143 |
+
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.
|
144 |
+
|
145 |
+
Please refer to the `assets/search_tool_trajectory.html` and `assets/search_python_tool_trajectory.html` for the detailed template.
|
146 |
+
|
147 |
+
## Evaluation
|
148 |
+
| Category | Benchmark (Metric) | DeepSeek V3.1-NonThinking | DeepSeek V3 0324 | DeepSeek V3.1-Thinking | DeepSeek R1 0528
|
149 |
+
|----------|----------------------------------|-----------------|---|---|---|
|
150 |
+
| General |
|
151 |
+
| | MMLU-Redux (EM) | 91.8 | 90.5 | 93.7 | 93.4
|
152 |
+
| | MMLU-Pro (EM) | 83.7 | 81.2 | 84.8 | 85.0
|
153 |
+
| | GPQA-Diamond (Pass@1) | 74.9 | 68.4 | 80.1 | 81.0
|
154 |
+
| | Humanity's Last Exam (Pass@1) | - | - | 15.9 | 17.7
|
155 |
+
|Search Agent|
|
156 |
+
| | BrowseComp | - | - | 30.0 | 8.9
|
157 |
+
| | BrowseComp_zh | - | - | 49.2 | 35.7
|
158 |
+
| | Humanity's Last Exam (Python + Search) |- | - | 29.8 | 24.8
|
159 |
+
| | SimpleQA | - | - | 93.4 | 92.3
|
160 |
+
| Code |
|
161 |
+
| | LiveCodeBench (2408-2505) (Pass@1) | 56.4 | 43.0 | 74.8 | 73.3
|
162 |
+
| | Codeforces-Div1 (Rating) | - | - | 2091 | 1930
|
163 |
+
| | Aider-Polyglot (Acc.) | 68.4 | 55.1 | 76.3 | 71.6
|
164 |
+
| Code Agent|
|
165 |
+
| | SWE Verified (Agent mode) | 66.0 | 45.4 | - | 44.6
|
166 |
+
| | SWE-bench Multilingual (Agent mode) | 54.5 | 29.3 | - | 30.5
|
167 |
+
| | Terminal-bench (Terminus 1 framework) | 31.3 | 13.3 | - | 5.7
|
168 |
+
| Math |
|
169 |
+
| | AIME 2024 (Pass@1) | 66.3 | 59.4 | 93.1 | 91.4
|
170 |
+
| | AIME 2025 (Pass@1) | 49.8 | 51.3 | 88.4 | 87.5
|
171 |
+
| | HMMT 2025 (Pass@1) | 33.5 | 29.2 | 84.2 | 79.4 |
|
172 |
+
|
173 |
+
Note:
|
174 |
+
- 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.
|
175 |
+
|
176 |
+
- SWE-bench is evaluated with our internal code agent framework.
|
177 |
+
|
178 |
+
- HLE is evaluated with the text-only subset.
|
179 |
+
|
180 |
+
### Usage Example
|
181 |
+
|
182 |
+
```python
|
183 |
+
import transformers
|
184 |
+
|
185 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-V3.1")
|
186 |
+
|
187 |
+
messages = [
|
188 |
+
{"role": "system", "content": "You are a helpful assistant"},
|
189 |
+
{"role": "user", "content": "Who are you?"},
|
190 |
+
{"role": "assistant", "content": "<think>Hmm</think>I am DeepSeek"},
|
191 |
+
{"role": "user", "content": "1+1=?"}
|
192 |
+
]
|
193 |
+
|
194 |
+
tokenizer.apply_chat_template(messages, tokenize=False, thinking=True, add_generation_prompt=True)
|
195 |
+
# '<|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>'
|
196 |
+
|
197 |
+
tokenizer.apply_chat_template(messages, tokenize=False, thinking=False, add_generation_prompt=True)
|
198 |
+
# '<|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>'
|
199 |
+
```
|
200 |
+
|
201 |
+
## How to Run Locally
|
202 |
+
|
203 |
+
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.
|
204 |
+
|
205 |
+
## License
|
206 |
+
|
207 |
+
This repository and the model weights are licensed under the [MIT License](LICENSE).
|
208 |
+
|
209 |
+
## Citation
|
210 |
+
|
211 |
+
```
|
212 |
+
@misc{deepseekai2024deepseekv3technicalreport,
|
213 |
+
title={DeepSeek-V3 Technical Report},
|
214 |
+
author={DeepSeek-AI},
|
215 |
+
year={2024},
|
216 |
+
eprint={2412.19437},
|
217 |
+
archivePrefix={arXiv},
|
218 |
+
primaryClass={cs.CL},
|
219 |
+
url={https://arxiv.org/abs/2412.19437},
|
220 |
+
}
|
221 |
+
```
|
222 |
+
|
223 |
+
## Contact
|
224 |
+
|
225 |
+
If you have any questions, please raise an issue or contact us at [[email protected]]([email protected]).
|