# Entity Hallucination Eval

> Evaluates large language models' ability to generate factually correct answers to complex and factual questions while mitigating entity-level hallucinations. It also measures the effectiveness of a real-time hallucination detection mechanism in identifying fabricated or low-confidence entities during generation. Use when the user wants to benchmark on WikiBio GPT-3 dataset, 2WikiMultihopQA, StrategyQA, NQ, or asks about evaluating this task. Reports AUC.

- Skill: `qhjqhj00/entity-hallucination-eval` (Agent Skill)
- Install (CLI): `npx skillmds add qhjqhj00/entity-hallucination-eval`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qhjqhj00/entity-hallucination-eval/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: qhjqhj00 (https://skillmd.com/u/qhjqhj00)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/qhjqhj00/entity-hallucination-eval

---


# entity-hallucination-eval

> Mitigating Entity-Level Hallucination in Large Language Models — Su et al. (2024) (arXiv:2407.09417, 2024)

## What this evaluates

Evaluates large language models' ability to generate factually correct answers to complex and factual questions while mitigating entity-level hallucinations. It also measures the effectiveness of a real-time hallucination detection mechanism in identifying fabricated or low-confidence entities during generation.

## Datasets

- **WikiBio GPT-3 dataset** — total ?; splits: test (-1)
- **2WikiMultihopQA** — total ?; splits: test (-1)
- **StrategyQA** — total ?; splits: test (-1)
- **NQ** — total ?; splits: test (-1)

## Metrics

- `AUC` **(primary)** — range: [0, 1]
  - Area under the Receiver Operating Characteristic curve, measuring the trade-off between true positive and false positive rates for hallucination detection.
- `Exact Match (EM)` — range: [0, 1]
  - Binary score of 1 if the extracted final answer exactly matches the reference answer string, 0 otherwise.
- `F1` — range: [0, 1]
  - Token-level F1 score computed as the harmonic mean of precision and recall over word tokens in the predicted and reference answers.
- `Accuracy` — range: [0, 1]
  - Proportion of correctly answered yes/no questions in StrategyQA.

## Input / output format

**Input**: For generation: Question + top-3 BM25-retrieved Wikipedia passages + few-shot examples (8 for 2WikiMultihopQA/StrategyQA, none for NQ). For detection: GPT-3 generated text passages with factual claims.

**Output**: For generation: Chain-of-thought reasoning followed by a final extracted answer. For detection: A probability or entropy score indicating entity-level hallucination likelihood.

## Scoring recipe

```python
def score_generation(preds, golds):
    em_scores = []
    f1_scores = []
    for p, g in zip(preds, golds):
        em_scores.append(1.0 if p.strip() == g.strip() else 0.0)
        p_tok, g_tok = set(p.split()), set(g.split())
        if not p_tok or not g_tok: continue
        prec = len(p_tok & g_tok) / len(p_tok)
        rec = len(p_tok & g_tok) / len(g_tok)
        f1 = 2 * prec * rec / (prec + rec) if (prec + rec) > 0 else 0.0
        f1_scores.append(f1)
    return {"EM": sum(em_scores)/len(em_scores), "F1": sum(f1_scores)/len(f1_scores)}
```

## Common pitfalls

- Failing to use pattern-matching to extract the final answer from the LLM's chain-of-thought output before computing metrics.
- Applying the 8-shot few-shot prompt template to NQ, which the authors explicitly state should receive zero examples due to its simpler nature.
- Comparing multi-round retrieval baselines without enforcing the single-sentence revision constraint, which inflates retrieval overhead unfairly.

## Evidence (verbatim from paper)

> For the evaluation metrics, we use pattern-matching techniques to extract the final answer from the output of the LLM. This extracted answer is subsequently compared to the reference answer. We employ various methods for this comparison, including the exact match (EM) metric at the answer level and token-level assessments of F1 score, precision, and recall.

## Citation

```bibtex
@misc{su2024mitigating,
  title={Mitigating Entity-Level Hallucination in Large Language Models},
  author={Su et al. (2024)},
  year={2024},
  note={arXiv:2407.09417}
}
```

- arXiv: 2407.09417

