最佳實務強化防護機制
減少幻覺
透過允許不確定性、以直接引述作為回應依據,以及使用引用來驗證主張,將 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.進階技巧
-
思維鏈驗證: 搭配
display: "summarized"使用思考,並在答案看起來有誤時,檢視thinking區塊中的摘要推理內容。這可以揭示有缺陷的邏輯或假設。 -
Best-of-N 驗證: 讓 Claude 多次執行相同的提示,並比較輸出結果。輸出之間的不一致可能表示存在幻覺。
-
迭代改進: 將 Claude 的輸出作為後續提示的輸入,要求其驗證或擴充先前的陳述。這可以發現並修正不一致之處。
-
限制外部知識: 明確指示 Claude 僅使用所提供文件中的資訊,而不使用其一般知識。
這個頁面有幫助嗎?