HuggingFace镜像/DeepSeek-V3.1
模型介绍模型推理文件和版本分析
下载使用量0

DeepSeek-V3.1

DeepSeek-V3

Homepage Chat Hugging Face
Discord Wechat Twitter Follow
License

简介

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 倍,达到 6300 亿 tokens;128K 扩展阶段的训练数据量扩展了 3.3 倍,达到 2090 亿 tokens。

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

模型下载

模型总参数量激活参数量上下文长度下载链接
DeepSeek-V3.1-Base6710 亿370 亿128KHuggingFace | ModelScope
DeepSeek-V3.16710 亿370 亿128KHuggingFace | ModelScope

对话模板

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

非思考模式

首轮对话

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

借助给定的前缀,DeepSeek V3.1 能够以非思考模式对查询生成响应。与 DeepSeek V3 不同,该版本新增了一个额外的标记 </think>。

多轮对话

上下文: <|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:

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

思考模式

首轮对话

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

思考模式的前缀与 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> 会保留在上下文中的每一轮对话里。

工具调用(ToolCall)

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

<|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(Rating)--20911930
Aider-Polyglot(准确率)68.455.176.371.6
代码智能体
SWE Verified(智能体模式)66.045.4-44.6
SWE-bench Multilingual(智能体模式)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 与我们联系。