Real-Time Detection of Hallucinated Entities in Long-Form Generation

Oscar Obeso, Andy Arditi, Javier Ferrando, Joshua Freeman, Cameron Holmes, Neel Nanda

TL;DR

Existing hallucination detection methods for Large Language Models (LLMs) are often too slow or expensive for real-world applications because they rely on heavy post-generation verification. This paper introduces a lightweight, streaming approach that trains linear and LoRA probes on a model's internal hidden states to flag entity-level hallucinations token-by-token. Running directly within the model's forward pass, these probes achieve state-of-the-art detection accuracy with negligible computational overhead, enabling real-time interventions like selective abstention.

What Problem Does This Paper Address?

As LLMs are increasingly deployed in high-stakes domains like medicine and law, factual reliability is paramount. However, these models frequently "hallucinate"—generating plausible-sounding but entirely fabricated information.

While current research has made progress in detecting hallucinations in short-form question-answering (QA), real-world usage typically involves open-ended, long-form generation. In long-form text, correct and incorrect claims are deeply intertwined. Existing long-form detection frameworks (like SAFE or FActScore) rely on expensive multi-step pipelines that extract claims, query external search engines, and use a secondary LLM judge to verify the text after it has been fully generated. This introduces massive latency and cost, making real-time streaming detection impossible. The authors address this gap by shifting the focus from post-hoc sentence-level claim verification to real-time, token-level entity verification.

Methods

The core idea is to treat hallucination detection as a token-classification task operating directly on the internal representations of the LLM.

  1. Entity-Level Focus: Instead of evaluating abstract claims, the method targets concrete entities (names, dates, citations). Entities have clean token boundaries, making them ideal for token-level sequence labeling.
  2. Automated Annotation Pipeline: To build a training dataset, the authors use a frontier LLM (Claude 4 Sonnet) augmented with web search to automatically extract entities from long-form generations and label them as "Supported," "Not Supported," or "Insufficient Information." Every token within a fabricated entity span is assigned a positive hallucination label.
  3. Internal Probing: Using these token labels, the authors train lightweight classifiers on top of the target LLM's hidden activations (specifically at layer $\sim 95\%$ of the model's depth). They experiment with two architectures:
  4. Linear Probes: Simple linear layers that read hidden states without modifying the underlying model parameters.
  5. LoRA Probes: Low-Rank Adaptation parameters integrated into the model layers to optimize internal representations for detection.
  6. KL Regularization: To prevent LoRA training from degrading the model's general capabilities or altering its output distribution, the authors introduce a Kullback-Leibler (KL) divergence penalty against the original frozen model.
Figure 3: Token-level annotation pipeline. We construct LongFact++, a large set of prompts spanning diverse domains to elicit entity-dense generations. The target LLM (e.g., Llama) produces long-form completions containing both factual and hallucinated content. A frontier LLM with web search (e.g., Claude) then identifies entities within each generation, verifies them against external sources, and produces labels indicating which entities are supported and which are not. The result is a dataset in which every token is annotated to indicate whether it forms part of a hallucination.

Datasets

The authors train and evaluate their approach across four model families using several key datasets:

  • LongFact++: A newly introduced dataset that expands the original LongFact benchmark by 10x. It contains ~22,000 fact-seeking prompts across four distinct domains: topic-focused queries, biographies, citation-heavy research topics, and landmark legal cases.
  • HealthBench: A held-out evaluation dataset consisting of long-form medical dialogue prompts to test cross-domain generalization.
  • TriviaQA: A standard short-form QA dataset used to evaluate how well the probes transfer to brief generation settings.
  • MATH: A held-out dataset testing out-of-distribution mathematical reasoning, which naturally lacks discrete entities but serves as a test for broader correctness signaling.

Key Insights and Ideas

  • Long-Form Supervision is Essential: Probes trained exclusively on long-form data generalize remarkably well to short-form QA tasks. However, the reverse is not true: probes trained only on short-form data suffer a $\sim 0.10$ AUC drop when evaluated on long-form text. This indicates that long-form data exposes unique internal features of factuality that short-form data cannot replicate.
  • Cross-Model Transferability: Probes trained on one model's internal states can successfully detect hallucinations in entirely different model families. This strongly suggests that the internal representation of "knowing vs. hallucinating" captures fundamental, model-agnostic features of truthfulness rather than model-specific artifacts.
  • Generalization Beyond Entities: Despite being trained strictly to identify fabricated entities, the probes successfully flag incorrect answers in the out-of-distribution MATH dataset. The probes appear to be capturing a broader internal signal of model correctness.

Key Results

Evaluating across multiple model families, the token-level probes consistently out-performed traditional uncertainty-based baselines (such as token perplexity and semantic entropy).

For Llama-3.3-70B on the LongFact benchmark, the LoRA probe achieved an AUC of 0.90, vastly outperforming the computationally expensive semantic entropy baseline, which only managed an AUC of 0.71.

Figure 1: Token-level probes detect hallucinated entities. In long-form generation settings (Long- Fact, HealthBench), linear probes far outperform uncertainty-based baselines, with LoRA probes improving performance even further. Our probes also perform well in short-form settings (TriviaQA), and out-of-distribution reasoning domains (MATH). Results for Llama-3.3-70B are displayed.

Furthermore, the authors demonstrated a real-time intervention called selective answering on the SimpleQA benchmark. By monitoring the probe scores token-by-token and halting generation to output an abstention ("I don't know") the moment the score crossed a threshold, they successfully boosted the model's conditional accuracy on attempted questions from under 30% to over 50%.

Figure 2: An annotated example of hallucination detection in long-form legal text. The underlines indicate entity spans labeled by our annotation pipeline: green denotes entities labeled as supported, while red denotes entities labeled as hallucinated. Hallucination detection probe scores for each token are shown as yellow highlights, with the intensity reflecting the score’s magnitude (scores below 0.4 are not shown). Note that while the annotation pipeline predominantly identifies and labels entities (e.g., “Jonathan M. Madero”, “BlackBerry Curve 8330”), this example illustrates the difficulty in cleanly separating entities from non-entities in long-form text. We notice that both our annotation pipeline and our resulting probes sometimes detect broader hallucinations, such as claims, even if they don’t correspond cleanly to an entity (e.g., “at his residence in San Diego,” which is indeed a fabricated detail).

Limitations and Future Work

While promising, the authors highlight several limitations that prevent immediate production deployment:

  • Relational Errors: The entity-level focus misses "relational" hallucinations, where the entities themselves are real but the stated relationship between them is false (e.g., swapping the roles of two real people in a lawsuit).
  • Annotation Noise: The automated LLM-plus-search annotation pipeline achieves an 80.6% recall and a 15.8% false positive rate, meaning the training data contains inherent noise that bounds probe performance.
  • The Reliability Gap: The best LoRA probes top out at $\sim 70\%$ recall at a 10% false positive rate on long-form text. In practice, using these probes for selective answering means sacrificing roughly 50% of correct answers to meaningfully suppress hallucinations.

Future work will focus on scaling token-level detection to broader semantic spans and refining annotation quality to close this reliability gap.

Summary updated

BibTeX
@misc{obeso2025real,
  author = {Oscar Obeso and Andy Arditi and Javier Ferrando and Joshua Freeman and Cameron Holmes and Neel Nanda},
  title = {{Real-Time Detection of Hallucinated Entities in Long-Form Generation}},
  year = {2025},
  eprint = {2509.03531},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.03531},
}
Figure