最佳實務強化防護機制
減少幻覺
透過允許不確定性、以直接引述作為回應依據,以及使用引用來驗證主張,將 Claude 輸出中的幻覺降至最低。
即使是最先進的語言模型,例如 Claude,有時也可能生成與事實不符或與給定上下文不一致的文本。這種現象稱為「hallucination」(幻覺),可能會削弱您的 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.
<policy>
{{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.進階技巧
-
思維鏈驗證(Chain-of-thought verification):要求 Claude 在給出最終答案之前逐步解釋其推理過程。這可以揭露有缺陷的邏輯或假設。
-
N 選最佳驗證(Best-of-N verification):使用相同的提示多次執行 Claude,並比較各次輸出。輸出之間的不一致可能表示存在幻覺。
-
迭代式精煉(Iterative refinement):將 Claude 的輸出作為後續提示的輸入,要求它驗證或擴充先前的陳述。這可以發現並修正不一致之處。
-
外部知識限制(External knowledge restriction):明確指示 Claude 僅使用所提供文件中的資訊,而不使用其一般知識。
Was this page helpful?