DeepSeek-R1 官方 使用指南

1,030 阅读12分钟

DeepSeek-R1

1. 简介

我们介绍了第一代推理模型 DeepSeek-R1-Zero 和 DeepSeek-R1。 DeepSeek-R1-Zero 是一种通过大规模强化学习 (RL) 训练的模型,不需要监督微调 (SFT) 作为初步步骤,在推理方面表现出色。

在 RL 的帮助下,DeepSeek-R1-Zero 自然而然地表现出许多强大而有趣的推理行为。不过,DeepSeek-R1-Zero 也面临着无休止重复、可读性差和语言混合等挑战。

为了解决这些问题并进一步提高推理性能,我们引入了 DeepSeek-R1,它在 RL 之前整合了冷启动数据。DeepSeek-R1 在数学、代码和推理任务中实现了与 OpenAI-o1 相当的表现。

为了支持研究社区,我们开源了 DeepSeek-R1-Zero、DeepSeek-R1 以及基于 Llama 和 Qwen 从 DeepSeek-R1 提炼出的六个密集模型。DeepSeek-R1-Distill-Qwen-32B 在各种基准测试中均超过了 OpenAI-o1-mini,取得了密集模型的新最先进成果。

2. 模型摘要


训练后:基础模型上的大规模强化学习

  • 我们直接将强化学习 (RL) 应用于基础模型,而无需依赖监督微调 (SFT) 作为初步步骤。这种方法允许模型探索解决复杂问题的思路 (CoT),从而开发出 DeepSeek-R1-Zero。DeepSeek-R1-Zero 展示了自我验证、反思和生成长 CoT 等功能,标志着研究界的一个重要里程碑。值得注意的是,这是第一个公开研究,验证了 LLM 的推理能力可以纯粹通过 RL 来激励,而无需 SFT。这一突破为该领域的未来发展铺平了道路。

  • 我们引入了用于开发 DeepSeek-R1 的流水线。该流水线包含两个 RL 阶段,旨在发现改进的推理模式并与人类偏好保持一致,以及两个 SFT 阶段,作为模型推理和非推理能力的种子。我们相信该流水线将通过创建更好的模型使行业受益。


提炼:小模型同样强大

  • 我们证明了较大模型的推理模式可以提炼为较小的模型,从而获得比通过强化学习在小型模型上发现的推理模式更好的性能。开源的 DeepSeek-R1 及其 API 将有利于研究界在未来提炼出更好的小型模型。
  • 利用 DeepSeek-R1 生成的推理数据,我们对研究社区中广泛使用的多个稠密模型进行了微调。评估结果表明,经过提炼的较小稠密模型在基准测试中表现优异。我们向社区开源了基于 Qwen2.5 和 Llama3 系列的 1.5B、7B、8B、14B、32B 和 70B 检查点。

3. 模型下载

DeepSeek-R1 模型

DeepSeek-R1-Zero 和 DeepSeek-R1 基于 DeepSeek-V3-Base 进行训练。有关模型架构的更多详细信息,请参阅DeepSeek-V3存储库。

DeepSeek-R1-Distill 模型

DeepSeek-R1-Distill 模型基于开源模型进行了微调,使用了 DeepSeek-R1 生成的样本。我们对其配置和分词器进行了轻微更改。请使用我们的设置来运行这些模型。

4.评估结果

DeepSeek-R1-评估

对于我们所有的模型,最大生成长度设置为 32,768 个 token。对于需要采样的基准,我们使用的温度为 0.6 ,top-p 值为 0.95 ,并为每个查询生成 64 个响应来估计 pass@1。

CategoryBenchmark (Metric)Claude-3.5-Sonnet-1022GPT-4o 0513DeepSeek V3OpenAI o1-miniOpenAI o1-1217DeepSeek R1
Architecture--MoE--MoE
# Activated Params--37B--37B
# Total Params--671B--671B
EnglishMMLU (Pass@1)88.387.288.585.291.890.8
MMLU-Redux (EM)88.988.089.186.7-92.9
MMLU-Pro (EM)78.072.675.980.3-84.0
DROP (3-shot F1)88.383.791.683.990.292.2
IF-Eval (Prompt Strict)86.584.386.184.8-83.3
GPQA-Diamond (Pass@1)65.049.959.160.075.771.5
SimpleQA (Correct)28.438.224.97.047.030.1
FRAMES (Acc.)72.580.573.376.9-82.5
AlpacaEval2.0 (LC-winrate)52.051.170.057.8-87.6
ArenaHard (GPT-4-1106)85.280.485.592.0-92.3
CodeLiveCodeBench (Pass@1-COT)33.834.2-53.863.465.9
Codeforces (Percentile)20.323.658.793.496.696.3
Codeforces (Rating)7177591134182020612029
SWE Verified (Resolved)50.838.842.041.648.949.2
Aider-Polyglot (Acc.)45.316.049.632.961.753.3
MathAIME 2024 (Pass@1)16.09.339.263.679.279.8
MATH-500 (Pass@1)78.374.690.290.096.497.3
CNMO 2024 (Pass@1)13.110.843.267.6-78.8
ChineseCLUEWSC (EM)85.487.990.989.9-92.8
C-Eval (EM)76.776.086.568.9-91.8
C-SimpleQA (Correct)55.458.768.040.3-63.7

Distilled Model Evaluation

ModelAIME 2024 pass@1AIME 2024 cons@64MATH-500 pass@1GPQA Diamond pass@1LiveCodeBench pass@1CodeForces rating
GPT-4o-05139.313.474.649.932.9759
Claude-3.5-Sonnet-102216.026.778.365.038.9717
o1-mini63.680.090.060.053.81820
QwQ-32B-Preview44.060.090.654.541.91316
DeepSeek-R1-Distill-Qwen-1.5B28.952.783.933.816.9954
DeepSeek-R1-Distill-Qwen-7B55.583.392.849.137.61189
DeepSeek-R1-Distill-Qwen-14B69.780.093.959.153.11481
DeepSeek-R1-Distill-Qwen-32B72.683.394.362.157.21691
DeepSeek-R1-Distill-Llama-8B50.480.089.149.039.61205
DeepSeek-R1-Distill-Llama-70B70.086.794.565.257.51633

5. 聊天网站和 API 平台

您可以在DeepSeek官方网站chat.deepseek.com上与DeepSeek-R1聊天,并打开“DeepThink”按钮

我们还在 DeepSeek 平台上提供与 OpenAI 兼容的 API:platform.deepseek.com

6. 如何在本地运行

DeepSeek-R1 模型

有关在本地运行 DeepSeek-R1 的更多信息,请访问DeepSeek-V3 repo。

注意:Hugging Face 的 Transformers 尚未直接得到支持。

DeepSeek-R1-Distill 模型

DeepSeek-R1-Distill 模型可以以与 Qwen 或 Llama 模型相同的方式使用。

例如,您可以使用vLLM轻松启动服务:

vllm serve deepseek-ai/DeepSeek-R1-Distill-Qwen-32B --tensor-parallel-size 2 --max-model-len 32768 --enforce-eager

您还可以使用SGLang轻松启动服务

python3 -m sglang.launch_server --model deepseek-ai/DeepSeek-R1-Distill-Qwen-32B --trust-remote-code --tp 2

使用建议

我们建议在使用 DeepSeek-R1 系列模型(包括基准测试)时遵循以下配置,以实现预期性能:

  1. 将温度设置在 0.5-0.7 范围内(建议为 0.6),以防止无休止的重复或不连贯的输出。
  2. 避免添加系统提示;所有说明都应包含在用户提示中。
  3. 对于数学问题,建议在提示中包含一个指令,例如:“请逐步推理,并将您的最终答案放在 \boxed{} 内。”
  4. 在评估模型性能时,建议进行多次测试并取平均值。

image.png

官方提示

在DeepSeek官方网页/app中,我们没有使用系统提示,而是设计了两个专门的提示,用于文件上传和网页搜索,以提升用户体验。另外,网页/app中的温度为0.6。

对于文件上传,请按照模板创建提示,其中 {file_name}、{file_content} 和 {question} 是参数。

file_template = \
"""[file name]: {file_name}
[file content begin]
{file_content}
[file content end]
{question}"""

对于 Web 搜索,{search_results}、{cur_data} 和 {question} 是参数。

对于中文查询,我们使用提示:


search_answer_zh_template = \
'''# 以下内容是基于用户发送的消息的搜索结果:
{search_results}
在我给你的搜索结果中,每个结果都是[webpage X begin]...[webpage X end]格式的,X代表每篇文章的数字索引。请在适当的情况下在句子末尾引用上下文。请按照引用编号[citation:X]的格式在答案中对应部分引用上下文。如果一句话源自多个上下文,请列出所有相关的引用编号,例如[citation:3][citation:5],切记不要将引用集中在最后返回引用编号,而是在答案对应部分列出。
在回答时,请注意以下几点:
- 今天是{cur_date}。
- 并非搜索结果的所有内容都与用户的问题密切相关,你需要结合问题,对搜索结果进行甄别、筛选。
- 对于列举类的问题(如列举所有航班信息),尽量将答案控制在10个要点以内,并告诉用户可以查看搜索来源、获得完整信息。优先提供信息完整、最相关的列举项;如非必要,不要主动告诉用户搜索结果未提供的内容。
- 对于创作类的问题(如写论文),请务必在正文的段落中引用对应的参考编号,例如[citation:3][citation:5],不能只在文章末尾引用。你需要解读并概括用户的题目要求,选择合适的格式,充分利用搜索结果并抽取重要信息,生成符合用户要求、极具思想深度、富有创造力与专业性的答案。你的创作篇幅需要尽可能延长,对于每一个要点的论述要推测用户的意图,给出尽可能多角度的回答要点,且务必信息量大、论述详尽。
- 如果回答很长,请尽量结构化、分段落总结。如果需要分点作答,尽量控制在5个点以内,并合并相关的内容。
- 对于客观类的问答,如果问题的答案非常简短,可以适当补充一到两句相关信息,以丰富内容。
- 你需要根据用户要求和回答内容选择合适、美观的回答格式,确保可读性强。
- 你的回答应该综合多个相关网页来回答,不能重复引用一个网页。
- 除非用户要求,否则你回答的语言需要和用户提问的语言保持一致。

# 用户消息为:
{question}'''

对于英语查询,我们使用提示:

search_answer_en_template = \
'''# The following contents are the search results related to the user's message:
{search_results}
In the search results I provide to you, each result is formatted as [webpage X begin]...[webpage X end], where X represents the numerical index of each article. Please cite the context at the end of the relevant sentence when appropriate. Use the citation format [citation:X] in the corresponding part of your answer. If a sentence is derived from multiple contexts, list all relevant citation numbers, such as [citation:3][citation:5]. Be sure not to cluster all citations at the end; instead, include them in the corresponding parts of the answer.
When responding, please keep the following points in mind:
- Today is {cur_date}.
- Not all content in the search results is closely related to the user's question. You need to evaluate and filter the search results based on the question.
- For listing-type questions (e.g., listing all flight information), try to limit the answer to 10 key points and inform the user that they can refer to the search sources for complete information. Prioritize providing the most complete and relevant items in the list. Avoid mentioning content not provided in the search results unless necessary.
- For creative tasks (e.g., writing an essay), ensure that references are cited within the body of the text, such as [citation:3][citation:5], rather than only at the end of the text. You need to interpret and summarize the user's requirements, choose an appropriate format, fully utilize the search results, extract key information, and generate an answer that is insightful, creative, and professional. Extend the length of your response as much as possible, addressing each point in detail and from multiple perspectives, ensuring the content is rich and thorough.
- If the response is lengthy, structure it well and summarize it in paragraphs. If a point-by-point format is needed, try to limit it to 5 points and merge related content.
- For objective Q&A, if the answer is very brief, you may add one or two related sentences to enrich the content.
- Choose an appropriate and visually appealing format for your response based on the user's requirements and the content of the answer, ensuring strong readability.
- Your answer should synthesize information from multiple relevant webpages and avoid repeatedly citing the same webpage.
- Unless the user requests otherwise, your response should be in the same language as the user's question.

# The user's message is:
{question}'''

7. 许可

本代码库和模型权重遵循MIT 许可协议。DeepSeek-R1 系列支持商业使用,允许任何修改和衍生作品,包括但不限于用于训练其他 LLM 的蒸馏。请注意:

  • DeepSeek-R1-Distill-Qwen-1.5B、DeepSeek-R1-Distill-Qwen-7B、DeepSeek-R1-Distill-Qwen-14B 和 DeepSeek-R1-Distill-Qwen-32B 源自Qwen-2.5 系列,最初获得Apache 2.0 许可,现已使用 DeepSeek-R1 精选的 800k 个样本进行了微调。
  • DeepSeek-R1-Distill-Llama-8B 源自 Llama3.1-8B-Base,最初获得llama3.1 许可
  • DeepSeek-R1-Distill-Llama-70B 源自 Llama3.3-70B-Instruct,最初获得llama3.3 许可

8. 引用

@misc{deepseekai2025deepseekr1incentivizingreasoningcapability,
      title={DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning}, 
      author={DeepSeek-AI and Daya Guo and Dejian Yang and Haowei Zhang and Junxiao Song and Ruoyu Zhang and Runxin Xu and Qihao Zhu and Shirong Ma and Peiyi Wang and Xiao Bi and Xiaokang Zhang and Xingkai Yu and Yu Wu and Z. F. Wu and Zhibin Gou and Zhihong Shao and Zhuoshu Li and Ziyi Gao and Aixin Liu and Bing Xue and Bingxuan Wang and Bochao Wu and Bei Feng and Chengda Lu and Chenggang Zhao and Chengqi Deng and Chenyu Zhang and Chong Ruan and Damai Dai and Deli Chen and Dongjie Ji and Erhang Li and Fangyun Lin and Fucong Dai and Fuli Luo and Guangbo Hao and Guanting Chen and Guowei Li and H. Zhang and Han Bao and Hanwei Xu and Haocheng Wang and Honghui Ding and Huajian Xin and Huazuo Gao and Hui Qu and Hui Li and Jianzhong Guo and Jiashi Li and Jiawei Wang and Jingchang Chen and Jingyang Yuan and Junjie Qiu and Junlong Li and J. L. Cai and Jiaqi Ni and Jian Liang and Jin Chen and Kai Dong and Kai Hu and Kaige Gao and Kang Guan and Kexin Huang and Kuai Yu and Lean Wang and Lecong Zhang and Liang Zhao and Litong Wang and Liyue Zhang and Lei Xu and Leyi Xia and Mingchuan Zhang and Minghua Zhang and Minghui Tang and Meng Li and Miaojun Wang and Mingming Li and Ning Tian and Panpan Huang and Peng Zhang and Qiancheng Wang and Qinyu Chen and Qiushi Du and Ruiqi Ge and Ruisong Zhang and Ruizhe Pan and Runji Wang and R. J. Chen and R. L. Jin and Ruyi Chen and Shanghao Lu and Shangyan Zhou and Shanhuang Chen and Shengfeng Ye and Shiyu Wang and Shuiping Yu and Shunfeng Zhou and Shuting Pan and S. S. Li and Shuang Zhou and Shaoqing Wu and Shengfeng Ye and Tao Yun and Tian Pei and Tianyu Sun and T. Wang and Wangding Zeng and Wanjia Zhao and Wen Liu and Wenfeng Liang and Wenjun Gao and Wenqin Yu and Wentao Zhang and W. L. Xiao and Wei An and Xiaodong Liu and Xiaohan Wang and Xiaokang Chen and Xiaotao Nie and Xin Cheng and Xin Liu and Xin Xie and Xingchao Liu and Xinyu Yang and Xinyuan Li and Xuecheng Su and Xuheng Lin and X. Q. Li and Xiangyue Jin and Xiaojin Shen and Xiaosha Chen and Xiaowen Sun and Xiaoxiang Wang and Xinnan Song and Xinyi Zhou and Xianzu Wang and Xinxia Shan and Y. K. Li and Y. Q. Wang and Y. X. Wei and Yang Zhang and Yanhong Xu and Yao Li and Yao Zhao and Yaofeng Sun and Yaohui Wang and Yi Yu and Yichao Zhang and Yifan Shi and Yiliang Xiong and Ying He and Yishi Piao and Yisong Wang and Yixuan Tan and Yiyang Ma and Yiyuan Liu and Yongqiang Guo and Yuan Ou and Yuduan Wang and Yue Gong and Yuheng Zou and Yujia He and Yunfan Xiong and Yuxiang Luo and Yuxiang You and Yuxuan Liu and Yuyang Zhou and Y. X. Zhu and Yanhong Xu and Yanping Huang and Yaohui Li and Yi Zheng and Yuchen Zhu and Yunxian Ma and Ying Tang and Yukun Zha and Yuting Yan and Z. Z. Ren and Zehui Ren and Zhangli Sha and Zhe Fu and Zhean Xu and Zhenda Xie and Zhengyan Zhang and Zhewen Hao and Zhicheng Ma and Zhigang Yan and Zhiyu Wu and Zihui Gu and Zijia Zhu and Zijun Liu and Zilin Li and Ziwei Xie and Ziyang Song and Zizheng Pan and Zhen Huang and Zhipeng Xu and Zhongyu Zhang and Zhen Zhang},
      year={2025},
      eprint={2501.12948},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2501.12948}, 
}


9. 联系方式

如果您有任何疑问,请提出问题或通过service@deepseek.com联系我们。