CHAPTER 16

✅ Chain-of-Verification

Have LLMs Fact-Check Themselves to Reduce Hallucinations

Learning Objectives:
Learn the Chain-of-Verification (CoVe) technique for catching LLM hallucinations. Understand the 4-step verification pipeline, implement fact-checking in medical AI, and compare outputs with/without verification.

Original Paper

Citation:
Dhuliawala, S., Komeili, M., Xu, J., Raheja, V., Li, M., & Boureau, Y.-L. (2023). "Chain-of-Verification Reduces Hallucination in Large Language Models." arXiv preprint arXiv:2309.11495.

ArXiv: https://arxiv.org/abs/2309.11495
Authors: Shehzaad Dhuliawala, Mojtaba Komeili, Jing Xu, Varun Raheja, Manzil Zaheer, Mihran Boureau
Date: September 21, 2023

The Hallucination Problem

LLMs can confidently generate false information. This is dangerous in high-consequence domains like medicine. CoVe solves this by having the model verify its own claims before finalizing answers.

The Core Problem (Dhuliawala et al., 2023):
"Large language models are prone to hallucinating facts, especially in knowledge-intensive tasks. While Chain-of-Thought reasoning helps with complex reasoning, it doesn't address hallucination of facts."

The 4-Step CoVe Pipeline

Step 1: Generation LLM generates initial response Draft answer Step 2: Decompose Break into atomic factual claims "List claims" Step 3: Verify Independently check each claim "Is this claim true?" Step 4: Correct Fix errors, finalize response Verified output Example: Medical Drug Information Initial Response: "Aspirin is a beta-blocker commonly used for high blood pressure. It reduces inflammation and treats migraine headaches." Step 2 - Decomposed Claims: Claim 1: "Aspirin is a beta-blocker" Claim 2: "Used for high blood pressure" Claim 3: "Reduces inflammation" Claim 4: "Treats migraine headaches" Step 3 - Verification: ❌ Claim 1 FALSE: Aspirin is an NSAID, not a beta-blocker ❌ Claim 2 FALSE: Aspirin is NOT first-line for hypertension ✓ Claim 3 TRUE: Aspirin does reduce inflammation ✓ Claim 4 TRUE: Aspirin helps with migraines Step 4 - Corrected Response: "Aspirin is an NSAID (non-steroidal anti-inflammatory drug). It reduces inflammation and is used to treat pain and migraines. It is NOT a beta-blocker and is not a first-line treatment for hypertension."

Figure 1 (Dhuliawala et al., 2023): Chain-of-Verification 4-step pipeline with medical example

Why Verification Works

The key insight: LLMs can verify facts (checking) better than they can generate correct facts (production). By separating generation from verification, we catch errors the model would otherwise make confidently.

Without CoVe With CoVe
LLM generates confident but false statements LLM generates, then self-verifies and corrects
No way to catch hallucinations Verification step catches many errors
User might trust the false information Final answer is more reliable (higher accuracy)
No transparency into confidence Explicit verification shows what was fact-checked

Implementation: Medical Fact-Checking

# Chain-of-Verification implementation for medical AI
from anthropic import Anthropic

client = Anthropic()

def cove_medical_response(question):
    """Apply CoVe to medical question answering"""

    # Step 1: Generation
    generation_prompt = f"""
Answer this medical question:
{question}

Provide a comprehensive answer."""

    generation = client.messages.create(
        model="claude-3-5-sonnet-20241022",
        max_tokens=500,
        messages=[{"role": "user", "content": generation_prompt}]
    )
    initial_response = generation.content[0].text

    # Step 2: Decompose claims
    decompose_prompt = f"""
From this medical response, list ALL factual claims:

Response: "{initial_response}"

Format:
CLAIM 1: [claim]
CLAIM 2: [claim]
...

Focus on specific, verifiable claims (drug names, dosages, indications, side effects)."""

    decompose = client.messages.create(
        model="claude-3-5-sonnet-20241022",
        max_tokens=500,
        messages=[{"role": "user", "content": decompose_prompt}]
    )
    claims = decompose.content[0].text

    # Step 3: Verify each claim independently
    verify_prompt = f"""
Fact-check these medical claims. For EACH claim, state if it's TRUE or FALSE.

Claims:
{claims}

For each claim, provide:
- CLAIM: [the claim]
- CORRECT: [TRUE or FALSE]
- REASON: [why you believe this]

Be strict with medical facts. Err on the side of caution for safety-sensitive claims."""

    verify = client.messages.create(
        model="claude-3-5-sonnet-20241022",
        max_tokens=800,
        messages=[{"role": "user", "content": verify_prompt}]
    )
    verification_results = verify.content[0].text

    # Step 4: Correct and finalize
    correct_prompt = f"""
Original response:
{initial_response}

Verification results:
{verification_results}

Generate a CORRECTED response that:
1. Removes false claims
2. Adds any important corrections noted in verification
3. Explicitly notes when claims are well-established vs still being researched
4. Includes a note: "This response has been fact-checked for accuracy."

Corrected response:"""

    correct = client.messages.create(
        model="claude-3-5-sonnet-20241022",
        max_tokens=600,
        messages=[{"role": "user", "content": correct_prompt}]
    )
    final_response = correct.content[0].text

    return {
        "initial": initial_response,
        "claims": claims,
        "verification": verification_results,
        "final_verified": final_response
    }


# Example usage
result = cove_medical_response(
    "Is aspirin safe for patients with a history of GI ulcers?"
)

print("=== INITIAL RESPONSE ===")
print(result["initial"])
print("\n=== VERIFICATION RESULTS ===")
print(result["verification"])
print("\n=== VERIFIED FINAL RESPONSE ===")
print(result["final_verified"])
            

Empirical Results from Paper

Dhuliawala et al. tested CoVe on long-form generation tasks and found significant improvements:

Results from the Paper

Task Without CoVe With CoVe Improvement
Biographical QA (Hallucination) Baseline +5.8% accuracy Fewer false claims
Fact Checking Baseline +7.2% accuracy Better error detection

Key Finding: CoVe especially helps in scenarios with strong hallucination tendency. The model's verification pass catches its own false statements.

When CoVe is Most Valuable

Use CoVe When:

  • ✓ Long-form generation (biographies, summaries, medical explanations)
  • ✓ Fact-sensitive domains (medicine, law, finance)
  • ✓ Knowledge-intensive questions (anything requiring specific facts)
  • ✓ High-consequence decisions (patient safety, legal advice)
  • ✓ You want auditable outputs (show what was verified)
Limitations of CoVe:
✗ Slow (requires multiple LLM calls)
✗ Model might verify false claims as correct if knowledge is limited
✗ Doesn't help if the fundamental knowledge is wrong
✗ Still requires human review in critical cases

Key Takeaways

  • Chain-of-Verification = 4-step process: generate → decompose → verify → correct
  • Catches hallucinations = LLMs verify better than they generate
  • Critical for medical AI = fact-checking before final output
  • More reliable answers = 5-7% accuracy improvement in paper
  • Trade-off: Slower (4 LLM calls) but much more trustworthy

Further Reading

Original Paper:
Dhuliawala, S., Komeili, M., Xu, J., Raheja, V., Li, M., & Boureau, Y.-L. (2023). "Chain-of-Verification Reduces Hallucination in Large Language Models." arXiv preprint arXiv:2309.11495.
Available on ArXiv: https://arxiv.org/abs/2309.11495

🎯 Ready for Assessment?

10 Questions
~10 mins
70% to Pass
Take Quiz Now →