Skip to main content

Cleanlab

Cleanlab 為進入 AI 和 RAG 解決方案的每個資料點以及從中產生的每個預測添加自動化和信任。

使用 Cleanlab Components將 Cleanlab Evaluations 與 AgentBuilder 整合,並使用 Cleanlab 的評估和補救套件解鎖可信任的 agents、RAG 和 LLM 管道。

您可以使用這些Components以介於 01 之間的分數量化任何 LLM 回應的可信度,並解釋回應為何良好或不良。對於具有上下文的 RAG 或 agent 管道,您可以使用量化分數評估上下文充足性、依據性、有用性和查詢清晰度。此外,您可以使用警告或後備答案補救低信任回應。

需要使用 Cleanlab API 金鑰進行驗證。

Cleanlab Evaluator

Cleanlab Evaluator Components使用 Cleanlab 評估和解釋提示和回應配對的可信度。如需分數運作方式的詳細資訊,請參閱 Cleanlab 文件

Cleanlab Evaluator 參數

某些參數在視覺編輯器中預設為隱藏。 您可以透過 Components的標頭選單 中的 Controls 修改所有參數。

NameTypeDescription
system_promptMessage輸入參數。前置到提示的系統訊息。選用。
promptMessage輸入參數。面向使用者的 LLM 輸入。
responseMessage輸入參數。要評估的模型回應。
cleanlab_api_keySecret輸入參數。您的 Cleanlab API 金鑰。
cleanlab_evaluation_modelDropdown輸入參數。Cleanlab 使用的評估模型,例如 GPT-4 或 Claude。這不需要是生成回應的相同模型。
quality_presetDropdown輸入參數。評估速度和準確性之間的權衡。

Cleanlab Evaluator 輸出

Cleanlab Evaluator Components有三個可能的輸出。

NameTypeDescription
scorenumber, float顯示介於 0 和 1 之間的信任分數。
explanationMessage提供信任分數的解釋。
responseMessage返回原始回應,以便輕鬆鏈接到 Cleanlab Remediator Components。

Cleanlab Remediator

Cleanlab Remediator Components使用來自 Cleanlab Evaluator Components 的信任分數來決定是否顯示、警告或替換 LLM 回應。

此Components具有分數閾值、警告文字和後備訊息的參數,您可以根據需要自訂。

輸出是 Remediated Response (remediated_response),這是一個 Message,包含應用補救邏輯後向使用者顯示的最終訊息。

Cleanlab Remediator 參數

NameTypeDescription
responseMessage輸入參數。要潛在補救的回應。
scoreNumber輸入參數。來自 CleanlabEvaluator 的信任分數。
explanationMessage輸入參數。如果顯示警告,要附加的解釋。選用。
thresholdFloat輸入參數。通過回應不變的最低信任分數。
show_untrustworthy_responseBoolean輸入參數。如果回應被判定為不可信,是否顯示或隱藏帶警告的原始回應。
untrustworthy_warning_textPrompt輸入參數。不可信回應的警告文字。
fallback_textPrompt輸入參數。如果回應被隱藏,則為後備訊息。

Cleanlab RAG Evaluator

Cleanlab RAG Evaluator Components使用 Cleanlab 的評估指標 評估 RAG 和 LLM 管道輸出以獲得可信度、上下文充足性、回應依據性、有用性和查詢容易度。

您可以將此Components與 Cleanlab Remediator Components 配對,以補救來自 RAG 管道的低信任回應。

Cleanlab RAG Evaluator 參數

某些參數在視覺編輯器中預設為隱藏。 您可以透過 Components的標頭選單 中的 Controls 修改所有參數。

NameTypeDescription
cleanlab_api_keySecret輸入參數。您的 Cleanlab API 金鑰。
cleanlab_evaluation_modelDropdown輸入參數。Cleanlab 使用的評估模型,例如 GPT-4 或 Claude。這不需要是生成回應的相同模型。
quality_presetDropdown輸入參數。評估速度和準確性之間的權衡。
contextMessage輸入參數。來自您的 RAG 系統的檢索上下文。
queryMessage輸入參數。原始使用者查詢。
responseMessage輸入參數。基於上下文和查詢的模型回應。
run_context_sufficiencyBoolean輸入參數。評估上下文是否支援回答查詢。
run_response_groundednessBoolean輸入參數。評估回應是否依據上下文。
run_response_helpfulnessBoolean輸入參數。評估回應的有用性。
run_query_easeBoolean輸入參數。評估查詢是否模糊、複雜或對抗性。

Cleanlab RAG Evaluator 輸出

Cleanlab RAG Evaluator Components具有以下輸出選項:

NameTypeDescription
trust_scoreNumber整體信任分數。
trust_explanationMessage信任分數的解釋。
other_scoresDictionary可選啟用的 RAG 評估指標字典。
evaluation_summaryMessage查詢、上下文、回應和評估結果的 Markdown 摘要。
responseMessage返回原始回應,以便輕鬆鏈接到 Cleanlab Remediator Components。

Cleanlab Flow範例

以下範例 Flow顯示如何使用 Cleanlab EvaluatorCleanlab Remediator Components來評估和補救來自任何 LLM 的回應,以及如何使用 Cleanlab RAG Evaluator Components來評估 RAG 管道輸出。

評估和補救來自 LLM 的回應

此FLOW使用 Cleanlab EvaluatorCleanlab Remediator Components評估和補救來自任何 LLM 的回應的可信度。

您可以 下載評估和補救 Flow,然後 將 Flow匯入 到您的 AgentBuilder 實例。 或者,您可以從頭建置 Flow,方法是連接以下Components:

  • 將來自任何 Language ModelAgent Components的 Message 輸出連接到 Cleanlab Evaluator Components的 Response 輸入。
  • Prompt Template Components連接到 Cleanlab Evaluator Components的 Prompt 輸入。

Evaluate response trustworthiness

當您執行FLOW時,Cleanlab Evaluator Components從FLOW返回信任分數和解釋。

Cleanlab Remediator Components使用此信任分數來決定是否輸出原始回應、警告它或用後備答案替換它。

此範例顯示一個被判定為不可信的回應(分數為 .09),並由 Cleanlab Remediator Components標記警告。

Cleanlab Remediator Example

要隱藏不可信回應,請配置 Cleanlab Remediator Components以後備訊息替換回應。

Cleanlab Remediator Example

評估 RAG 管道

作為範例,基於 Vector Store RAG 範本建立 Flow,然後新增 Cleanlab RAG Evaluator Components來評估 Flow的上下文、查詢和回應。 將 RAG FLOW中其他Components的 contextqueryresponse 輸出連接到 Cleanlab RAG Evaluator Components。

Evaluate RAG pipeline

以下是來自 Cleanlab RAG Evaluator Components的 Evaluation Summary 輸出的範例:

Evaluate RAG pipeline

Evaluation Summary 包括查詢、上下文、回應和所有評估結果。在此範例中,Context SufficiencyResponse Groundedness 分數很低(分數為 0.002),因為上下文不包含查詢的資訊,且回應不依據上下文。

Search