减少幻觉
即使是最先进的语言模型,如 Claude,有时也会生成与事实不符或与给定上下文不一致的文本。这种现象被称为"幻觉",可能会损害 AI 驱动解决方案的可靠性。 本指南将探讨减少幻觉并确保 Claude 输出准确可信的技术。
基本的幻觉最小化策略
- 允许 Claude 说"我不知道": 明确给予 Claude 承认不确定性的权限。这种简单的技术可以大幅减少虚假信息。
示例:分析并购报告
| 角色 | 内容 |
|---|---|
| User | As our M&A advisor, analyze this report on the potential acquisition of AcmeCo by ExampleCorp. <report> {{REPORT}} </report> Focus on financial projections, integration risks, and regulatory hurdles. If you're unsure about any aspect or if the report lacks necessary information, say "I don't have enough information to confidently assess this." |
- 使用直接引述进行事实锚定: 对于涉及长文档(>20k tokens)的任务,要求 Claude 在执行任务之前先逐字提取引述。这将其回复锚定在实际文本中,减少幻觉。
示例:审计数据隐私政策
| 角色 | 内容 |
|---|---|
| User | As our Data Protection Officer, review this updated privacy policy for GDPR and CCPA compliance. <br/>{{POLICY}} </policy> 1. Extract exact quotes from the policy that are most relevant to GDPR and CCPA compliance. If you can't find relevant quotes, state "No relevant quotes found." 2. Use the quotes to analyze the compliance of these policy sections, referencing the quotes by number. Only base your analysis on the extracted quotes. |
- 通过引述进行验证:通过让 Claude 为其每项声明引用引述和来源,使回复可审计。你还可以让 Claude 在生成回复后通过找到支持引述来验证每项声明。如果找不到引述,必须撤回该声明。
示例:起草产品发布的新闻稿
| 角色 | 内容 |
|---|---|
| User | Draft a press release for our new cybersecurity product, AcmeSecurity Pro, using only information from these product briefs and market reports. <documents> {{DOCUMENTS}} </documents> After drafting, review each claim in your press release. For each claim, find a direct quote from the documents that supports it. If you can't find a supporting quote for a claim, remove that claim from the press release and mark where it was removed with empty [] brackets. |
进阶技术
-
思维链验证:要求 Claude 在给出最终答案之前逐步解释其推理过程。这可以揭示错误的逻辑或假设。
-
N 选最佳验证:对同一提示词多次运行 Claude 并比较输出。输出之间的不一致可能表明存在幻觉。
-
迭代优化:将 Claude 的输出作为后续提示词的输入,要求其验证或扩展先前的陈述。这可以捕获并纠正不一致之处。
-
外部知识限制:明确指示 Claude 仅使用所提供文档中的信息,而非其通用知识。
Note
请记住,虽然这些技术可以显著减少幻觉,但并不能完全消除它们。始终验证关键信息,特别是对于高风险决策。