Prompt
How do I evaluate hallucinations in LLM answers?
Latest observation
Evaluating hallucinations in LLM answers usually means checking whether the model’s claims are grounded in evidence and factually correct relative to a trusted source.
1) Start by defining “hallucination”
A response is hallucinated if it:
- States facts that are false
- Makes unsupported claims
- Confidently invents details, citations, or reasoning
- Answers beyond the provided context as if it were known
2) Choose the right evaluation type
There are two common settings:
A. Closed-book factual QA
You compare the answer to ground-truth facts.
- Example: “What is the capital of Australia?”
- Hallucination = wrong factual claim
B. Grounded / retrieval-based QA
The answer should be supported by a provided document or knowledge source.
- Example: “Summarize this policy document.”
- Hallucination = claim not supported by the document, even if it happens to be true in the real world
3) Break answers into atomic claims
Don’t judge the response as one blob. Split it into small factual statements.
Example:
“Paris is the capital of France, and it has a population of 2.1 million.”
Atomic claims:
- Paris is the capital of France.
- Paris has a population of 2.1 million.
Then evaluate each claim separately.
4) Verify each claim against evidence
For each claim, label it as:
- Supported
- Contradicted
- Not enough evidence
- Irrelevant / unsupported
Useful sources:
- Provided context/document
- Trusted knowledge base
- Human expert judgment
- Verified external references
5) Use common metrics
Depending on your setup, these are typical:
Precision / hallucination rate
- Of the claims the model made, how many were unsupported or false?
- Hallucination rate = unsupported or false claims / total claims
Factuality / faithfulness
- How many claims are supported by evidence?
- Often used in summarization and RAG evaluation
Attribution accuracy
- For grounded tasks: how often is each answer traceable to the source?
Exact match / F1
- For short QA tasks with known answers
- Useful but not enough for hallucination detection on free-form outputs
6) Evaluate at multiple levels
Hallucinations can happen at:
- Entity level: wrong person/place/date
- Relation level: incorrect relationship between facts
- Numeric level: wrong numbers, percentages, dates
- Causal level: wrong explanation of why something happened
- Citations level: fabricated sources or misquoted sources
7) Use human review when possible
Humans are still the most reliable for nuanced cases:
- Ambiguous claims
- Partial truth
- Complex reasoning
- Domain-specific correctness
A good review rubric:
- Is the claim directly supported?
- Is it partially supported but overstated?
- Is it unsupported?
- Is it plainly false?
8) Automate where you can
For scale, you can use:
- Rule-based checks for dates, numbers, named entities
- Retrieval-based verification
- LLM-as-judge with a strict rubric
- NLI models to test entailment between evidence and claims
Be careful: an LLM judge can itself hallucinate, so calibrate with human-labeled data.
9) Recommended practical workflow
- Collect a set of prompts and model answers
- Split answers into atomic claims
- Gather evidence for each prompt
- Label each claim: supported / contradicted / not enough evidence
- Compute hallucination rate and related metrics
- Review a sample manually to validate the evaluator
- Iterate on prompt, retrieval, or decoding settings
10) If you want a simple scoring rubric
You can assign:
- 2 = fully supported
- 1 = partially supported / vague
- 0 = unsupported or false
Then average across claims or answers.
If you want, I can also give you:
- a rubric template for manual evaluation,
- a Python script to score hallucinations, or
- an LLM-based evaluation prompt you can use directly.