Split complex tasks into simpler subtasks
將復(fù)雜任務(wù)分解為較簡單的子任務(wù)
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.
與軟件工程中將復(fù)雜系統(tǒng)分解為一組模塊化組件的最佳實踐相同,將任務(wù)提交給 GPT 時也是如此。與較簡單的任務(wù)相比,復(fù)雜任務(wù)的錯誤率往往更高。此外,復(fù)雜任務(wù)通??梢灾匦露x為一系列較簡單任務(wù)的工作流程,其中較早任務(wù)的輸出被用于構(gòu)建后續(xù)任務(wù)的輸入。
Tactic: Use intent classification to identify the most relevant instructions for a user query
技巧:使用意圖分類識別與用戶查詢最相關(guān)的指示
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).
對于需要處理不同情況下的許多獨立指令集的任務(wù),首先對查詢進行分類,并使用分類來確定所需的指令,這將是有益的??梢酝ㄟ^定義固定的類別并硬編碼與給定類別下任務(wù)處理相關(guān)的指令來實現(xiàn)。這個過程也可以遞歸應(yīng)用于將任務(wù)分解為一系列階段。這種方法的優(yōu)點是每個查詢只包含執(zhí)行任務(wù)的下一個階段所需的指令,與使用單個查詢執(zhí)行整個任務(wù)相比,這可以降低錯誤率。這還可以降低成本,因為更大的提示需要更多的資源(請參閱定價信息)。
Suppose for example that for a customer service application, queries could be usefully classified as follows:
例如,假設(shè)對于客戶服務(wù)應(yīng)用程序,查詢可以有以下有用的分類:
SYSTEM 系統(tǒng) |
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. 您將收到客戶服務(wù)查詢。將每個查詢分類為主要類別和次要類別。使用 JSON 格式提供輸出,鍵為:主要和次要。 Primary categories: Billing, Technical Support, Account Management, or General Inquiry. 主要類別:計費、技術(shù)支持、帳戶管理或一般查詢。 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 技術(shù)支持的次要類別: -?故障排除 -?設(shè)備兼容性 -?軟件更新 Account Management secondary categories: - Password reset - Update personal information - Close account - Account security 帳戶管理的次要類別: -?密碼重置 -?更新個人信息 -?關(guān)閉帳戶 -?帳戶安全 General Inquiry secondary categories: - Product information - Pricing - Feedback - Speak to a human 一般查詢的次要類別: -?產(chǎn)品信息 -?定價 -?反饋 -?聯(lián)系人工客服 |
USER 用戶 |
I need to get my internet working again. 我需要讓我的互聯(lián)網(wǎng)再次工作起來。 |
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".
根據(jù)客戶查詢的分類,可以提供一組更具體的指令給 GPT 模型處理下一步操作。例如,假設(shè)客戶需要幫助“故障排除”。
SYSTEM 系統(tǒng) |
You will be provided with customer service inquiries that require troubleshooting in a technical support context. Help the user by: 您將收到需要在技術(shù)支持上下文中進行故障排除的客戶服務(wù)查詢。通過以下方式幫助用戶: - 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: -?現(xiàn)在,請告訴他們?nèi)绾沃匦聠釉O(shè)備: -- 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"}. 如果客戶在重新啟動設(shè)備并等待 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: -?如果用戶開始詢問與此主題無關(guān)的問題,則確認他們是否想結(jié)束當(dāng)前有關(guān)故障排除的聊天,并根據(jù)以下方案對其請求進行分類: |
USER 用戶 |
<insert primary/secondary classification scheme from above here> <在上面插入主要/次要分類方案> I need to get my internet working again. 我需要讓我的互聯(lián)網(wǎng)再次工作起來。 |
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.
請注意,已指示模型發(fā)出特殊字符串以指示會話狀態(tài)何時發(fā)生變化。這使我們能夠?qū)⑾到y(tǒng)轉(zhuǎn)變?yōu)橐粋€狀態(tài)機,其中狀態(tài)確定注入哪些指令。通過跟蹤狀態(tài)、確定在該狀態(tài)下哪些指令相關(guān),以及可選地確定從該狀態(tài)允許的狀態(tài)轉(zhuǎn)換,我們可以為用戶體驗設(shè)置防護措施,這對于使用不太結(jié)構(gòu)化的方法很難實現(xiàn)。
Tactic: For dialogue applications that require very long conversations, summarize or filter previous dialogue
技巧:對于需要非常長對話的對話應(yīng)用,總結(jié)或過濾先前的對話
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 模型有固定的上下文長度,在用戶與助手之間的對話中,如果整個對話都包含在上下文窗口中,對話不能無限繼續(xù)下去。
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.
有多種解決這個問題的方法,方法之一是對先前的對話進行總結(jié)。一旦輸入的大小達到預(yù)定的閾值長度,這可能會觸發(fā)一個查詢,對對話的一部分進行總結(jié),先前對話的總結(jié)可以作為系統(tǒng)消息的一部分包含在其中?;蛘?,可以在整個對話過程中異步地對先前的對話進行總結(jié)。
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".
另一種解決方案是動態(tài)選擇與當(dāng)前查詢最相關(guān)的先前對話部分。請參閱策略“使用基于嵌入的搜索來實現(xiàn)高效的知識檢索”。
Tactic: Summarize long documents piecewise and construct a full summary recursively
策略:逐段總結(jié)長文檔并遞歸構(gòu)建完整總結(jié)
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 模型有固定的上下文長度,無法在單個查詢中對超出上下文長度減去生成總結(jié)長度的文本進行總結(jié)。
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.
要對非常長的文檔(如書籍)進行總結(jié),可以使用一系列查詢來逐段總結(jié)文檔的每個部分。可以將各個段落的總結(jié)連接并進行總結(jié),生成總結(jié)的總結(jié)。這個過程可以遞歸進行,直到對整個文檔進行總結(jié)。如果需要使用先前部分的信息才能理解后續(xù)部分,則可以在總結(jié)內(nèi)容時,在給定點之前包含文本的運行總結(jié)。這個過程在以往的 OpenAI 研究中使用 GPT-3 的變體研究了對書籍進行總結(jié)的效果。文章來源:http://www.zghlxwxcb.cn/news/detail-556543.html
“點贊有美意,贊賞是鼓勵”文章來源地址http://www.zghlxwxcb.cn/news/detail-556543.html
到了這里,關(guān)于ChatGPT 最佳實踐指南之:將復(fù)雜任務(wù)拆分為較簡單的子任務(wù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!