共用方式為


LanguageModelFailurePlugin

模擬各種大型語言模型(LLM)失效情境,以測試依賴語言模型應用程式的韌性。

一張用開發代理模擬語言模型失敗回應的命令提示字元截圖,針對一個 LLM API 請求。

設定範例

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.1.0/rc.schema.json",
  "plugins": [
    {
      "name": "LanguageModelFailurePlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "languageModelFailurePlugin"
    }
  ],
  "urlsToWatch": [
    "https://api.openai.com/*",
    "http://localhost:11434/*"
  ],
  "languageModelFailurePlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.1.0/languagemodelfailureplugin.schema.json",
    "failures": [
      "Hallucination",
      "PlausibleIncorrect"
    ]
  }
}

組態屬性

房產 Description 預設
failures 模擬各種特定故障類型。 若未指定,外掛會隨機從所有可用的故障類型中選擇。 所有可用故障

可用的失效類型

該外掛支援以下模擬常見大型語言模型行為的失敗類型:

失敗類型 Description
AmbiguityVagueness 提供模糊或模糊的回應
BiasStereotyping 在回答中引入偏見或刻板印象
CircularReasoning 在解釋中使用循環推理
ContradictoryInformation 提供矛盾資訊
FailureDisclaimHedge 使用過度免責聲明或避險
FailureFollowInstructions 未能遵循特定指示
Hallucination 產生虛假或捏造的資訊
IncorrectFormatStyle 提供格式或風格錯誤的回應
Misinterpretation 誤解使用者的請求
OutdatedInformation 提供過時或過時的資訊
OverSpecification 提供不必要的詳細回應
OverconfidenceUncertainty 顯示對不確定資訊過度自信
Overgeneralization 做了過於籠統的概括
OverreliancePriorConversation 過度依賴之前的對話上下文
PlausibleIncorrect 提供合理但不正確的資訊

自訂故障類型

你可以在目錄中建立 .prompty 檔案 ~appFolder/prompts 來新增自訂的失敗類型。 檔案必須命名 lmfailure_<failure>.prompty ,其中 <failure> 以 kebab 大寫寫成(例如 my-failure)。 在外掛設定中,使用 PascalCase 來參考(例如 MyFailure)。

使用場景

LanguageModelFailurePlugin 設計用來協助開發者測試應用程式針對各種大型語言模型(LLM)的故障模式:

  • 幻覺測試:確認你的應用程式能妥善處理錯誤資訊
  • 偏見偵測:測試對偏見或刻板印象內容的回應
  • 格式驗證:確保您的應用程式能處理格式錯誤的回覆
  • 以下指令:當 LLM 不遵守指令時,測試韌性
  • 確定性處理:確認你的應用程式能處理過度自信且錯誤的回答

後續步驟