
新智元报道
新智元报道
【新智元导读】DeepSeek官方发布的R1模型部署指南来了!留言区纷纷高呼:「服务器繁忙」问题何时解决?同一天内,OpenAI的推理模型指南也发布了,特点就是字数很多。
-
不使用系统提示 -
采样温度:0.6 -
针对文件上传和网络搜索功能定制prompt -
每次输出时都以<think>\n开始,以防模型跳过思考过程



DeepSeek:手把手教你正确用上官方同款
```
file_template = \
"""[file name]: {file_name}
[file content begin]
{file_content}
[file content end]
{question}"""
```
对于网络搜索功能,则包含 {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}'''
```
第四点:别让模型绕过思考 DeepSeek发现,DeepSeek-R1系列模型在回应某些查询时,可能会跳过思考过程(即直接输出空的思考标签「<think>\n\n</think>」),这会影响模型的推理性能。 为确保模型进行完整的推理过程,官方建议:强制要求模型在每次输出时都以思考标签「<think>\n」开始。 OpenAI:推理模型的最佳实践
在这边,OpenAI也放出使用o系列模型的最佳实践指南。 推理模型与GPT模型
OpenAI介绍道,与GPT模型相比,o系列模型在不同任务上表现出色,且需要使用不同的提示。 这两类模型没有优劣之分——它们各有所长。 o系列模型更像是一个「规划者」,能深入思考复杂任务;相比之下,GPT模型则是一个「执行者」,能直接执行任务,延迟低、性价比更高。 在不同情况下,具体选择哪个模型,推荐如下。
-
速度和成本:选择GPT模型,因为它们处理速度更快,成本更低
-
执行明确任务:选择GPT模型,它们在处理界定清晰的任务时表现出色
-
准确性和可靠性:选择o系列模型,它们是可靠的决策专家
-
复杂问题解决:选择o系列模型,它们善于处理模糊和复杂的问题

何时使用推理模型
如何编写推理模型的prompt
-
推理模型就像一位经验丰富的高级同事——你只需告诉他们最终目标,就能相信他们自主完成所有细节工作。 -
GPT模型则更像一位新手同事——你需要提供明确详细的指示,才能让他们准确完成特定的输出任务。
-
用开发者消息取代系统消息:自o1-2024-12-17版本起,推理模型开始支持开发者消息(developer message)而非系统消息(system message)。 -
保持提示词简洁明确:推理模型最擅长理解和响应简短、清晰的指令。 -
避免使用CoT提示:由于模型内置推理能力,因此无需特别提示它们「一步一步思考」或「解释推理过程」。 -
善用分隔符增强清晰度:使用Markdown、XML标签和章节标题等分隔符来明确区分输入的不同部分,这有助于模型准确理解各个章节的内容。 -
优先尝试零样本学习:推理模型通常无需少样本示例即可产出优质结果,因此建议先尝试不含示例的提示词。如果对输出结果有更复杂的要求,再考虑在提示词中添加输入和期望输出的示例。请注意确保示例与提示词指令严格匹配,因为不一致可能导致性能下降。 -
提供明确约束条件:如果需要对模型的响应施加具体限制(例如「提供预算控制在500美元以内的解决方案」),请在提示词中明确列出这些约束条件。 -
明确定义目标:在指令中,请详细说明判定响应成功的具体参数,并引导模型持续优化推理过程,直到达成设定的成功标准。 -
Markdown格式说明:从o1-2024-12-17版本开始,API中的推理模型默认不会生成带有Markdown格式的响应。如果确实需要在响应中包含Markdown格式,请在开发者消息的首行添加「Formatting re-enabled」字符串。
左右滑动查看
推理工作原理

(文:新智元)