模拟各种大型语言模型(LLM)失败方案,以测试依赖于语言模型的应用程序的复原能力。
配置示例
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.0.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.0.0/languagemodelfailureplugin.schema.json",
"failures": [
"Hallucination",
"PlausibleIncorrect"
]
}
}
配置属性
| 资产 | Description | 违约 |
|---|---|---|
failures |
要模拟的特定故障类型的数组。 如果未指定,插件将从所有可用的故障类型中随机选择。 | 所有可用故障 |
可用失败类型
该插件支持模拟常见 LLM 行为的以下故障类型:
| 失败类型 | Description |
|---|---|
AmbiguityVagueness |
提供模棱两可或模糊的响应 |
BiasStereotyping |
在响应中引入偏见或陈规定型 |
CircularReasoning |
在解释中使用循环推理 |
ContradictoryInformation |
提供相互矛盾的信息 |
FailureDisclaimHedge |
使用过多的免责声明或对冲 |
FailureFollowInstructions |
无法按照特定说明进行作 |
Hallucination |
生成 false 或组成信息 |
IncorrectFormatStyle |
以不正确的格式或样式提供响应 |
Misinterpretation |
错误解释用户的请求 |
OutdatedInformation |
提供过时或过时的信息 |
OverSpecification |
提供不必要的详细响应 |
OverconfidenceUncertainty |
显示对不确定信息的过度置信 |
Overgeneralization |
进行过度广泛的通用化 |
OverreliancePriorConversation |
过度依赖以前的聊天上下文 |
PlausibleIncorrect |
提供合理但不正确的信息 |
自定义失败类型
可以通过在~appFolder/prompts目录中创建.prompty文件来添加自定义失败类型。 文件必须命名lmfailure_<failure>.prompty为以烤肉串(例如,my-failure)编写的位置<failure>。 在插件配置中,使用 PascalCase 引用它(例如, MyFailure)。
使用场景
LanguageModelFailurePlugin 旨在帮助开发人员针对各种 LLM 故障模式测试其应用程序:
- 幻觉测试:验证应用是否正确处理虚假信息
- 偏差检测:测试对偏置内容或陈规定型内容的响应
- 格式验证:确保应用处理格式不正确的响应
- 说明:当 LLM 不遵循说明时测试复原能力
- 不确定性处理:验证应用是否管理过度满意的错误响应