Do Androids Know They're Only Dreaming of Electric Sheep?

Sky CH-Wang, Benjamin Van Durme, Jason Eisner, Chris Kedzie · OpenReview

Abstract

We design probes trained on the internal representations of a transformer language model that are predictive of its hallucinatory behavior on in-context generation tasks. To facilitate this detection, we create a span-annotated dataset of organic and synthetic hallucinations over several tasks. We find that probes trained on the force-decoded states of synthetic hallucinations are generally ecologically invalid in organic hallucination detection. Furthermore, hidden state information about hallucination appears to be task and distribution-dependent. Intrinsic and extrinsic hallucination saliency varies across layers, hidden state types, and tasks; notably, extrinsic hallucinations tend to be more salient in a transformer's internal representations. Outperforming multiple contemporary baselines, we show that probing is a feasible and efficient alternative to language model hallucination evaluation when model states are available.

Introduction

Hallucination—the generation of plausible-sounding but ungrounded information—remains a primary obstacle to the deployment of Large Language Models (LLMs). Traditional detection methods typically rely on "black-box" evaluation, comparing generated text against source documents using secondary models like Natural Language Inference (NLI) or GPT-4. However, these approaches are computationally expensive and ignore the internal state of the generating model. This research investigates whether LLMs internally represent their own unfaithfulness, allowing for hallucination detection through the model's own hidden layers.

Methodology

The study utilizes Llama-2-13b across three grounded generation tasks: abstractive summarization (CNN/DailyMail), knowledge-grounded dialogue (Conv-FEVER), and data-to-text generation (E2E). The researchers employed Probing, training small supervised classifiers on the model's internal hidden states to predict hallucinations at the token and response levels.

Three probe architectures were evaluated:

  1. Linear Probes targeting specific layers.
  2. Attention-Pooling Probes incorporating historical context within the response.
  3. Ensemble Probes combining signals across all sublayers (attention and feed-forward).

To ensure robustness, the researchers developed a dataset of over 15,000 utterances, distinguishing between organic hallucinations (natural model errors) and synthetic hallucinations (manually edited ungrounded content).

Key Insights and Internal Representations

Analysis of the probes revealed that hallucination signals are not uniformly distributed. Detection performance typically peaks in the middle layers (layers 10–20), though significant signal is detectable as early as layer 4. This suggests that the model's internal state begins to diverge from grounded representations very early in the generation process.

Visualization of token-level hallucination signals across transformer layers, showing how ungrounded content (yellow) is represented differently than grounded content (purple).

Furthermore, the study found that extrinsic hallucinations (adding information not in the source) are more salient in the model's internal representations than intrinsic hallucinations (misrepresenting provided facts). This indicates a distinct shift in the model's internal "mode" when it moves from retrieval to creative generation. However, the lack of task transfer—where probes trained on summarization fail on dialogue—suggests that these signals are highly context-dependent rather than being tied to a universal "hallucination neuron."

Comparative Performance

The probing approach demonstrated remarkable efficacy, often surpassing both automated baselines and human performance. On the CNN/DailyMail task, the ensemble probe achieved an F1 score of 0.75, significantly outperforming expert human annotators (0.55) and advanced baselines like ChatGPT with Chain-of-Thought prompting.

Comparison of response-level hallucination detection performance (F1-R) against various baselines and human experts across three datasets.

Conclusion

Probing internal representations offers a high-precision, efficient alternative to external hallucination detection. While the requirement for hidden state access limits its use to open-weight models, the ability to detect unfaithfulness as it occurs opens new avenues for real-time mitigation. Future work will focus on improving task-agnostic features to reduce the need for domain-specific training.

Summary updated

BibTeX
@inproceedings{chwang2024do,
  author = {Sky CH-Wang and Benjamin Van Durme and Jason Eisner and Chris Kedzie},
  title = {{Do Androids Know They're Only Dreaming of Electric Sheep?}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  url = {https://openreview.net/forum?id=bGwwJ2LuMN},
}
Figure