Split complex tasks into simpler subtasks
将复杂任务分解为较简单的子任务
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 GPTs. 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.
与软件工程中将复杂系统分解为一组模块化组件的最佳实践相同,将任务提交给 GPT 时也是如此。与较简单的任务相比,复杂任务的错误率往往更高。此外,复杂任务通常可以重新定义为一系列较简单任务的工作流程,其中较早任务的输出被用于构建后续任务的输入。
Tactic: Use intent classification to identify the most relevant instructions for a user query
技巧:使用意图分类识别与用户查询最相关的指示
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:
例如,假设对于客户服务应用程序,查询可以有以下有用的分类:
SYSTEM 系统 |
You will be provided with customer service queries. Classify each query into a primary category and a secondary category. Provide your output in json format with the keys: primary and secondary. 您将收到客户服务查询。将每个查询分类为主要类别和次要类别。使用 JSON 格式提供输出,键为:主要和次要。 Primary categories: Billing, Technical Support, Account Management, or General Inquiry. 主要类别:计费、技术支持、帐户管理或一般查询。 Billing secondary categories: - Unsubscribe or upgrade - Add a payment method - Explanation for charge - Dispute a charge 计费的次要类别: - 退订或升级 - 添加付款方式 - 收费解释 - 争议收费 Technical Support secondary categories: - Troubleshooting - Device compatibility - Software updates 技术支持的次要类别: - 故障排除 - 设备兼容性 - 软件更新 Account Management secondary categories: - Password reset - Update personal information - Close account - Account security 帐户管理的次要类别: - 密码重置 - 更新个人信息 - 关闭帐户 - 帐户安全 General Inquiry secondary categories: - Product information - Pricing - Feedback - Speak to a human 一般查询的次要类别: - 产品信息 - 定价 - 反馈 - 联系人工客服 |
USER 用户 |
I need to get my internet working again. 我需要让我的互联网再次工作起来。 |
Based on the classification of the customer query, a set of more specific instructions can be provided to a GPT model to handle next steps. For example, suppose the customer requires help with "troubleshooting".
根据客户查询的分类,可以提供一组更具体的指令给 GPT 模型处理下一步操作。例如,假设客户需要帮助“故障排除”。
SYSTEM 系统 |
You will be provided with customer service inquiries that require troubleshooting in a technical support context. Help the user by: 您将收到需要在技术支持上下文中进行故障排除的客户服务查询。通过以下方式帮助用户: - Ask them to check that all cables to/from the router are connected. Note that it is common for cables to come loose over time. - 要求他们检查与路由器相连的所有电缆是否连接。请注意,随着时间的推移,电缆常常会松动。 - If all cables are connected and the issue persists, ask them which router model they are using - 如果所有电缆连接正常且问题仍然存在,请询问他们使用的路由器型号。 - Now you will advise them how to restart their device: - 现在,请告诉他们如何重新启动设备: -- If the model number is MTD-327J, advise them to push the red button and hold it for 5 seconds, then wait 5 minutes before testing the connection. - 如果型号是 MTD-327J,请建议他们按下红色按钮并保持按压 5 秒钟,然后等待 5 分钟后测试连接。 -- If the model number is MTD-327S, advise them to unplug and replug it, then wait 5 minutes before testing the connection. 如果型号是 MTD-327S,请建议他们拔下插头并重新插上,然后等待 5 分钟后测试连接。 - If the customer's issue persists after restarting the device and waiting 5 minutes, connect them to IT support by outputting {"IT support requested"}. 如果客户在重新启动设备并等待 5 分钟问题仍然存在,则通过输出 {"IT support requested"} 将他们连接到 IT 支持。 - If the user starts asking questions that are unrelated to this topic then confirm if they would like to end the current chat about troubleshooting and classify their request according to the following scheme: - 如果用户开始询问与此主题无关的问题,则确认他们是否想结束当前有关故障排除的聊天,并根据以下方案对其请求进行分类: |
USER 用户 |
<insert primary/secondary classification scheme from above here> <在上面插入主要/次要分类方案> I need to get my internet working again. 我需要让我的互联网再次工作起来。 |
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.
请注意,已指示模型发出特殊字符串以指示会话状态何时发生变化。这使我们能够将系统转变为一个状态机,其中状态确定注入哪些指令。通过跟踪状态、确定在该状态下哪些指令相关,以及可选地确定从该状态允许的状态转换,我们可以为用户体验设置防护措施,这对于使用不太结构化的方法很难实现。
Tactic: For dialogue applications that require very long conversations, summarize or filter previous dialogue
技巧:对于需要非常长对话的对话应用,总结或过滤先前的对话
Since GPTs 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.
由于 GPT 模型有固定的上下文长度,在用户与助手之间的对话中,如果整个对话都包含在上下文窗口中,对话不能无限继续下去。
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".
另一种解决方案是动态选择与当前查询最相关的先前对话部分。请参阅策略“使用基于嵌入的搜索来实现高效的知识检索”。
Tactic: Summarize long documents piecewise and construct a full summary recursively
策略:逐段总结长文档并递归构建完整总结
Since GPTs 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.
由于 GPT 模型有固定的上下文长度,无法在单个查询中对超出上下文长度减去生成总结长度的文本进行总结。
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 的变体研究了对书籍进行总结的效果。文章来源:https://www.toymoban.com/news/detail-556543.html
“点赞有美意,赞赏是鼓励”文章来源地址https://www.toymoban.com/news/detail-556543.html
到了这里,关于ChatGPT 最佳实践指南之:将复杂任务拆分为较简单的子任务的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!