AI Wiki中文/EN

LLM hallucinations: agreement is not evidence

语言模型幻觉

Separate factual truth, document support and sample consistency with a fictional archive.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

A date repeated six times

Imagine a fictional archive founded in 1920. Its catalogue contains a typo: 1921. Six generated answers repeat 1921. They agree with one another and with the supplied document, yet the date is wrong. Three questions have different answers: is the claim true, is it supported by this document, and do other samples repeat it?

Here, a hallucination means a generated factual assertion that is false or lacks the evidence required by the task. These categories need separate labels. A correct fact absent from a short document is unsupported in that document, not thereby false. A task that asks for faithful extraction may reject it even when a broader investigation confirms it. Write down the evidence policy before measuring errors.

TruthfulQA separates truthfulness from informativeness: an abstention can avoid a false assertion while answering nothing. Its first version evaluates a deliberately challenging question set; it does not estimate the error rate of every deployed assistant. TruthfulQA

Repeated answers can share the same factual mistake.
Repeated answers can share the same factual mistake.

Signals, labels and denominators

For an atomic claim c and evidence D, use three support labels. Our fact-table example assumes a key has one value; real documents may contain qualifications or contradictions that require richer annotation.

S(c,D)∈{supported,contradicted,unknown}.S(c,D)\in\{\mathrm{supported},\mathrm{contradicted},\mathrm{unknown}\}.

SelfCheckGPT investigates whether disagreement among sampled generations can help detect unreliable statements. In the first version, one method compares sentence representations with BERTScore; another uses generated multiple-choice questions and answerability checks. This is a detection signal, not independent access to truth. Our program replaces those language components with literal comparisons so every decision is inspectable. SelfCheckGPT

Given N samples, define a deliberately simple inconsistency score. Missing a claim counts as a non-match here, which can penalize a true but infrequently mentioned fact.

I(c)=1−1N∑j=1N1{S(c,Dj)=supported}.I(c)=1-\frac{1}{N}\sum_{j=1}^{N}\mathbf 1\{S(c,D_j)=\mathrm{supported}\}.

Flag scores at least 0.5. A true positive is a flagged false claim; a false positive is a flagged true claim. Labels come from the authored world table, not from the detector itself.

precision=TPTP+FP,recall=TPTP+FN.\mathrm{precision}=\frac{TP}{TP+FP},\qquad \mathrm{recall}=\frac{TP}{TP+FN}.

If no claims are flagged, precision has no denominator. If no claims are false, recall has no denominator. Report either as undefined, not a perfect score. For an answering policy, let a_i indicate acceptance and y_i factual correctness:

coverage=∑iaiM,accuracyanswered=∑iaiyi∑iai.\mathrm{coverage}=\frac{\sum_i a_i}{M},\qquad \mathrm{accuracy}_{\mathrm{answered}}=\frac{\sum_i a_i y_i}{\sum_i a_i}.

Refusing everything gives zero coverage and undefined conditional accuracy. It should not win a useful-answer comparison merely because it made no false statements.

A detector that misses the shared error

The non-AI baseline is exact lookup in a curated fact table. A practical pipeline first splits answers into claims, obtains relevant evidence, assigns support labels and sends unresolved claims to review. Repeated generation is an optional additional signal. Preserve the claim, retrieved passage, source date and decision so a later correction can be traced.

Save the following as a Python file and run it with Python 3.12; only the standard library is needed. All names, facts and samples are invented. Five claims are checked against six samples. With dictionary lookup treated as constant time, C claims and N samples need O(CN) comparisons; storing the sample tables is additional memory. In a real system, N generations and semantic comparisons can dominate latency and token cost.

"""Original fictional archive facts: consistency, document support and truth differ."""
import json,math


def support(claim,evidence):
    if not isinstance(claim,(tuple,list)) or len(claim)!=2 or not all(isinstance(v,str) and v for v in claim):raise ValueError('claim must be a nonempty key/value pair')
    if not isinstance(evidence,dict) or not all(isinstance(k,str) and isinstance(v,str) for k,v in evidence.items()):raise ValueError('string fact table required')
    key,value=claim
    if key not in evidence:return 'unknown'
    return 'supported' if evidence[key]==value else 'contradicted'


def consistency(claim,samples):
    if not isinstance(samples,(list,tuple)) or not 1<=len(samples)<=100:raise ValueError('one to100 comparison samples required')
    labels=[support(claim,s) for s in samples];n=len(labels)
    return dict(match=labels.count('supported'),conflict=labels.count('contradicted'),missing=labels.count('unknown'),inconsistency=1-labels.count('supported')/n)


def detection(scores,false_labels,threshold=.5):
    if not scores or len(scores)!=len(false_labels) or any(type(y) is not int or y not in [0,1] for y in false_labels):raise ValueError('aligned binary labels required')
    if not math.isfinite(threshold) or not 0<=threshold<=1 or any(not math.isfinite(x) or not 0<=x<=1 for x in scores):raise ValueError('scores and threshold must be in[0,1]')
    predicted=[int(x>=threshold) for x in scores];tp=sum(p==1 and y==1 for p,y in zip(predicted,false_labels));fp=sum(p==1 and y==0 for p,y in zip(predicted,false_labels));fn=sum(p==0 and y==1 for p,y in zip(predicted,false_labels));tn=len(scores)-tp-fp-fn
    return dict(tp=tp,fp=fp,fn=fn,tn=tn,precision=tp/(tp+fp) if tp+fp else None,recall=tp/(tp+fn) if tp+fn else None)


def answered(accept,truth):
    if not accept or len(accept)!=len(truth) or any(type(v) is not bool for v in accept+truth):raise ValueError('aligned nonempty boolean lists required')
    count=sum(accept);correct=sum(a and t for a,t in zip(accept,truth))
    return dict(coverage=count/len(accept),accuracy_among_answers=correct/count if count else None,no_false_claims=all(not a or t for a,t in zip(accept,truth)))


def demo():
    world={'year':'1920','city':'Linden','founder':'Mara','collection':'maps'}
    document={'year':'1921','city':'Linden','collection':'maps'}
    claims=[('year','1921'),('city','Linden'),('founder','Mara'),('collection','coins'),('year','1920')]
    samples=[{'year':'1921','city':'Linden','collection':'coins' if i==0 else 'maps',**({'founder':'Mara'} if i<2 else {})} for i in range(6)]
    rows=[dict(claim=list(c),document=support(c,document),world=support(c,world),**consistency(c,samples)) for c in claims]
    truth=[r['world']=='supported' for r in rows];scores=[r['inconsistency'] for r in rows]
    policies={'consistent':[s<.5 for s in scores],'document_supported':[r['document']=='supported' for r in rows],'abstain_all':[False]*len(rows)}
    return dict(world=world,document=document,samples=samples,claims=rows,detection=detection(scores,[int(not t) for t in truth]),policies={k:answered(v,truth) for k,v in policies.items()},scope='All names and fact tables are fictional; literal comparisons are not natural-language entailment.')

if __name__=='__main__':print(json.dumps(demo(),indent=2,allow_nan=False))

The inconsistency scores are 0, 0, 2/3, 5/6 and 1. The false date is never flagged. The true founder is flagged because four samples omit her, and the correct date is flagged because all samples repeat the typo. Thus TP=1, FP=2, FN=1 and TN=1: precision is 1/3 and recall is 1/2. These are results of this constructed example, not a measured model benchmark.

Accepting only consistent claims answers two of five candidates, one correctly. Accepting only document-supported claims happens to make the same choices because the document itself is wrong. A source-backed system still needs source-quality controls.

What to change when the checker fails

More samples may reduce sampling noise without correcting shared misinformation. Use independently maintained evidence when factual verification matters. For extraction, retain an unknown state and distinguish omission from contradiction. For open questions, define acceptable answer variants and an adjudication process; exact string matching is only our teaching baseline.

Choose the flagging threshold on a separate, labeled validation set. Report missed false claims, false alarms, abstention, answer usefulness and cost on untouched cases. High-cost errors may justify review or a narrow verified lookup service. Retrieval, citation checks and calibrated refusal address different parts of this pipeline; none makes the others unnecessary. See confidence calibration and self-consistency.

Predict the failure before running

  1. Does six-way agreement establish that the archive opened in 1921?

Answer: No. All six samples can share the catalogue’s error. Agreement measures relations among outputs, not agreement with the world.

  1. Compute the founder claim’s inconsistency when two samples mention Mara and four omit the founder.

Answer: It is 1−2/6=2/3. The high score does not distinguish omission from a competing founder name; inspect the separate missing and conflict counts.

  1. Is an always-abstaining policy 100% accurate on answered questions?

Answer: Its conditional accuracy is undefined because there are no answered questions. Coverage is zero; “no false claims” alone hides this failure to help.

  1. A product must quote only a supplied manual. Should a true claim absent from that manual pass?

Answer: Not under that evidence contract. Mark it unsupported or request another source; do not label it false merely because the manual omits it.

Read the detection study with its labels

The fixed TruthfulQA version supplies the truthfulness/informativeness distinction. The fixed SelfCheckGPT version supplies the sampling-based detection idea, not our literal algorithm or its numbers. Later repository variants must be read and evaluated separately. Neither source turns consistency into a proof of factual correctness.

Make a prediction, then check

Six samples repeat an incorrect date. What does agreement establish?

Choose one answer

Learning objectives

  • Design a factuality check that accounts for missing evidence, shared mistakes and abstention.
  • Run the original finite experiment and explain its counterexample and scope.

Prerequisites & connections

Explore related knowledge →

References

  1. TruthfulQA: Measuring How Models Mimic Human Falsehoods — v1
    Stephanie Lin; Jacob Hilton; Owain Evans · 2021
  2. SelfCheckGPT: Zero-Resource Black-Box Hallucination Detection for Generative Large Language Models — v1
    Potsawee Manakul; Adian Liusie; Mark J. F. Gales · 2023

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-20 · Single AI author. Viewed PDF4/6, sections2.1/3.2: truthfulness, informativeness and human evaluation; PDF12 viewed incidentally as references. Viewed PDF3/4: sampling consistency, BERTScore/MQAG and the first-version 65-paragraph study; no benchmark reproduced. 4 paired equations and four explained exercises. Truth, document support and sample agreement separated; 1/2/1/1 detection counts, undefined abstention metrics and authored evidence checked.

  • Truth, document support and sample agreement separated; 1/2/1/1 detection counts, undefined abstention metrics and authored evidence checked.
  • Four computed SVG variants per topic;11 numeric/geometry tests and36 responsive cases passed. Twelve selected final captures directly viewed. Full article acceptance recorded separately.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.