This guide shares strategies and tactics for getting better results from large language models (sometimes referred to as GPT models) like GPT-4o. The methods described here can sometimes be deployed in combination for greater effect. We encourage experimentation to find the methods that work best for you.
这个指南分享了从大型语言模型(有时被称为 GPT 模型)如 GPT-4o 获得更好结果的策略和策略。这里描述的方法有时可以组合使用以达到更好的效果。我们鼓励您进行实验以找到最适合您的方法。
You can also explore example prompts which showcase what our models are capable of:
你还可以探索示例提示,这些示例展示了我们的模型的能力:
Explore prompt examples to learn what GPT models can do
探索提示示例以了解 GPT 模型的功能
These models can’t read your mind. If outputs are too long, ask for brief replies. If outputs are too simple, ask for expert-level writing. If you dislike the format, demonstrate the format you’d like to see. The less the model has to guess at what you want, the more likely you’ll get it.
这些模型无法读懂你的想法。如果输出太长,请求简短回复。如果输出过于简单,要求专家级写作。如果你不喜欢格式,请示范你想要的格式。模型猜测你想要什么越少,你就越有可能得到想要的。
Tactics: 战术:
- Include details in your query to get more relevant answers
包括在您的查询中详细信息,以获得更相关的答复 - Ask the model to adopt a persona
让模型采用一个角色 - Use delimiters to clearly indicate distinct parts of the input
使用分隔符清楚地指示输入的不同部分 - Specify the steps required to complete a task
完成任务所需的步骤 - Provide examples 提供例子
- Specify the desired length of the output
指定所需的输出长度
Language models can confidently invent fake answers, especially when asked about esoteric topics or for citations and URLs. In the same way that a sheet of notes can help a student do better on a test, providing reference text to these models can help in answering with fewer fabrications.
语言模型可以自信地编造虚假答案,尤其是在被询问关于深奥主题或需要引用和网址时。就像笔记可以帮助学生在考试中表现更好一样,为这些模型提供参考文本也可以帮助减少编造的内容。
Tactics: 战术:
- Instruct the model to answer using a reference text
让模型使用参考文本来回答 - Instruct the model to answer with citations from a reference text
根据参考文本提供答复
Just as it is good practice in software engineering to decompose a complex system into a set of modular components, the same is true of tasks submitted to a language model. Complex tasks tend to have higher error rates than simpler tasks. Furthermore, complex tasks can often be re-defined as a workflow of simpler tasks in which the outputs of earlier tasks are used to construct the inputs to later tasks.
正如在软件工程中将复杂系统分解为一组模块化组件是一种良好实践,同样适用于提交给语言模型的任务。复杂任务的错误率通常高于简单任务。此外,复杂任务通常可以重新定义为一系列简单任务的工作流,其中前一任务的输出用于构建后一任务的输入。
Tactics: 战术:
- Use intent classification to identify the most relevant instructions for a user query
使用意图分类来识别用户查询的最相关说明 - For dialogue applications that require very long conversations, summarize or filter previous dialogue
用于需要非常长对话的对话应用程序,请总结或过滤先前的对话内容 - Summarize long documents piecewise and construct a full summary recursively
分段总结长篇文档,并递归构建完整的摘要
If asked to multiply 17 by 28, you might not know it instantly, but can still work it out with time. Similarly, models make more reasoning errors when trying to answer right away, rather than taking time to work out an answer. Asking for a "chain of thought" before an answer can help the model reason its way toward correct answers more reliably.
如果要求您乘以 17 和 28,您可能无法立即知道答案,但仍可以花时间计算出来。类似地,当模型试图立即回答而不是花时间计算答案时,它会做出更多的推理错误。在得出答案之前要求"思维过程"可以更可靠地帮助模型推演出正确的答案。
Tactics: 战术:
- Instruct the model to work out its own solution before rushing to a conclusion
在下定结论前,指导模型自己找出解决方案 - Use inner monologue or a sequence of queries to hide the model's reasoning process
使用内部独白或一系列询问来隐藏模型的推理过程 - Ask the model if it missed anything on previous passes
问模型是否在先前的尝试中遗漏了任何内容
Compensate for the weaknesses of the model by feeding it the outputs of other tools. For example, a text retrieval system (sometimes called RAG or retrieval augmented generation) can tell the model about relevant documents. A code execution engine like OpenAI's Code Interpreter can help the model do math and run code. If a task can be done more reliably or efficiently by a tool rather than by a language model, offload it to get the best of both.
通过为模型提供其他工具的输出来弥补模型的缺陷。例如,文本检索系统(有时称为 RAG 或检索增强型生成)可以告诉模型相关文档。像 OpenAI 的 Code Interpreter 这样的代码执行引擎可以帮助模型进行数学计算和运行代码。如果某项任务可以由工具更可靠或高效地完成,而不是由语言模型来完成,那就将其外包出去,以获得最佳效果。
Tactics: 战术:
- Use embeddings-based search to implement efficient knowledge retrieval
使用基于嵌入的搜索实现高效的知识检索 - Use code execution to perform more accurate calculations or call external APIs
使用代码执行来进行更精确的计算或调用外部 API - Give the model access to specific functions
给模型访问特定功能
Improving performance is easier if you can measure it. In some cases a modification to a prompt will achieve better performance on a few isolated examples but lead to worse overall performance on a more representative set of examples. Therefore to be sure that a change is net positive to performance it may be necessary to define a comprehensive test suite (also known an as an "eval").
如果您能够衡量性能,那么提高性能就更容易。在某些情况下,对提示的修改可以在少数孤立的示例中获得更好的性能,但会导致在更具代表性的示例集上出现更差的整体性能。因此,要确保变更对性能是整体积极的,可能需要定义一个全面的测试套件(也称为"评估")。
Tactic: 战术:
Each of the strategies listed above can be instantiated with specific tactics. These tactics are meant to provide ideas for things to try. They are by no means fully comprehensive, and you should feel free to try creative ideas not represented here.
上述列出的每一种策略都可以通过具体的策战来实施。这些策战旨在提供一些可尝试的想法。它们绝不是全面的,您也应该尝试在此没有体现的创意想法。
In order to get a highly relevant response, make sure that requests provide any important details or context. Otherwise you are leaving it up to the model to guess what you mean.
为了获得高度相关的响应,请确保请求提供任何重要的细节或背景。否则,您将让模型去猜测您的意思。
Worse 更糟 | Better 更好 |
How do I add numbers in Excel? 如何在 Excel 中添加数字? | How do I add up a row of dollar amounts in Excel? I want to do this automatically for a whole sheet of rows with all the totals ending up on the right in a column called "Total". 如何在 Excel 中自动求一行的美元金额总和?我希望能为整个表单的所有行自动完成此操作,所有总和将出现在右侧的一列中,列名为"总计"。 |
Who’s president? 谁是总统? | Who was the president of Mexico in 2021, and how frequently are elections held? 2021 年墨西哥的总统是谁,总统选举的频率是多少? |
Write code to calculate the Fibonacci sequence. 编写代码计算斐波那契数列。 | Write a TypeScript function to efficiently calculate the Fibonacci sequence. Comment the code liberally to explain what each piece does and why it's written that way. 写一个 TypeScript 函数高效地计算斐波那契数列。在代码中添加大量注释来解释每个部分的作用以及它们是如何编写的。 |
Summarize the meeting notes. 总结会议记录。 | Summarize the meeting notes in a single paragraph. Then write a markdown list of the speakers and each of their key points. Finally, list the next steps or action items suggested by the speakers, if any. 会议纪要概括为一个段落。接着以 Markdown 格式列出演讲者及其关键观点。最后列出演讲者提出的后续步骤或行动项目(如有)。 - 演讲者 1: - 关键观点 1 - 关键观点 2 - 演讲者 2: - 关键观点 1 - 关键观点 2 - 后续步骤或行动项目: - 步骤 1 - 步骤 2 |
The system message can be used to specify the persona used by the model in its replies.
系统消息可用于指定模型在其回复中使用的角色。
Delimiters like triple quotation marks, XML tags, section titles, etc. can help demarcate sections of text to be treated differently.
像三重引号、XML 标签、章节标题等分隔符可以帮助划分需要被不同处理的文本区域。
For straightforward tasks such as these, using delimiters might not make a difference in the output quality. However, the more complex a task is the more important it is to disambiguate task details. Don’t make the model work to understand exactly what you are asking of them.
对于这些简单的任务,使用分隔符可能不会改变输出质量。但是,任务越复杂,明确任务细节就越重要。不要让模型努力理解你到底要求他们做什么。
Some tasks are best specified as a sequence of steps. Writing the steps out explicitly can make it easier for the model to follow them.
有些任务最好被指定为一系列步骤。明确地书写这些步骤可以使模型更容易遵循它们。
Providing general instructions that apply to all examples is generally more efficient than demonstrating all permutations of a task by example, but in some cases providing examples may be easier. For example, if you intend for the model to copy a particular style of responding to user queries which is difficult to describe explicitly. This is known as "few-shot" prompting.
对于所有示例提供通用说明通常比示范任务的所有排列更有效率,但在某些情况下,提供示例可能更容易。例如,如果您希望模型能复制回应用户查询的特定样式,而这种样式很难明确描述。这被称为"少量示例"提示。
You can ask the model to produce outputs that are of a given target length. The targeted output length can be specified in terms of the count of words, sentences, paragraphs, bullet points, etc. Note however that instructing the model to generate a specific number of words does not work with high precision. The model can more reliably generate outputs with a specific number of paragraphs or bullet points.
您可以要求模型生成指定长度的输出。目标输出长度可以用字数、句子数、段落数、项目符号等来指定。但请注意,指示模型生成特定字数的输出无法做到高精度。模型可以更可靠地生成指定段落数或项目符号数的输出。
If we can provide a model with trusted information that is relevant to the current query, then we can instruct the model to use the provided information to compose its answer.
如果我们可以为模型提供与当前查询相关的可靠信息,那么我们就可以指示模型使用提供的信息来撰写答案。
Given that all models have limited context windows, we need some way to dynamically lookup information that is relevant to the question being asked. Embeddings can be used to implement efficient knowledge retrieval. See the tactic "Use embeddings-based search to implement efficient knowledge retrieval" for more details on how to implement this.
鉴于所有模型都有有限的上下文窗口,我们需要某种方式动态查找与所提问题相关的信息。嵌入可用于实现高效的知识检索。详见战术"使用基于嵌入的搜索来实现高效的知识检索"。
If the input has been supplemented with relevant knowledge, it's straightforward to request that the model add citations to its answers by referencing passages from provided documents. Note that citations in the output can then be verified programmatically by string matching within the provided documents.
如果输入已经补充了相关知识,那么只需简单请求该模型通过引用提供的文档中的段落来为其答案添加引用。请注意,输出中的引用可以通过对提供的文档进行字符串匹配来程序化地进行验证。
For tasks in which lots of independent sets of instructions are needed to handle different cases, it can be beneficial to first classify the type of query and to use that classification to determine which instructions are needed. This can be achieved by defining fixed categories and hardcoding instructions that are relevant for handling tasks in a given category. This process can also be applied recursively to decompose a task into a sequence of stages. The advantage of this approach is that each query will contain only those instructions that are required to perform the next stage of a task which can result in lower error rates compared to using a single query to perform the whole task. This can also result in lower costs since larger prompts cost more to run (see pricing information).
对于需要大量独立指令集来处理不同情况的任务,先对查询类型进行分类,并使用该分类确定所需的指令可能会很有帮助。这可以通过定义固定的类别并编码与处理给定类别任务相关的指令来实现。该过程也可以递归应用,将任务分解为一系列阶段。这种方法的优点是,每个查询只包含执行任务下一阶段所需的指令,从而可以相比使用单个查询执行整个任务而获得更低的错误率。这也可能导致成本更低,因为更大的提示需要更多成本运行(参见价格信息)。
Suppose for example that for a customer service application, queries could be usefully classified as follows:
假设以客户服务应用程序为例,查询可以按以下方式进行有用的分类:
Based on the classification of the customer query, a set of more specific instructions can be provided to a model for it to handle next steps. For example, suppose the customer requires help with "troubleshooting".
根据客户查询的分类,可以为模型提供一组更具体的说明,以便它处理下一步。例如,假设客户需要"故障排除"方面的帮助。
Notice that the model has been instructed to emit special strings to indicate when the state of the conversation changes. This enables us to turn our system into a state machine where the state determines which instructions are injected. By keeping track of state, what instructions are relevant at that state, and also optionally what state transitions are allowed from that state, we can put guardrails around the user experience that would be hard to achieve with a less structured approach.
请注意,该模型已被指示发出特殊字符串以指示对话状态的变化。这使我们能够将系统转换为状态机,其中状态决定注入哪些指令。通过跟踪状态、在该状态下相关的指令以及可选的允许状态转换,我们可以为用户体验设置护栏,这在采取更不结构化的方法时难以实现。
Since models have a fixed context length, dialogue between a user and an assistant in which the entire conversation is included in the context window cannot continue indefinitely.
由于模型具有固定的上下文长度,因此无法无限期地进行包含整个对话的用户和助理之间的对话。
There are various workarounds to this problem, one of which is to summarize previous turns in the conversation. Once the size of the input reaches a predetermined threshold length, this could trigger a query that summarizes part of the conversation and the summary of the prior conversation could be included as part of the system message. Alternatively, prior conversation could be summarized asynchronously in the background throughout the entire conversation.
有多种解决这个问题的方法,其中一种是总结之前的对话内容。一旦输入的内容达到预设的长度阈值,就可以触发一个查询,对对话的一部分进行总结,并将这个总结作为系统消息的一部分。另一种方式是在整个对话过程中,异步地对之前的对话进行总结。
An alternative solution is to dynamically select previous parts of the conversation that are most relevant to the current query. See the tactic "Use embeddings-based search to implement efficient knowledge retrieval".
一个可选的解决方案是动态选择与当前查询最相关的对话的先前部分。参见策略"使用基于嵌入的搜索实现高效的知识检索"。
Since models have a fixed context length, they cannot be used to summarize a text longer than the context length minus the length of the generated summary in a single query.
由于模型具有固定的上下文长度,因此它们无法在单次查询中总结长度超过上下文长度减去生成摘要长度的文本。
To summarize a very long document such as a book we can use a sequence of queries to summarize each section of the document. Section summaries can be concatenated and summarized producing summaries of summaries. This process can proceed recursively until an entire document is summarized. If it’s necessary to use information about earlier sections in order to make sense of later sections, then a further trick that can be useful is to include a running summary of the text that precedes any given point in the book while summarizing content at that point. The effectiveness of this procedure for summarizing books has been studied in previous research by OpenAI using variants of GPT-3.
要总结一份非常长的文档,如一本书,我们可以使用一系列查询来总结文档的每个部分。部分总结可以连接起来并进行总结,产生总结的总结。这个过程可以递归进行,直到整个文档被总结。如果有必要使用早期部分的信息才能理解后续部分,那么一种有用的技巧是在总结某一点的内容时,包括文中前述内容的运行总结。这种总结图书的方法的有效性已在之前由 OpenAI 使用 GPT-3 的变体进行的研究中进行了研究。
Sometimes we get better results when we explicitly instruct the model to reason from first principles before coming to a conclusion. Suppose for example we want a model to evaluate a student’s solution to a math problem. The most obvious way to approach this is to simply ask the model if the student's solution is correct or not.
有时我们在做出结论之前先从基本原理推理,能得到更好的结果。例如,我们希望一个模型评估学生解决数学问题的答案。最直接的方法就是直接询问模型该解答是否正确。
But the student's solution is actually not correct! We can get the model to successfully notice this by prompting the model to generate its own solution first.
但是学生的解决方案实际上并不正确!我们可以通过提示模型先生成自己的解决方案来让模型成功地注意到这一点。
The previous tactic demonstrates that it is sometimes important for the model to reason in detail about a problem before answering a specific question. For some applications, the reasoning process that a model uses to arrive at a final answer would be inappropriate to share with the user. For example, in tutoring applications we may want to encourage students to work out their own answers, but a model’s reasoning process about the student’s solution could reveal the answer to the student.
以前的策略表明,在回答特定问题之前,模型有时需要对问题进行详细推理。对于某些应用程序而言,模型用于得出最终答案的推理过程是不适合与用户共享的。例如,在辅导应用程序中,我们可能希望鼓励学生自己寻找答案,但模型对学生解决方案的推理过程可能会泄露答案给学生。
Inner monologue is a tactic that can be used to mitigate this. The idea of inner monologue is to instruct the model to put parts of the output that are meant to be hidden from the user into a structured format that makes parsing them easy. Then before presenting the output to the user, the output is parsed and only part of the output is made visible.
内心独白是一种可以用来缓解这种情况的策略。内心独白的概念是指指示模型将旨在对用户隐藏的输出部分置于易于解析的结构格式中。然后在将输出呈现给用户之前,对输出进行解析,只显示部分输出。
Alternatively, this can be achieved with a sequence of queries in which all except the last have their output hidden from the end user.
或者,这可以通过一系列查询来实现,其中除最后一个外,其他查询的输出都对最终用户隐藏。
First, we can ask the model to solve the problem on its own. Since this initial query doesn't require the student’s solution, it can be omitted. This provides the additional advantage that there is no chance that the model’s solution will be biased by the student’s attempted solution.
首先,我们可以要求该模型自行解决该问题。由于这个初始查询不需要学生的解决方案,因此可以省略它。这提供了额外的优势,即模型的解决方案不会受到学生尝试解决方案的偏差影响。
Next, we can have the model use all available information to assess the correctness of the student’s solution.
接下来,我们可以让模型利用所有可用的信息来评估学生解决方案的正确性。
Finally, we can let the model use its own analysis to construct a reply in the persona of a helpful tutor.
最后,我们可以让模型使用自己的分析在有帮助的导师的人物角色中构建一个回复。
Suppose that we are using a model to list excerpts from a source which are relevant to a particular question. After listing each excerpt the model needs to determine if it should start writing another or if it should stop. If the source document is large, it is common for a model to stop too early and fail to list all relevant excerpts. In that case, better performance can often be obtained by prompting the model with followup queries to find any excerpts it missed on previous passes.
假设我们正在使用一个模型来列出与特定问题相关的引文摘要。在列出每个引文摘要后,模型需要确定是否应该开始写另一个,还是应该停止。如果源文档很大,模型通常会过早停止,无法列出所有相关的引文摘要。在这种情况下,通过提示模型进行后续查询,以查找之前遗漏的任何引文摘要,通常可以获得更好的性能。
A model can leverage external sources of information if provided as part of its input. This can help the model to generate more informed and up-to-date responses. For example, if a user asks a question about a specific movie, it may be useful to add high quality information about the movie (e.g. actors, director, etc…) to the model’s input. Embeddings can be used to implement efficient knowledge retrieval, so that relevant information can be added to the model input dynamically at run-time.
如果将外部信息源作为模型输入的一部分提供,模型就可以利用这些信息。这有助于模型生成更有见地和更新的响应。例如,如果用户询问关于某部电影的问题,添加关于该电影的高质量信息(如演员、导演等)到模型输入中可能会很有用。嵌入可用于实现高效的知识检索,使相关信息能够动态地添加到模型输入中。
A text embedding is a vector that can measure the relatedness between text strings. Similar or relevant strings will be closer together than unrelated strings. This fact, along with the existence of fast vector search algorithms means that embeddings can be used to implement efficient knowledge retrieval. In particular, a text corpus can be split up into chunks, and each chunk can be embedded and stored. Then a given query can be embedded and vector search can be performed to find the embedded chunks of text from the corpus that are most related to the query (i.e. closest together in the embedding space).
文本嵌入是一种向量,可以测量文本字符串之间的相关性。相似或相关的字符串会比不相关的字符串更接近。这一事实以及快速向量搜索算法的存在意味着嵌入可用于实现高效的知识检索。特别是,文本语料库可以被分割成块,每个块都可以被嵌入和存储。然后,给定的查询可以被嵌入,并且可以执行向量搜索以找到与该查询最相关(即在嵌入空间中最接近)的语料库中的嵌入文本块。
Example implementations can be found in the OpenAI Cookbook. See the tactic “Instruct the model to use retrieved knowledge to answer queries” for an example of how to use knowledge retrieval to minimize the likelihood that a model will make up incorrect facts.
示例实现可以在OpenAI Cookbook中找到。请参阅策略"指示模型使用检索到的知识来回答查询",了解如何使用知识检索来最小化模型制造错误事实的可能性。
Language models cannot be relied upon to perform arithmetic or long calculations accurately on their own. In cases where this is needed, a model can be instructed to write and run code instead of making its own calculations. In particular, a model can be instructed to put code that is meant to be run into a designated format such as triple backtick. After an output is produced, the code can be extracted and run. Finally, if necessary, the output from the code execution engine (i.e. Python interpreter) can be provided as an input to the model for the next query.
语言模型不能依赖自身准确地执行算术或长计算。在需要此类功能的情况下,可以指示模型编写并运行代码,而不是自行做出计算。特别是,可以指示模型将需要运行的代码放入专门的格式,如三个反引号中。在生成输出后,可以提取并运行该代码。最后,如有必要,可将代码执行引擎(即 Python 解释器)的输出作为输入提供给模型以进行后续查询。
Another good use case for code execution is calling external APIs. If a model is instructed in the proper use of an API, it can write code that makes use of it. A model can be instructed in how to use an API by providing it with documentation and/or code samples showing how to use the API.
另一个良好的代码执行用例是调用外部 API。如果一个模型被指示正确使用 API,它可以编写利用它的代码。通过提供文档和/或代码示例展示如何使用 API,可以指导模型如何使用 API。
WARNING: Executing code produced by a model is not inherently safe and precautions should be taken in any application that seeks to do this. In particular, a sandboxed code execution environment is needed to limit the harm that untrusted code could cause.
警告:执行由模型生成的代码并非 inherently 安全,在任何试图执行此操作的应用程序中都应采取预防措施。特别是需要一个沙盒代码执行环境来限制不受信任代码可能造成的伤害。
The Chat Completions API allows passing a list of function descriptions in requests. This enables models to generate function arguments according to the provided schemas. Generated function arguments are returned by the API in JSON format and can be used to execute function calls. Output provided by function calls can then be fed back into a model in the following request to close the loop. This is the recommended way of using OpenAI models to call external functions. To learn more see the function calling section in our introductory text generation guide and more function calling examples in the OpenAI Cookbook.
聊天生成 API 允许在请求中传递函数描述列表。这使模型能够根据提供的模式生成函数参数。生成的函数参数以 JSON 格式返回给 API,可用于执行函数调用。函数调用的输出然后可以在后续请求中反馈到模型中,完成循环。这是使用 OpenAI 模型调用外部函数的推荐方式。要了解更多信息,请参见我们的文本生成指南中的函数调用部分,以及 OpenAI Cookbook 中的更多函数调用示例。
Sometimes it can be hard to tell whether a change — e.g., a new instruction or a new design — makes your system better or worse. Looking at a few examples may hint at which is better, but with small sample sizes it can be hard to distinguish between a true improvement or random luck. Maybe the change helps performance on some inputs, but hurts performance on others.
有时很难判断一个变化(例如新指令或新设计)是否使您的系统更好还是更差。通过查看几个示例可能会暗示哪个更好,但由于样本量小,很难区分真正的改进和随机运气。也许这种变化有助于某些输入的性能,但损害了其他输入的性能。
Evaluation procedures (or "evals") are useful for optimizing system designs. Good evals are:
评估流程(或"评价")对于优化系统设计很有用。好的评价应该是:
- Representative of real-world usage (or at least diverse)
代表现实世界使用情况(或至少是多样化) - Contain many test cases for greater statistical power (see table below for guidelines)
包含许多测试用例以增加统计力度(请参见下表中的指南) - Easy to automate or repeat
易于自动化或重复
Difference to detect 检测差异 | Sample size needed for 95% confidence 需要 95% 置信度的样本量 |
---|---|
30% | ~10 |
10% | ~100 |
3% | ~1,000 |
1% | ~10,000 |
Evaluation of outputs can be done by computers, humans, or a mix. Computers can automate evals with objective criteria (e.g., questions with single correct answers) as well as some subjective or fuzzy criteria, in which model outputs are evaluated by other model queries. OpenAI Evals is an open-source software framework that provides tools for creating automated evals.
输出的评估可以由计算机、人类或混合方式进行。计算机可以使用客观标准(例如只有一个正确答案的问题)以及一些主观或模糊标准自动完成评估,其中模型输出由其他模型查询进行评估。OpenAI Evals是一个开源软件框架,提供创建自动化评估的工具。
Model-based evals can be useful when there exists a range of possible outputs that would be considered equally high in quality (e.g. for questions with long answers). The boundary between what can be realistically evaluated with a model-based eval and what requires a human to evaluate is fuzzy and is constantly shifting as models become more capable. We encourage experimentation to figure out how well model-based evals can work for your use case.
基于模型的评估在存在多种可能输出且质量均等高时可能很有用(例如长答案问题)。可用模型评估的范围和需要人工评估的范围界限模糊,随着模型能力的不断提升而不断变化。我们鼓励进行实验,以了解基于模型的评估在您的使用案例中的实用性。
Suppose it is known that the correct answer to a question should make reference to a specific set of known facts. Then we can use a model query to count how many of the required facts are included in the answer.
假设已知一个问题的正确答案应该参考一组特定的已知事实。那么我们可以使用一个模型查询来统计答案中包含了多少个所需的事实。
For example, using the following system message:
例如,使用以下系统消息:
Here's an example input where both points are satisfied:
这里有一个示例输入,满足两个要点:
Here's an example input where only one point is satisfied:
这里有一个只有一个点满足的例子:
Here's an example input where none are satisfied:
这里有一个没有任何人满意的输入示例:
There are many possible variants on this type of model-based eval. Consider the following variation which tracks the kind of overlap between the candidate answer and the gold-standard answer, and also tracks whether the candidate answer contradicts any part of the gold-standard answer.
这种基于模型的评估存在许多可能的变体。考虑以下这种变体,它跟踪候选答案与标准答案之间的重叠程度,同时也检测候选答案是否与标准答案的任何部分产生矛盾。
Here's an example input with a substandard answer which nonetheless does not contradict the expert answer:
这是一个示例输入,尽管答案不太标准,但也不会与专家答案相矛盾:
Here's an example input with answer that directly contradicts the expert answer:
下面是一个输入示例,其答案直接与专家答案相矛盾:
Here's an example input with a correct answer that also provides a bit more detail than is necessary:
这里是一个带有正确答案的示例输入,它还提供了比必要更多的详细信息:
For more inspiration, visit the OpenAI Cookbook, which contains example code and also links to third-party resources such as:
为了获得更多灵感,请访问OpenAI Cookbook,其中包含示例代码,也有指向第三方资源的链接,例如: