LLM Output Is Inconsistent(LLM 输出不稳定)
知识库位置:
FDE Knowledge Base/03 Engineering/Troubleshooting/LLM-Output-Is-Inconsistent.md
Problem(问题)
Section titled “Problem(问题)”同样输入多次执行,输出格式或内容变化很大。
Symptoms(症状)
Section titled “Symptoms(症状)”例如第一次:
{ "priority": "high"(优先级:高)}第二次:
This looks urgent.(这看起来很紧急)第三次:
Priority: Medium(优先级:中)Possible Causes(可能原因)
Section titled “Possible Causes(可能原因)”Task Is Ambiguous(任务含糊)
Section titled “Task Is Ambiguous(任务含糊)”Prompt(提示词)没有明确判断标准。
Output Format Is Not Enforced(输出格式未被强制)
Section titled “Output Format Is Not Enforced(输出格式未被强制)”只是说:
Return JSON.(返回 JSON)
但没有 Schema(结构定义)。
Too Much Creativity(自由度过高)
Section titled “Too Much Creativity(自由度过高)”任务本身是 Classification(分类),却使用开放式生成方式。
Examples Are Inconsistent(示例彼此矛盾)
Section titled “Examples Are Inconsistent(示例彼此矛盾)”Few-shot Example(少样本示例)本身存在矛盾。
Input Contains Ambiguity(输入含糊)
Section titled “Input Contains Ambiguity(输入含糊)”上游数据不稳定。
Diagnostic Steps(诊断步骤)
Section titled “Diagnostic Steps(诊断步骤)”固定:
- Model(模型)
- Prompt Version(提示词版本)
- Input(输入)
- Config(配置)
执行多次。
比较:
Classification Consistency(分类一致性)Format Consistency(格式一致性)Reasoning Difference(推理差异)Fixes(修复)
Section titled “Fixes(修复)”Use Structured Output(使用结构化输出)
Section titled “Use Structured Output(使用结构化输出)”定义 Schema(结构定义)。
Clarify Decision Rules(明确判定规则)
Section titled “Clarify Decision Rules(明确判定规则)”不要只写:
Decide if urgent.(判断是否紧急)
应该明确:
Urgent if:(满足以下之一即为紧急:)- production outage(生产中断)- security incident(安全事件)- payment failure(支付失败)Use Enum(使用枚举)
Section titled “Use Enum(使用枚举)”例如:
LOW(低)MEDIUM(中)HIGH(高)Validate Output(校验输出)
Section titled “Validate Output(校验输出)”LLM(大语言模型)↓Schema Validation(结构校验)↓Business Validation(业务校验)Prevention(预防)
Section titled “Prevention(预防)”所有 Production(生产)Prompt 都应该:
- Versioned(有版本管理)
- Evaluated(有评估)
- Tested(有测试)
- Monitored(有监控)