Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:ALwrity ALwrity Hallucination Detection

From Leeroopedia
Knowledge Sources
Domains NLP, Fact_Checking, LLM_Safety
Last Updated 2026-10-24 00:00 GMT

Overview

Mechanism that verifies the factual claims in LLM-generated text by extracting claims, retrieving external evidence, and classifying each claim as supported, refuted, or un verifiable.

Description

Hallucination detection is the post-generation process of checking whether the factual assertions an LLM produced are grounded in external sources. LLMs generate text by sampling from a learned distribution; they have no built-in notion of truth and can produce fluent, confident statements that are factually wrong (hallucinations). A detection pipeline addresses this by decomposing the text into discrete verifiable claims, retrieving evidence for each from a search corpus, and then classifying each claim against the evidence.

The standard three-step pipeline is: (1) claim extraction — prompt the LLM to list atomic factual assertions in the text; (2) evidence retrieval — query a search API (Exa, Google) for each claim; (3) verification — prompt the LLM to classify each claim as supported, refuted, or insufficient_information given the retrieved evidence, with a confidence score. The aggregate confidence (fraction of supported claims) signals whether the text is trustworthy enough to publish.

Usage

Use this principle when:

  • Generated content makes factual claims that could be wrong (blog posts, news summaries).
  • A publish gate must block content with too many refuted claims.
  • Each claim needs a traceable evidence source for auditability.
  • Cost control requires a daily rate limit on expensive search/LLM calls.

Theoretical Basis

The pipeline is a retrieval-then-verify loop:

# Abstract hallucination detection (NOT a real implementation)
def detect(text):
    claims = llm_extract_claims(text)             # step 1
    results = []
    for claim in claims:
        evidence = search(claim.text)              # step 2
        verdict = llm_verify(claim, evidence)      # step 3
        results.append(verdict)                      # supported | refuted | insufficient
    confidence = sum(r.supported for r in results) / len(results)
    return HallucinationResult(claims=results, overall_confidence=confidence)

The key design choice is that verification uses external evidence, not the model's own confidence, because the model cannot reliably self-assess factual accuracy.

Practical Guide

  • External evidence, not self-confidence.' Always verify against retrieved sources; never trust the model's own confidence score as a truth signal.
  • Atomic claims.' Break text into single-fact claims so each can be verified independently.
  • Three-way classification.' Include insufficient_information as a first-class outcome; do not force a binary supported/refuted.
  • Rate limiting.' Gate expensive search calls with a daily cap so cost does not scale unbounded.
  • Publish gate.' Set a minimum overall-confidence threshold below which content is held for human review.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment