Hallucination Mitigation: RAG, Decoding, and Training › Measuring Hallucination Mitigation

Michael BrenndoerferMarch 20, 20264 min read
Language AI HandbookAll chapters
Part 56 of 67Hallucination and Factuality
Chapter 432Hallucination Mitigation: RAG, Decoding, and Training › Measuring Hallucination Mitigation
Reading section 9 of 12 · Measuring Hallucination Mitigation · 4 minSection 9 of 12 · 4 min

Book contents

Section 9 of 12 · 4 min read

Hallucination Mitigation: RAG, Decoding, and Training › Measuring Hallucination MitigationOne section · Sections in this chapter9 / 12 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Deploying mitigation strategies without measuring their effect is flying blind. Effective evaluation requires benchmarks that test the specific failure modes your mitigation is designed to address, and metrics that capture both the rate of hallucination and the model's calibration.

Benchmarks for Factual Accuracy

Several benchmarks have become standard for evaluating factual accuracy in language models:

TruthfulQA tests whether models give truthful answers to questions that many humans answer incorrectly due to common misconceptions. A model that merely reproduces training data will score poorly, because training data contains the misconceptions. The benchmark specifically targets the tendency of capable models to generate plausible-sounding falsehoods.

FELM (Factuality Evaluation of Large Language Models) evaluates factuality across multiple domains (science, medicine, finance, law) by having models generate responses and then checking specific factual claims against verified sources. FELM provides domain-specific breakdowns, making it useful for identifying where a model has strong versus weak factual coverage.

FActScore (described earlier in the Post-Hoc Verification section) evaluates long-form generation by decomposing responses into atomic claims and verifying each one. This is particularly useful for evaluating mitigation strategies on biography, entity description, and summarization tasks where hallucination is fine-grained rather than binary.

HaluEval focuses on hallucination in dialogue and question answering, with tasks that test whether the model can identify hallucinated versus faithful responses. It is useful both for evaluation and for constructing training data for DPO-based mitigation.

Calibration Evaluation

Measuring whether a model's expressed uncertainty is calibrated requires comparing stated confidence to empirical accuracy. The standard tool is an expected calibration error (ECE) analysis:

ECE=∑b=1B∣Bb∣n∣acc(Bb)−conf(Bb)∣\text{ECE} = \sum_{b=1}^{B} \frac{|B_b|}{n} \left| \text{acc}(B_b) - \text{conf}(B_b) \right|

where:

  • BbB_b: a bin of predictions with confidence scores falling in the same range
  • acc(Bb)\text{acc}(B_b): the actual accuracy within bin BbB_b
  • conf(Bb)\text{conf}(B_b): the average confidence within bin BbB_b
  • nn: the total number of predictions

A model with ECE close to 0 is well-calibrated: when it says it is 80% confident, it is right 80% of the time. A model with high ECE is miscalibrated: its stated confidence does not track its actual accuracy. Most language models are overconfident in their factual claims, meaning ECE analysis will show that their high-confidence claims are correct less often than their confidence implies.

Out[15]:
Visualization
Calibration curve chart with three lines and a perfect calibration diagonal reference.
Calibration curves comparing an overconfident model, a well-calibrated model, and an underconfident model. The diagonal dashed line represents perfect calibration, where stated confidence equals empirical accuracy. The overconfident model (red) lies below the diagonal: when it claims 80% confidence, its actual accuracy is only around 60%. The underconfident model (green) lies above the diagonal: it achieves higher accuracy than its stated confidence suggests. The well-calibrated model (blue) tracks close to the diagonal. Expected calibration error (ECE) quantifies the average deviation from the diagonal, with lower values indicating better calibration.

End-to-End Evaluation

For production systems, the most meaningful evaluation is end-to-end: measure the rate of factual errors on a representative sample of real user queries with ground truth labels. This is expensive (it requires human annotation at scale), but it is the only evaluation that captures the full distribution of failure modes in your deployment context.

A practical compromise is periodic automated evaluation on a curated validation set, with human spot-checking to catch systematic errors that the automated metrics miss. The validation set should be refreshed periodically to include new query types and to avoid overfitting mitigation strategies to a fixed benchmark.