d
deepseek-ai/DeepSeek-V3.1-Base
模型介绍模型推理文件和版本分析
下载使用量0

DeepSeek-V3.1

DeepSeek-V3

官网 聊天 Hugging Face
Discord 微信 Twitter 关注
许可证

简介

DeepSeek-V3.1 是一款支持思考模式与非思考模式的混合模型。相较于上一版本,本次升级在多个方面带来了改进:

  • 混合思考模式:通过切换对话模板,单一模型即可同时支持思考模式与非思考模式。

  • 更智能的工具调用:经过训练后优化,模型在工具使用和智能体任务中的表现得到显著提升。

  • 更高的思考效率:DeepSeek-V3.1-Think 达到了与 DeepSeek-R1-0528 相当的回答质量,同时响应速度更快。

DeepSeek-V3.1 是在 DeepSeek-V3.1-Base 的基础上进行训练后优化得到的。DeepSeek-V3.1-Base 则是在原始 V3 基础模型 checkpoint 之上,遵循原始 DeepSeek-V3 报告中概述的方法,通过两阶段长上下文扩展方案构建而成。我们通过收集额外的长文档并大幅扩展两个训练阶段来扩充数据集。32K 扩展阶段的训练量增加了 10 倍,达到 630B tokens,而 128K 扩展阶段的训练量则扩展了 3.3 倍,达到 209B tokens。

此外,DeepSeek-V3.1 在训练时,模型权重和激活值均采用 UE8M0 FP8 数据格式,以确保与微缩放数据格式的兼容性。更多详情请参考 DeepGEMM。

模型下载

模型总参数量激活参数量上下文长度下载链接
DeepSeek-V3.1-Base671B37B128KHuggingFace | ModelScope
DeepSeek-V3.1671B37B128KHuggingFace | ModelScope

对话模板

对话模板的详细信息描述于 tokenizer_config.json 和 assets/chat_template.jinja 文件中。以下是简要说明。

非思考模式

首轮对话

前缀: <|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|></think>

在给定前缀的情况下,DeepSeek V3.1 以非思考模式生成查询回复。与 DeepSeek V3 不同,它新增了一个额外的标记 <RichMediaReference>。

多轮对话

上下文: <|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|></think>{response}<|end▁of▁sentence|>...<|User|>{query}<|Assistant|>superscript:{response}<|end▁of▁sentence|>

前缀: <|User|>{query}<|Assistant|></think>

通过将上下文与前缀拼接,即可得到该查询的正确提示词。

思考模式

首轮对话

前缀: <|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|>superscript:

思考模式的前缀与 DeepSeek-R1 类似。

多轮对话

上下文: <|begin▁of▁sentence|>{system prompt}<|User|>{query}<|Assistant|>superscript:{response}<|end▁of▁sentence|>...<|User|>{query}<|Assistant|>superscript:{response}<|end▁of▁sentence|>

前缀: <|User|>{query}<|Assistant|>superscript:

多轮对话模板与非思考模式的多轮对话模板相同。这意味着上一轮中的思考标记会被去除,但上下文中的每一轮均保留 </think> 标记。

工具调用

非思考模式支持工具调用功能。其格式如下:

<|begin▁of▁sentence|>{system prompt}\n\n{tool_description}<|User|>{query}<|Assistant|>superscript:,其中工具描述(tool_description)为

## 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▁calls▁begin|><|tool▁call▁begin|>tool_call_name<|tool▁sep|>tool_call_arguments<|tool▁call▁end|>{additional_tool_calls}<|tool▁calls▁end|>

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

代码智能体(Code-Agent)

我们支持多种代码智能体框架。请参考上述工具调用格式创建您自己的代码智能体。示例可参见assets/code_agent_trajectory.html。

搜索智能体(Search-Agent)

我们为思考模式下的搜索工具调用设计了特定格式,以支持搜索智能体。

对于需要访问外部信息或最新信息的复杂问题,DeepSeek-V3.1 能够通过多轮工具调用流程,利用用户提供的搜索工具。

详细模板请参考assets/search_tool_trajectory.html和assets/search_python_tool_trajectory.html。

评估

类别基准测试(指标)DeepSeek V3.1-NonThinkingDeepSeek V3 0324DeepSeek V3.1-ThinkingDeepSeek R1 0528
通用
MMLU-Redux(精确匹配)91.890.593.793.4
MMLU-Pro(精确匹配)83.781.284.885.0
GPQA-Diamond(Pass@1)74.968.480.181.0
Humanity's Last Exam(Pass@1)--15.917.7
搜索智能体
BrowseComp--30.08.9
BrowseComp_zh--49.235.7
Humanity's Last Exam(Python + 搜索)--29.824.8
SimpleQA--93.492.3
代码
LiveCodeBench(2408-2505)(Pass@1)56.443.074.873.3
Codeforces-Div1(评分)--20911930
Aider-Polyglot(准确率)68.455.176.371.6
代码智能体
SWE Verified(智能体模式)66.045.4-44.6
SWE-bench 多语言(智能体模式)54.529.3-30.5
Terminal-bench(Terminus 1 框架)31.313.3-5.7
数学
AIME 2024(Pass@1)66.359.493.191.4
AIME 2025(Pass@1)49.851.388.487.5
HMMT 2025(Pass@1)33.529.284.279.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 代码库。

使用建议:

  1. mlp.gate.e_score_correction_bias 参数应使用 FP32 精度加载和计算。
  2. 确保 FP8 模型权重和激活值采用 UE8M0 尺度格式。

许可证

本代码库和模型权重采用 MIT 许可证 授权。

引用

@misc{deepseekai2024deepseekv3technicalreport,
      title={DeepSeek-V3 Technical Report}, 
      author={DeepSeek-AI},
      year={2024},
      eprint={2412.19437},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2412.19437}, 
}

联系方式

若您有任何疑问,请提交 issue 或通过邮箱 service@deepseek.com 与我们联系。