Table of Contents
Fetching ...

Lookback Lens: Detecting and Mitigating Contextual Hallucinations in Large Language Models Using Only Attention Maps

Yung-Sung Chuang, Linlu Qiu, Cheng-Yu Hsieh, Ranjay Krishna, Yoon Kim, James Glass

TL;DR

This work tackles contextual hallucinations in large language models by introducing Lookback Lens, a lightweight detector built from attention map signals—specifically per-head lookback ratios that measure attention to context versus generated text. It shows that a simple logistic classifier using these features rivals or surpasses heavier approaches based on hidden states or external entailment models, and it can transfer across models and tasks without retraining. Beyond detection, the authors integrate Lookback Lens into decoding (Lookback Lens Guided Decoding) to reduce hallucinations, achieving notable gains on XSum and demonstrating cross-task and cross-model transfer abilities. The approach emphasizes interpretability and efficiency, offering a practical pathway to improve factuality in generation without extensive retraining or reliance on parametric knowledge.

Abstract

When asked to summarize articles or answer questions given a passage, large language models (LLMs) can hallucinate details and respond with unsubstantiated answers that are inaccurate with respect to the input context. This paper describes a simple approach for detecting such contextual hallucinations. We hypothesize that contextual hallucinations are related to the extent to which an LLM attends to information in the provided context versus its own generations. Based on this intuition, we propose a simple hallucination detection model whose input features are given by the ratio of attention weights on the context versus newly generated tokens (for each attention head). We find that a linear classifier based on these lookback ratio features is as effective as a richer detector that utilizes the entire hidden states of an LLM or a text-based entailment model. The lookback ratio-based detector -- Lookback Lens -- is found to transfer across tasks and even models, allowing a detector that is trained on a 7B model to be applied (without retraining) to a larger 13B model. We further apply this detector to mitigate contextual hallucinations, and find that a simple classifier-guided decoding approach is able to reduce the amount of hallucination, for example by 9.6% in the XSum summarization task.

Lookback Lens: Detecting and Mitigating Contextual Hallucinations in Large Language Models Using Only Attention Maps

TL;DR

This work tackles contextual hallucinations in large language models by introducing Lookback Lens, a lightweight detector built from attention map signals—specifically per-head lookback ratios that measure attention to context versus generated text. It shows that a simple logistic classifier using these features rivals or surpasses heavier approaches based on hidden states or external entailment models, and it can transfer across models and tasks without retraining. Beyond detection, the authors integrate Lookback Lens into decoding (Lookback Lens Guided Decoding) to reduce hallucinations, achieving notable gains on XSum and demonstrating cross-task and cross-model transfer abilities. The approach emphasizes interpretability and efficiency, offering a practical pathway to improve factuality in generation without extensive retraining or reliance on parametric knowledge.

Abstract

When asked to summarize articles or answer questions given a passage, large language models (LLMs) can hallucinate details and respond with unsubstantiated answers that are inaccurate with respect to the input context. This paper describes a simple approach for detecting such contextual hallucinations. We hypothesize that contextual hallucinations are related to the extent to which an LLM attends to information in the provided context versus its own generations. Based on this intuition, we propose a simple hallucination detection model whose input features are given by the ratio of attention weights on the context versus newly generated tokens (for each attention head). We find that a linear classifier based on these lookback ratio features is as effective as a richer detector that utilizes the entire hidden states of an LLM or a text-based entailment model. The lookback ratio-based detector -- Lookback Lens -- is found to transfer across tasks and even models, allowing a detector that is trained on a 7B model to be applied (without retraining) to a larger 13B model. We further apply this detector to mitigate contextual hallucinations, and find that a simple classifier-guided decoding approach is able to reduce the amount of hallucination, for example by 9.6% in the XSum summarization task.
Paper Structure (49 sections, 6 equations, 5 figures, 14 tables)

This paper contains 49 sections, 6 equations, 5 figures, 14 tables.

Figures (5)

  • Figure 1: An illustration of the Lookback Lens. We extract attention weights and calculate the lookback ratios for all layers and all heads. We train a linear classifier on the concatenated features to predict truthfulness of the generation.
  • Figure 2: Lookback Lens Guided Decoding: sample multiple chunk candidates, compute lookback ratios from attention maps to be scored by Lookback Lens, and select the best candidate that is less likely to be hallucinations.
  • Figure 3: Qualitative example on XSum using the LLaMA-2-7B-Chat model with greedy decoding and Lookback Lens Guided Decoding. The numbers in the parenthesis show the predicted scores from the Lookback Lens.
  • Figure 4: Screenshot of human annotation interface.
  • Figure 5: Top-10 positive/negative heads ranked from top to the bottom by the magnitude of their coefficients in the Lookback Lens classifier.