深入解析:【R2模型前瞻】幻方量化开源 DeepSeek-V3.1
简介
DeepSeek-V3.1 是一种混合模型,同时支持思考模式和非思考模式。相较于前一版本,此次升级在多个方面带来了改进:
混合思考模式:通过调整对话模板,同一模型可支持思考模式与非思考模式。
更智能的工具调用:经过训练后优化,模型在工具使用和智能体任务上的表现显著提升。
更高的思考效率:DeepSeek-V3.1-Think 在保持与 DeepSeek-R1-0528 相当的回答质量的同时,响应速度更快。
DeepSeek-V3.1 是在 DeepSeek-V3.1-Base 的基础上进行训练后优化的,而 V3.1-Base 则基于原始 V3 基础检查点,采用两阶段长上下文扩展方法构建,遵循了原版 DeepSeek-V3 报告中概述的方法论。我们通过收集更多长文本文档大幅扩展了训练数据集,并显著延长了两个训练阶段的规模:32K 扩展阶段的训练量增加了 10 倍,达到 630B tokens;128K 扩展阶段则扩展了 3.3 倍,达到 209B tokens。此外,DeepSeek-V3.1 采用 UE8M0 FP8 缩放数据格式进行训练,以确保与微缩放数据格式的兼容性。
模型下载
模型 | 参数总量 | 激活参数量 | 上下文长度 | 下载链接 |
---|---|---|---|---|
DeepSeek-V3.1-Base | 671B | 37B | 128K | HuggingFace | ModelScope |
DeepSeek-V3.1 | 671B | 37B | 128K | HuggingFace | ModelScope |
聊天模板
我们的聊天模板详细说明见 tokenizer_config.json
和 assets/chat_template.jinja
文件。以下是简要描述。
非思考模式
第一轮对话
前缀<|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|></think>
根据给定的前缀,深度求索V3.1以非思考模式生成对查询的响应。与深度求索V3不同的是,它引入了一个额外的标记</think>
。
多轮对话
上下文:
<|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|></think>{response}<|end▁of▁sentence|>...<|User|>{query}<|Assistant|></think>{response}<|end▁of▁sentence|>
前缀<|User|>{query}<|Assistant|></think>
通过将上下文和前缀连接起来,我们得到了查询的正确提示。
思考模式
第一轮对话
前缀<|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|><think>
思维模式的前缀类似于DeepSeek-R1。
多轮对话
上下文:<|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|></think>{response}<|end▁of▁sentence|>...<|User|>{query}<|Assistant|></think>{response}<|end▁of▁sentence|>
前缀:<|User|>{query}<|Assistant|><think>
多轮对话模板与非思考型多轮对话模板相同。这意味着最后一轮的思考标记会被丢弃,但每轮上下文中仍保留</think>
标签。
ToolCall
工具调用在非思考模式下支持。格式为:
<|begin▁of▁sentence|>{system prompt}{tool_description}<|User|>{query}<|Assistant|></think>
工具描述的位置
## Tools
You have access to the following tools:
### {tool_name1}
Description: {description}
Parameters: {json.dumps(parameters)}
IMPORTANT: ALWAYS adhere to this exact format for tool use:
tool_call_nametool_call_arguments{{additional_tool_calls}}
Where:
- `tool_call_name` must be an exact match to one of the available tools
- `tool_call_arguments` must be valid JSON that strictly follows the tool's Parameters Schema
- For multiple tool calls, chain them directly without separators or spaces
代码代理
我们支持多种代码代理框架。请参考上述工具调用格式来创建您自己的代码代理。示例参见assets/code_agent_trajectory.html
文件。
搜索代理
我们为思维模式下的搜索工具调用设计了特定格式,以支持搜索代理功能。
对于需要获取外部或最新信息的复杂问题,DeepSeek-V3.1可通过多轮工具调用流程,利用用户提供的搜索工具进行查询。
具体模板请查看assets/search_tool_trajectory.html
和assets/search_python_tool_trajectory.html
文件。
评估说明
Category | Benchmark (Metric) | DeepSeek V3.1-NonThinking | DeepSeek V3 0324 | DeepSeek V3.1-Thinking | DeepSeek R1 0528 |
---|---|---|---|---|---|
General | |||||
MMLU-Redux (EM) | 91.8 | 90.5 | 93.7 | 93.4 | |
MMLU-Pro (EM) | 83.7 | 81.2 | 84.8 | 85.0 | |
GPQA-Diamond (Pass@1) | 74.9 | 68.4 | 80.1 | 81.0 | |
Humanity’s Last Exam (Pass@1) | - | - | 15.9 | 17.7 | |
Search Agent | |||||
BrowseComp | - | - | 30.0 | 8.9 | |
BrowseComp_zh | - | - | 49.2 | 35.7 | |
Humanity’s Last Exam (Python + Search) | - | - | 29.8 | 24.8 | |
SimpleQA | - | - | 93.4 | 92.3 | |
Code | |||||
LiveCodeBench (2408-2505) (Pass@1) | 56.4 | 43.0 | 74.8 | 73.3 | |
Codeforces-Div1 (Rating) | - | - | 2091 | 1930 | |
Aider-Polyglot (Acc.) | 68.4 | 55.1 | 76.3 | 71.6 | |
Code Agent | |||||
SWE Verified (Agent mode) | 66.0 | 45.4 | - | 44.6 | |
SWE-bench Multilingual (Agent mode) | 54.5 | 29.3 | - | 30.5 | |
Terminal-bench (Terminus 1 framework) | 31.3 | 13.3 | - | 5.7 | |
Math | |||||
AIME 2024 (Pass@1) | 66.3 | 59.4 | 93.1 | 91.4 | |
AIME 2025 (Pass@1) | 49.8 | 51.3 | 88.4 | 87.5 | |
HMMT 2025 (Pass@1) | 33.5 | 29.2 | 84.2 | 79.4 |
注:
搜索代理使用我们的内部搜索框架进行评估,该框架采用商业搜索API+网页过滤器+128K上下文窗口。R1-0528版本的搜索代理结果通过预定义工作流进行评估。
SWE-bench测试基于我们的内部代码代理框架进行评估。
HLE测试仅使用纯文本子集进行评估。
使用示例
import transformers
tokenizer = transformers.AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-V3.1")
messages = [
{
"role": "system", "content": "You are a helpful assistant"
},
{
"role": "user", "content": "Who are you?"
},
{
"role": "assistant", "content": "<think>Hmm</think>I am DeepSeek"
},
{
"role": "user", "content": "1+1=?"
}
]
tokenizer.apply_chat_template(messages, tokenize=False, thinking=True, add_generation_prompt=True)
# '<|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>'
tokenizer.apply_chat_template(messages, tokenize=False, thinking=False, add_generation_prompt=True)
# '<|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>'
如何本地运行
DeepSeek-V3.1 的模型结构与 DeepSeek-V3 相同。如需了解如何在本地运行此模型,请访问 DeepSeek-V3 代码库。
许可证
本代码库及模型权重均采用 MIT 许可证 授权。