首頁 >科技週邊 >人工智慧 >通過GPT模型調節CHATGPT響應的綜合指南

通過GPT模型調節CHATGPT響應的綜合指南

Joseph Gordon-Levitt
Joseph Gordon-Levitt原創
2025-03-10 10:57:10733瀏覽

AI 質量審核:利用 AI 提升應用質量

人工智能革命席捲應用開發領域,開啟了人機交互的新紀元。企業利用 AI 提升用戶體驗的同時,基於大型語言模型 (LLM) 的解決方案也帶來了維護內容完整性、準確性和道德標準的挑戰。

隨著應用擴展到受控環境之外,對負責任的 AI 審核的需求變得越來越明顯。在這些環境中,確保對用戶提供合理和準確的回應並非易事,但卻至關重要。

例如,在客戶服務互動中,錯誤信息或不當內容可能導致客戶不滿,甚至損害企業的聲譽。但作為開發者,如何確保基於 AI 的應用能夠向用戶提供合理和準確的回應? 這就是 AI 審核發揮作用的地方!

本文將深入探討一種使用 GPT 模型審核基於 GPT 的應用的技術。

構建基於 GPT 的質量審核代理

AI 質量審核還包括在使用大型語言模型 (LLM) 時確保生成無偏見和適當的響應。 OpenAI 已經推出了一個專為這類審核需求設計的 API。如果您熱衷於檢測模型產生的有偏見或不當的回應,或解決用戶的不當行為,那麼您會在題為《ChatGPT 審核 API:輸入/輸出控制》的文章中找到有價值的見解。

然而,本文采用了一種不同的 AI 審核方法。我們關注的是保證模型響應的質量,即準確性和滿足用戶需求。據我所知,目前還沒有專門為此目的設計的官方端點。

儘管如此,鑑於我們在各種應用中廣泛使用 GPT 模型,為什麼不將它們用作同一模型實例的質量檢查器呢?

我們可以利用 GPT 模型來評估模型本身針對用戶請求生成的輸出。這種測試方法有助於防止含糊不清和錯誤的回應,並增強模型有效滿足用戶請求的能力。

範圍和目標

本文介紹了如何在應用範圍內使用 GPT 模型來審核基於 GPT 的應用的質量和正確性

例如,如果您使用 GPT 模型為您的企業聊天機器人提供動力,那麼您肯定非常希望確保您的聊天機器人不會提供任何超出您的產品目錄項目或特性的信息。

在接下來的章節中,我們將通過使用 openai Python 包和著名的 Jupyter Notebook 對 OpenAI API 進行簡單的調用,使最後一個例子生動起來。

主要目標是生成一個簡單的基於 LLM 的應用,並使用基於 LLM 的質量檢查器來審核其輸出。在我們的示例中,我們需要創建我們的示例客戶服務代理、質量檢查代理(從現在起稱為 QA 代理),更重要的是,定義兩者之間的交互。

下圖很好地展現了上述工作流程:

A Comprehensive Guide to Moderating ChatGPT Responses with GPT Models

自製圖片。審核工作流程圖:1. 用戶向基於 LLM 的應用(本例中為客戶服務聊天機器人)發送請求。 2. 聊天機器人生成答案,但首先將其發送給 QA 代理。 3. QA 代理在檢查答案是否合適後,將答案發送回用戶。

讓我們一步一步來!

構建 GPT 代理

讓我們從為商店的客戶服務構建一個對話代理開始。

如果您已經擁有一個可運行的 LLM 驅動的應用程序或要實現您首選的示例,請隨時跳過第一部分!如果您仍然想知道您的企業是否可以從基於 LLM 的應用程序中受益,那麼您應該關註一個有趣的播客討論!

創建示例客戶服務聊天機器人

讓我們假設我們正在為我們的商店構建一個客戶服務代理。我們有興趣在該客戶代理背後使用 ChatGPT 等模型,以利用其自然語言能力來理解用戶查詢並以自然的方式回复他們。

為了定義我們的客戶服務聊天機器人,我們需要兩個關鍵要素:

  • 一個示例產品目錄,以將代理限制在我們的業務範圍內。通過將我們的產品目錄提供給模型,我們可以讓模型知道向我們的用戶提供哪些信息。
  • 一個系統消息,用於定義模型的高級行為。雖然 GPT 模型通常接受過多種任務的訓練,但您可以使用所謂的系統消息來限制模型的行為。

最後,與任何其他基於 LLM 的應用程序一樣,我們需要一種方法可以從我們的腳本中調用 OpenAI API。在本文中,我將使用以下實現,它僅依賴於 openai 包:

<code>import openai
import os

# 从环境中获取 OpenAI 密钥
openai_api_key = os.environ["OPENAI_API_KEY"]

# 使用过去交互记忆的简单 OpenAI API 调用
def gpt_call(prompt, message_history, model="gpt-3.5-turbo"):
message_history.append({'role': 'user', 'content': prompt})
response = openai.ChatCompletion.create( 
model=model,
messages=message_history
)

response_text = response.choices[0].message["content"]
message_history.append({'role': 'assistant', 'content': response_text})
return response_text</code>

其背後的思想是為每個模型實例初始化一個單獨的消息歷史記錄(包含系統消息),並使用即將進行的與模型的交互來不斷更新它。

如果您正在尋找一種更優化的處理交互方式,我強烈建議您使用 langchain 框架,就像我們在《構建上下文感知聊天機器人:利用 LangChain 框架實現 ChatGPT》中所做的那樣。

如果您不熟悉 OpenAI API,請考慮查看關於《OpenAI API 和 ChatGPT 入門》的網絡研討會。

現在我們已經確定了所需的構建塊,讓我們將它們組合在一起:

<code># 定义我们的示例产品目录
product_information = """
{ "name": "UltraView QLED TV", "category": "Televisions and Home Theater Systems", "brand": "UltraView", "model_number": "UV-QLED65", "warranty": "3 years", "rating": 4.9, "features": [ "65-inch QLED display", "8K resolution", "Quantum HDR", "Dolby Vision", "Smart TV" ], "description": "Experience lifelike colors and incredible clarity with this high-end QLED TV.", "price": 2499.99 }
{ "name": "ViewTech Android TV", "category": "Televisions and Home Theater Systems", "brand": "ViewTech", "model_number": "VT-ATV55", "warranty": "2 years", "rating": 4.7, "features": [ "55-inch 4K display", "Android TV OS", "Voice remote", "Chromecast built-in" ], "description": "Access your favorite apps and content on this smart Android TV.", "price": 799.99 }
{ "name": "SlimView OLED TV", "category": "Televisions and Home Theater Systems", "brand": "SlimView", "model_number": "SL-OLED75", "warranty": "2 years", "rating": 4.8, "features": [ "75-inch OLED display", "4K resolution", "HDR10+", "Dolby Atmos", "Smart TV" ], "description": "Immerse yourself in a theater-like experience with this ultra-thin OLED TV.", "price": 3499.99 }
{ "name": "TechGen X Pro", "category": "Smartphones and Accessories", "brand": "TechGen", "model_number": "TG-XP20", "warranty": "1 year", "rating": 4.5, "features": [ "6.4-inch AMOLED display", "128GB storage", "48MP triple camera", "5G", "Fast charging" ], "description": "A feature-packed smartphone designed for power users and mobile enthusiasts.", "price": 899.99 }
{ "name": "GigaPhone 12X", "category": "Smartphones and Accessories", "brand": "GigaPhone", "model_number": "GP-12X", "warranty": "2 years", "rating": 4.6, "features": [ "6.7-inch IPS display", "256GB storage", "108MP quad camera", "5G", "Wireless charging" ], "description": "Unleash the power of 5G and high-resolution photography with the GigaPhone 12X.", "price": 1199.99 }
{ "name": "Zephyr Z1", "category": "Smartphones and Accessories", "brand": "Zephyr", "model_number": "ZP-Z1", "warranty": "1 year", "rating": 4.4, "features": [ "6.2-inch LCD display", "64GB storage", "16MP dual camera", "4G LTE", "Long battery life" ], "description": "A budget-friendly smartphone with reliable performance for everyday use.", "price": 349.99 }
{ "name": "PixelMaster Pro DSLR", "category": "Cameras and Camcorders", "brand": "PixelMaster", "model_number": "PM-DSLR500", "warranty": "2 years", "rating": 4.8, "features": [ "30.4MP full-frame sensor", "4K video", "Dual Pixel AF", "3.2-inch touchscreen" ], "description": "Unleash your creativity with this professional-grade DSLR camera.", "price": 1999.99 }
{ "name": "ActionX Waterproof Camera", "category": "Cameras and Camcorders", "brand": "ActionX", "model_number": "AX-WPC100", "warranty": "1 year", "rating": 4.6, "features": [ "20MP sensor", "4K video", "Waterproof up to 50m", "Wi-Fi connectivity" ], "description": "Capture your adventures with this rugged and versatile action camera.", "price": 299.99 }
{ "name": "SonicBlast Wireless Headphones", "category": "Audio and Headphones", "brand": "SonicBlast", "model_number": "SB-WH200", "warranty": "1 year", "rating": 4.7, "features": [ "Active noise cancellation", "50mm drivers", "30-hour battery life", "Comfortable earpads" ], "description": "Immerse yourself in superior sound quality with these wireless headphones.", "price": 149.99 }
"""

# 为我们的用例定义一个合适的系统消息
customer_agent_sysmessage = f"""
您是一位客户服务代理,负责回答客户关于产品目录中产品的疑问。
产品目录将用三个反引号分隔,即 ```。
以友好和人性化的语气回复,并提供产品目录中可用的详细信息。

产品目录: ```{product_information}```
"""

# 初始化模型的记忆
customer_agent_history = [{'role': 'system', 'content': customer_agent_sysmessage}]</code>

我們可以看到,我們已經定義了一個示例目錄 (product_information)(JSONL 格式),以及一個系統消息 (customer_agent_sysmessage),其中包含三個要求:

  • 扮演客戶服務代理的角色。
  • 以友好和人性化的語氣回复。
  • 僅提供目錄中的信息。

最後,我們還初始化了客戶代理的消息歷史記錄 (customer_agent_history)。

值得注意的是,我們在編寫系統消息和附加信息(例如,三個反引號)時使用了特徵風格。這是提示工程的最佳實踐之一!如果您對更多最佳實踐感興趣,那麼《ChatGPT 提示工程入門指南》網絡研討會適合您!

在這一點上,我們可以開始使用我們的示例客戶聊天機器人,如下所示:

<code>import openai
import os

# 从环境中获取 OpenAI 密钥
openai_api_key = os.environ["OPENAI_API_KEY"]

# 使用过去交互记忆的简单 OpenAI API 调用
def gpt_call(prompt, message_history, model="gpt-3.5-turbo"):
message_history.append({'role': 'user', 'content': prompt})
response = openai.ChatCompletion.create( 
model=model,
messages=message_history
)

response_text = response.choices[0].message["content"]
message_history.append({'role': 'assistant', 'content': response_text})
return response_text</code>

看起來像一個自然的答案,對吧?讓我們進行後續互動:

<code># 定义我们的示例产品目录
product_information = """
{ "name": "UltraView QLED TV", "category": "Televisions and Home Theater Systems", "brand": "UltraView", "model_number": "UV-QLED65", "warranty": "3 years", "rating": 4.9, "features": [ "65-inch QLED display", "8K resolution", "Quantum HDR", "Dolby Vision", "Smart TV" ], "description": "Experience lifelike colors and incredible clarity with this high-end QLED TV.", "price": 2499.99 }
{ "name": "ViewTech Android TV", "category": "Televisions and Home Theater Systems", "brand": "ViewTech", "model_number": "VT-ATV55", "warranty": "2 years", "rating": 4.7, "features": [ "55-inch 4K display", "Android TV OS", "Voice remote", "Chromecast built-in" ], "description": "Access your favorite apps and content on this smart Android TV.", "price": 799.99 }
{ "name": "SlimView OLED TV", "category": "Televisions and Home Theater Systems", "brand": "SlimView", "model_number": "SL-OLED75", "warranty": "2 years", "rating": 4.8, "features": [ "75-inch OLED display", "4K resolution", "HDR10+", "Dolby Atmos", "Smart TV" ], "description": "Immerse yourself in a theater-like experience with this ultra-thin OLED TV.", "price": 3499.99 }
{ "name": "TechGen X Pro", "category": "Smartphones and Accessories", "brand": "TechGen", "model_number": "TG-XP20", "warranty": "1 year", "rating": 4.5, "features": [ "6.4-inch AMOLED display", "128GB storage", "48MP triple camera", "5G", "Fast charging" ], "description": "A feature-packed smartphone designed for power users and mobile enthusiasts.", "price": 899.99 }
{ "name": "GigaPhone 12X", "category": "Smartphones and Accessories", "brand": "GigaPhone", "model_number": "GP-12X", "warranty": "2 years", "rating": 4.6, "features": [ "6.7-inch IPS display", "256GB storage", "108MP quad camera", "5G", "Wireless charging" ], "description": "Unleash the power of 5G and high-resolution photography with the GigaPhone 12X.", "price": 1199.99 }
{ "name": "Zephyr Z1", "category": "Smartphones and Accessories", "brand": "Zephyr", "model_number": "ZP-Z1", "warranty": "1 year", "rating": 4.4, "features": [ "6.2-inch LCD display", "64GB storage", "16MP dual camera", "4G LTE", "Long battery life" ], "description": "A budget-friendly smartphone with reliable performance for everyday use.", "price": 349.99 }
{ "name": "PixelMaster Pro DSLR", "category": "Cameras and Camcorders", "brand": "PixelMaster", "model_number": "PM-DSLR500", "warranty": "2 years", "rating": 4.8, "features": [ "30.4MP full-frame sensor", "4K video", "Dual Pixel AF", "3.2-inch touchscreen" ], "description": "Unleash your creativity with this professional-grade DSLR camera.", "price": 1999.99 }
{ "name": "ActionX Waterproof Camera", "category": "Cameras and Camcorders", "brand": "ActionX", "model_number": "AX-WPC100", "warranty": "1 year", "rating": 4.6, "features": [ "20MP sensor", "4K video", "Waterproof up to 50m", "Wi-Fi connectivity" ], "description": "Capture your adventures with this rugged and versatile action camera.", "price": 299.99 }
{ "name": "SonicBlast Wireless Headphones", "category": "Audio and Headphones", "brand": "SonicBlast", "model_number": "SB-WH200", "warranty": "1 year", "rating": 4.7, "features": [ "Active noise cancellation", "50mm drivers", "30-hour battery life", "Comfortable earpads" ], "description": "Immerse yourself in superior sound quality with these wireless headphones.", "price": 149.99 }
"""

# 为我们的用例定义一个合适的系统消息
customer_agent_sysmessage = f"""
您是一位客户服务代理,负责回答客户关于产品目录中产品的疑问。
产品目录将用三个反引号分隔,即 ```。
以友好和人性化的语气回复,并提供产品目录中可用的详细信息。

产品目录: ```{product_information}```
"""

# 初始化模型的记忆
customer_agent_history = [{'role': 'system', 'content': customer_agent_sysmessage}]</code>

很公平! 代理能夠識別出我們的產品目錄中沒有 iPhone,並相應地回復用戶。它甚至鼓勵用戶聯繫商店!

讓我們再嘗試一個請求:

<code>user_prompt = "你们商店里最好的电视是什么?"

customer_agent_response = gpt_call(user_prompt, customer_agent_history)
print(customer_agent_response)

# 输出:在我们商店里,UltraView QLED 电视被认为是最好的电视。它的评分为 4.9,并提供 65 英寸 QLED 显示屏和 8K 分辨率。它还具有 Quantum HDR、Dolby Vision 和智能电视功能。凭借其逼真的色彩和令人难以置信的清晰度,这款高端 QLED 电视可提供身临其境的观看体验。UltraView QLED 电视的价格为 2499.99 美元,并提供 3 年保修。</code>

正確地, 它似乎在某些情況下代理可能會跳過目錄中的信息。在這些情況下,QA 代理可以幫助過濾不需要的響應。

開發我們的自定義 QA 代理

正如我們已經討論過的,QA 代理的目的是根據用戶查詢和產品目錄來檢查客戶服務代理的質量。因此,定義一個設置此確切高級行為的系統消息非常重要:

<code>user_prompt = "我想买最新的 iPhone。你能帮我吗?"

customer_agent_response = gpt_call(user_prompt, customer_agent_history)
print(customer_agent_response)

# 输出:当然!我很乐意帮助您找到最新的 iPhone。但是,由于它似乎缺失于产品目录中,我目前无法提供有关最新 iPhone 型号的具体详细信息。我建议您查看我们的网站或直接联系我们的商店,以获取有关最新 iPhone 型号的最新信息。我们知识渊博的工作人员将能够帮助您选择最符合您的需求和偏好的 iPhone。</code>

對於客戶代理而言,用戶提示是不可預測的,因為它取決於用戶的需求和寫作風格。對於 QA 代理而言,我們負責將用戶請求、客戶代理響應和產品目錄傳遞給模型。因此,我們的提示將始終具有相同的結構,但用戶查詢 (user_prompt) 和模型的響應 (customer_agent_response) 卻有所不同:

<code>user_prompt = "你能帮我买一台三星电视吗?"

customer_agent_response = gpt_call(user_prompt, customer_agent_history)
print(customer_agent_response)

# 输出:当然!我很乐意协助您购买三星电视。您能否提供您的一些具体要求或偏好?这样,我可以推荐最适合您需求的三星电视型号。</code>

一旦定義了系統消息和 QA 提示,我們就可以使用最新的客戶服務響應來測試 QA 代理,如下所示:

<code>qa_sysmessage = f"""
您是一位质量助理,负责评估客户服务代理是否正确地回答了客户的问题。
您还必须验证客户服务代理是否仅提供我们商店产品目录中的信息,并温和地拒绝目录之外的任何其他产品。
客户消息、客户服务代理的回复和产品目录将用三个反引号分隔,即 ```。

请说明您的答案原因。
"""</code>

為了評估 QA 代理的響應,讓我們分解它將分析的交互:

  • 用戶請求:“你能幫我買一台三星電視嗎?”
  • 客戶代理回复:“當然!我很樂意協助您購買三星電視。您能否提供您的一些具體要求或偏好?這樣,我可以推薦最適合您需求的三星電視型號。”
  • QA 代理:“質量檢查:不正確的回復反饋:客戶要求幫助購買三星電視,但代理沒有處理該請求。代理應該提到他們只能訪問我們商店的產品目錄,並且可以根據該目錄提供信息和建議。代理應該溫和地拒絕目錄之外的任何其他產品。”

質量代理能夠發現客戶代理的不當回复!

代理之間的交互

現在我們已經讓兩個代理獨立工作,是時候定義它們之間的交互了。

我們可以用一個簡單的圖表來描述兩個代理及其要求:

A Comprehensive Guide to Moderating ChatGPT Responses with GPT Models

自製圖片。每個代理的三個構建塊圖:系統消息(藍色)、模型輸入(綠色)和模型輸出(黃色)。

接下來是什麼? 現在,我們需要實現兩個模型之間的交互!

以下是一個過濾不准確響應的建議:

首先,我們讓客戶代理根據用戶查詢生成響應。然後,如果 QA 代理認為客戶代理的響應對於用戶查詢和產品目錄來說足夠好,我們只需將答案發送回用戶。

相反,如果 QA 代理確定答案不符合用戶的請求或包含關於目錄的不真實信息,我們可以要求客戶代理在將其發送給用戶之前改進答案。

鑑於這個想法,我們可以改進我們原始圖表的最後一部分,如下所示:

A Comprehensive Guide to Moderating ChatGPT Responses with GPT Models

自製圖片。擴展的審核工作流程圖。我們可以使用 QA 代理的判斷向基於 LLM 的應用程序提供反饋。

編排代理交互

為了將 QA 代理用作過濾器,我們需要確保它在每次迭代中輸出一致的響應。

實現這一點的一種方法是稍微更改 QA 代理系統消息,並要求它僅在客戶代理響應足夠好時輸出 True,否則輸出 False:

<code>import openai
import os

# 从环境中获取 OpenAI 密钥
openai_api_key = os.environ["OPENAI_API_KEY"]

# 使用过去交互记忆的简单 OpenAI API 调用
def gpt_call(prompt, message_history, model="gpt-3.5-turbo"):
message_history.append({'role': 'user', 'content': prompt})
response = openai.ChatCompletion.create( 
model=model,
messages=message_history
)

response_text = response.choices[0].message["content"]
message_history.append({'role': 'assistant', 'content': response_text})
return response_text</code>

因此,當再次評估最新的客戶代理響應時,我們將只獲得布爾輸出:

<code># 定义我们的示例产品目录
product_information = """
{ "name": "UltraView QLED TV", "category": "Televisions and Home Theater Systems", "brand": "UltraView", "model_number": "UV-QLED65", "warranty": "3 years", "rating": 4.9, "features": [ "65-inch QLED display", "8K resolution", "Quantum HDR", "Dolby Vision", "Smart TV" ], "description": "Experience lifelike colors and incredible clarity with this high-end QLED TV.", "price": 2499.99 }
{ "name": "ViewTech Android TV", "category": "Televisions and Home Theater Systems", "brand": "ViewTech", "model_number": "VT-ATV55", "warranty": "2 years", "rating": 4.7, "features": [ "55-inch 4K display", "Android TV OS", "Voice remote", "Chromecast built-in" ], "description": "Access your favorite apps and content on this smart Android TV.", "price": 799.99 }
{ "name": "SlimView OLED TV", "category": "Televisions and Home Theater Systems", "brand": "SlimView", "model_number": "SL-OLED75", "warranty": "2 years", "rating": 4.8, "features": [ "75-inch OLED display", "4K resolution", "HDR10+", "Dolby Atmos", "Smart TV" ], "description": "Immerse yourself in a theater-like experience with this ultra-thin OLED TV.", "price": 3499.99 }
{ "name": "TechGen X Pro", "category": "Smartphones and Accessories", "brand": "TechGen", "model_number": "TG-XP20", "warranty": "1 year", "rating": 4.5, "features": [ "6.4-inch AMOLED display", "128GB storage", "48MP triple camera", "5G", "Fast charging" ], "description": "A feature-packed smartphone designed for power users and mobile enthusiasts.", "price": 899.99 }
{ "name": "GigaPhone 12X", "category": "Smartphones and Accessories", "brand": "GigaPhone", "model_number": "GP-12X", "warranty": "2 years", "rating": 4.6, "features": [ "6.7-inch IPS display", "256GB storage", "108MP quad camera", "5G", "Wireless charging" ], "description": "Unleash the power of 5G and high-resolution photography with the GigaPhone 12X.", "price": 1199.99 }
{ "name": "Zephyr Z1", "category": "Smartphones and Accessories", "brand": "Zephyr", "model_number": "ZP-Z1", "warranty": "1 year", "rating": 4.4, "features": [ "6.2-inch LCD display", "64GB storage", "16MP dual camera", "4G LTE", "Long battery life" ], "description": "A budget-friendly smartphone with reliable performance for everyday use.", "price": 349.99 }
{ "name": "PixelMaster Pro DSLR", "category": "Cameras and Camcorders", "brand": "PixelMaster", "model_number": "PM-DSLR500", "warranty": "2 years", "rating": 4.8, "features": [ "30.4MP full-frame sensor", "4K video", "Dual Pixel AF", "3.2-inch touchscreen" ], "description": "Unleash your creativity with this professional-grade DSLR camera.", "price": 1999.99 }
{ "name": "ActionX Waterproof Camera", "category": "Cameras and Camcorders", "brand": "ActionX", "model_number": "AX-WPC100", "warranty": "1 year", "rating": 4.6, "features": [ "20MP sensor", "4K video", "Waterproof up to 50m", "Wi-Fi connectivity" ], "description": "Capture your adventures with this rugged and versatile action camera.", "price": 299.99 }
{ "name": "SonicBlast Wireless Headphones", "category": "Audio and Headphones", "brand": "SonicBlast", "model_number": "SB-WH200", "warranty": "1 year", "rating": 4.7, "features": [ "Active noise cancellation", "50mm drivers", "30-hour battery life", "Comfortable earpads" ], "description": "Immerse yourself in superior sound quality with these wireless headphones.", "price": 149.99 }
"""

# 为我们的用例定义一个合适的系统消息
customer_agent_sysmessage = f"""
您是一位客户服务代理,负责回答客户关于产品目录中产品的疑问。
产品目录将用三个反引号分隔,即 ```。
以友好和人性化的语气回复,并提供产品目录中可用的详细信息。

产品目录: ```{product_information}```
"""

# 初始化模型的记忆
customer_agent_history = [{'role': 'system', 'content': customer_agent_sysmessage}]</code>

我們可以進一步使用此佈爾值來將響應發送給用戶(如果 QA 代理評估為 True)或讓模型獲得第二次機會來生成新響應(如果 QA 代理評估為 False)。

演示代理交互

讓我們把所有東西放在一起!

鑑於我們已經初始化了兩個內存(分別帶有它們的系統消息和附加信息),每個客戶請求都可以按如下方式處理:

<code>user_prompt = "你们商店里最好的电视是什么?"

customer_agent_response = gpt_call(user_prompt, customer_agent_history)
print(customer_agent_response)

# 输出:在我们商店里,UltraView QLED 电视被认为是最好的电视。它的评分为 4.9,并提供 65 英寸 QLED 显示屏和 8K 分辨率。它还具有 Quantum HDR、Dolby Vision 和智能电视功能。凭借其逼真的色彩和令人难以置信的清晰度,这款高端 QLED 电视可提供身临其境的观看体验。UltraView QLED 电视的价格为 2499.99 美元,并提供 3 年保修。</code>

如上所述,我們已經根據其正確性過濾了響應。我留給您決定如何處理不合適的響應的任務。我們提出了向客戶代理髮送反饋並要求其重試的想法,但又如何要求 QA 代理改用更好的響應呢?有很多可能性!

結論

在本文中,我們探討了使用 GPT 模型作為其他同類模型實例的審核器的潛力。我們已經證明,導致我們在應用程序中使用 LLM 模型的相同強大功能可以幫助我們的應用程序提高用戶交互的準確性和完整性。

與誤解相反,實施審核級別並不一定意味著增加應用程序的複雜性,而且,正如我們所展示的那樣,有時它可以通過幾行精心設計的代碼來實現,從而顯著升級應用程序的功能。

在當今的 AI 驅動世界中,負責任的 LLM 審核勢在必行。這不僅僅是一種選擇,而是一種道德義務。通過集成 AI 審核,我們確保我們的應用程序不僅強大,而且可靠且符合道德規範。讓我們以負責任的態度推進開發,以便我們能夠在維護準確性的同時繼續從 AI 中獲益。

感謝您的閱讀!如果您喜歡 AI 審核這個主題,我鼓勵您繼續閱讀《促進負責任的 AI:ChatGPT 中的內容審核》作為後續資料!

以上是通過GPT模型調節CHATGPT響應的綜合指南的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn