0Pricing
AI Agents · Lesson

Fact-Checking and Hallucination Prevention

Grounding-based verification: every claim must trace to a retrieved source.

The Hallucination Problem in Research Agents

LLMs can generate plausible-sounding claims with no basis in the retrieved sources. In a research agent, this is especially dangerous because the output looks authoritative and is presented with citations that may not actually support the claim.

Hallucination prevention must be a first-class concern.

Grounding: Every Claim Traces to a Source

The core principle of grounding: every factual claim in the final output must be traceable to at least one retrieved document. Claims that cannot be traced are either hallucinated or unsupported — both are unacceptable in a research report.

def check_grounding(claim: str, retrieved_docs: list[dict]) -> dict:
    doc_texts = '\n\n'.join(
        f'[DOC {i+1}] ({d["url"]})\n{d["text"][:800]}'
        for i, d in enumerate(retrieved_docs[:5])
    )
    return {
        'claim': claim,
        'docs':  doc_texts,
        'grounded': None   # to be filled by LLM verifier
    }

All lessons in this course

  1. Multi-Step Research Loop Design
  2. Source Verification and Citation
  3. Structured Report Generation
  4. Fact-Checking and Hallucination Prevention
← Back to AI Agents