Hallucination Detection
Hallucination detection refers to technical means for judging, after a model has generated output, which statements lack factual basis, contradict the given context, or are simply fabricated. It differs from hallucination mitigation in two paths: mitigation lowers the probability during generation, while detection finds the unreliable parts after generation for blocking, annotation or human review.
Core principles
Common methods fall into four categories. Uncertainty methods, usually written as SelfCheckGPT, sample the same question multiple times; if the answer stays consistent across samples it is more trustworthy, and if key facts change every time it means the model is only completing randomly. It needs only a black-box interface and no external knowledge base, but sampling cost grows linearly with the number of samples.
The second category is retrieval verification: break the answer into atomic facts, retrieve external material item by item, and judge whether each is supported, contradicted or unverifiable. This requires entity recognition and relation extraction, and whether the system has internet access determines the coverage.
The third category is logprob methods: look directly at the probability the model assigns to each token; if the probability at key entities or numbers is abnormally low and entropy is high, the model itself is uncertain. This is the cheapest option for models that expose probabilities, but high or low probability does not strictly correspond to correctness, and confident errors are frequent.
The fourth category is model-judge verification: have another model check the answer sentence by sentence against the context and output three labels, supported, contradicted or unsupported. It has broad coverage but may itself misjudge.
In deployment it is advisable to make detection a pipeline rather than a single point: after generation, do structured extraction to break the answer into checkable atomic propositions, then look up evidence, then assign labels, and finally route by confidence. Low-risk content passes directly, medium-risk content gets a warning, and high-risk content goes to human review or refusal. Keep the labels and evidence of every detection, which supports later accountability and also serves as training signal for the next round of fine-tuning.
Cost must be accounted for clearly: the latency and expense of full retrieval verification may exceed generation itself, so usually only key fields get detailed checking while the rest is coarsely filtered with lightweight self-consistency methods.
Key points
Distinguish extrinsic hallucination from intrinsic hallucination: the former is content inconsistent with objective facts and requires an external knowledge base; the latter contradicts the context provided by the user and only needs a comparable consistency check, with much higher detection accuracy. In RAG scenarios intrinsic hallucination is more controllable and easier to automate.
Real systems mostly use combined strategies: sentence-level self-consistency voting first, then retrieval verification, and finally a model judge providing evidence. Output graded labels rather than binary ones: confirmed, unsupported, contradicted, each handled differently.
Threshold tuning should follow business cost: where missed detection is expensive, lower the threshold and accept more false positives, and vice versa. Also monitor the timeliness of evidence, since outdated material will be misjudged as hallucination.
Common misconceptions
First, assuming low probability means wrong. Highly factual content can also have low probability, professional terminology especially.
Second, asserting contradiction from keyword matching alone. Differences in numbers, units, negations and qualifying conditions are not the same as factual conflict.
Third, disclosing detection results directly to users. Highlighting long passages creates new misunderstandings; a safer approach is to note that this part should be verified and provide a link to the evidence.
Application scenarios
Fallback for knowledge base question answering output, compliance review of medical and legal text, fact checking of summaries and reports, quality screening of evaluation sets, citation grounding for search results, and pre-publication blocking on content generation platforms.