Attention Head Entropy of LLMs Predicts Answer Correctness

Sophie Ostmeier, Brian Axelrod, Maya Varma, Asad Aali, Yabin Zhang, Magdalini Paschali, Sanmi Koyejo, Curtis Langlotz, Akshay Chaudhari · DOI

Abstract

Large language models (LLMs) often generate plausible yet incorrect answers, posing risks in safety-critical settings such as medicine. Human evaluation is expensive, and LLM-as-judge approaches risk introducing hidden errors. Recent white-box methods detect contextual hallucinations using model internals, focusing on the localization of the attention mass, but two questions remain open: do these approaches extend to predicting answer correctness, and do they generalize out-of-domains? We introduce Head Entropy, a method that predicts answer correctness from attention entropy patterns, specifically measuring the spread of the attention mass. Using sparse logistic regression on per-head 2-Renyi entropies, Head Entropy matches or exceeds baselines in-distribution and generalizes substantially better on out-of-domains, it outperforms the closest baseline on average by +8.5% AUROC. We further show that attention patterns over the question/context alone, before answer generation, already carry predictive signal using Head Entropy with on average +17.7% AUROC over the closest baseline. We evaluate across 5 instruction-tuned LLMs and 3 QA datasets spanning general knowledge, multi-hop reasoning, and medicine.

Introduction: The Challenge of "Confident Liars"

Large Language Models (LLMs) are notoriously "confident liars." They produce fluent, authoritative responses that are often factually incorrect—a major hurdle for deployment in safety-critical fields like medicine or law. Existing ways to catch these errors usually fall into two camps: "black-box" methods (sampling multiple answers and checking for consistency) or "gray-box" methods (looking at token probabilities). Both have significant flaws: black-box methods are computationally expensive, and token probabilities are often poorly calibrated.

Recent "white-box" methods look at internal attention maps, but they typically focus on localization (e.g., "Is the model looking at the context or itself?"). These methods often fail to generalize when the model encounters a new topic (out-of-distribution data).

Methodology: Measuring Attention Stability

The proposed method, Head Entropy, shifts the focus from attention location to attention spread. It operates on the principle that correctness isn't just about what the model attends to, but how decisive that attention is. If the attention is scattered (high entropy), the model is likely guessing or hallucinating based on weak associations.

2-Rényi Entropy and Sparse Regression

Instead of standard Shannon entropy, the researchers use 2-Rényi entropy to measure the concentration of attention weights in each head. This choice is mathematically linked to "Jacobian norms": high entropy at inference time suggests the model is in a state that was unstable or unrefined during training. Low-entropy patterns represent "well-learned" associations.

Figure 1: Overview of the Head Entropy architecture. Entropy is calculated from the self-attention matrix across semantic sections and fed into a logistic regression model to predict correctness.

The process involves:

  1. Extraction: Entropy values are extracted for every attention head across all layers during a single forward pass.
  2. Semantic Aggregation: To maintain efficiency, entropies are averaged across semantic sections (e.g., the question, the "thinking" phase, or the answer) rather than analyzing every single token.
  3. Classification: A simple, interpretable $\ell_1$-regularized (sparse) logistic regression model maps these entropy patterns to a probability of correctness.

Experimental Evaluation

The method was evaluated across five instruction-tuned models (from the Qwen3 and Llama 3 families) using three diverse benchmarks:

  • TriviaQA: General knowledge (open-domain).
  • HotpotQA: Multi-hop reasoning with long contexts.
  • MedMCQA: A high-stakes medical multiple-choice dataset.

Key Results and Insights

Head Entropy demonstrates superior performance across all tested scenarios, particularly in its ability to generalize to unseen domains.

Superior Generalization and Accuracy

In out-of-distribution (OOD) tests, Head Entropy outperformed the "Lookback Lens" baseline by an average of +8.5% AUROC. As shown in the performance plots, the logistic regression approach using head entropy (green triangles) consistently achieves the highest AUROC scores across different models and datasets.

Figure 3: AUROC performance across three datasets. Head Entropy (green triangles) consistently outperforms baselines like Lookback Lens and Hidden State LR across various model sizes.

The "Pre-cognition" Effect

One of the most remarkable findings is that attention patterns formed while the model is just reading the question—before it generates a single answer token—are highly predictive of eventual correctness. Using only question-tokens, Head Entropy improved AUROC by +17.7% over the strongest baseline. This suggests the model "knows" it lacks sufficient information or internal stability for a correct answer before it even starts "speaking."

Efficiency and Calibration

Beyond accuracy, Head Entropy is practical. It adds less than 1% to total inference time. Furthermore, it is well-calibrated; its Expected Calibration Error (ECE) was frequently below 0.10, meaning the predicted probabilities of correctness closely match actual outcomes.

Discussion and Future Work

While Head Entropy provides a powerful "early warning system" for LLM errors, it does require a small labeled dataset (around 10k examples) to train the logistic regressor for a specific model. Future research could explore extending this binary "correct vs. incorrect" classification to more subjective tasks like creative writing or summarization. Additionally, while SHAP values can identify which heads are most predictive, the specific linguistic features these heads track remain a subject for deeper probing.

Summary updated

BibTeX
@misc{ostmeier2026attention,
  author = {Sophie Ostmeier and Brian Axelrod and Maya Varma and Asad Aali and Yabin Zhang and Magdalini Paschali and Sanmi Koyejo and Curtis Langlotz and Akshay Chaudhari},
  title = {{Attention Head Entropy of LLMs Predicts Answer Correctness}},
  year = {2026},
  eprint = {2602.13699},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.13699},
}
Figure