danielhanchen commited on
Commit
9f721a5
·
verified ·
1 Parent(s): ef43782

Create README.md

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