Abstract
Large Language Models (LLMs) often hallucinate with high confidence because they fail to account for how early errors propagate through a sequence. This paper introduces TAD (Trainable Attention-based Dependency), a supervised uncertainty quantification (UQ) method that leverages internal attention maps and recurrent features to "track" uncertainty across generation steps. TAD significantly outperforms existing methods with only 5% computational overhead, providing a robust solution for detecting cascading hallucinations.
The Problem: The "House of Cards" Effect
When an LLM generates text, it does so token-by-token, conditioning each new word on its previous output. This creates a "house of cards" effect: if the model makes a factual error early on, all subsequent tokens are conditioned on that falsehood.
Current UQ methods struggle to identify these failures. Simple measures like token probabilities often show high confidence even after an error has occurred because the model is "sure" about what follows its own mistake. More complex sampling-based methods—which query the model multiple times—are computationally expensive, increasing latency by 400-600%. The authors identify a critical gap: the need for an efficient way to model the conditional dependency between generation steps to detect when a model has gone off the rails.
Methodology: Trainable Attention-based Dependency (TAD)
TAD treats uncertainty as a supervised learning problem. Instead of relying on human-engineered heuristics, it extracts features directly from the model's internal state to model how uncertainty flows through a sequence.
- Feature Extraction: For every token generated, TAD analyzes the LLM's internal attention maps (how the current token relates to previous ones), raw probabilities, and recurrent features (the uncertainty scores of preceding tokens).
- Two-Stage Training: To handle the recursive nature of generation, TAD uses a two-stage approach. A base regression model is first trained on probabilities; its predictions then serve as features for a final model that learns how uncertainty propagates.
- Inference: During use, TAD computes confidence scores recursively. These are averaged to provide a sequence-level uncertainty score.
Experimental Setup
The study evaluates TAD across ten datasets covering five distinct NLP tasks, including summarization (XSum, CNN/DailyMail), machine translation (WMT19), and various forms of QA (TruthfulQA, MMLU, GSM8k). The models tested include LLaMA-3.1 8B, Gemma-2 9B, and Qwen-2.5 7B.
Key Results
The primary metric used is the Prediction Rejection Ratio (PRR), which measures how effectively an uncertainty score can be used to "reject" low-quality or incorrect outputs.
As shown in the comprehensive results table, TAD achieved the best mean rank across all three LLMs and nearly all datasets. On the MedQUAD dataset (medical QA), TAD outperformed the next best method (LookBackLens) by a substantial 0.077 PRR points. Furthermore, TAD maintains this accuracy with only a 5% overhead, making it viable for real-time applications where sampling-based methods are too slow.
Key Insights: Attention as a "Smoke Detector"
The authors found that specific attention heads act as strong indicators of truthfulness. For example, in Llama-3.1 8B, a specific head consistently pays high attention to the preceding token during correct generations. When the model begins to hallucinate, this attention signal "blurs" or drops significantly, providing a clear warning sign. By incorporating these signals and the uncertainty of previous tokens, TAD can catch "cascading" hallucinations that independent token-level measures miss.
Limitations and Future Work
While TAD generalizes well within similar task types, it requires a labeled training set and model-specific tuning, as optimal attention heads vary between architectures. Future research will explore applying TAD to Retrieval-Augmented Generation (RAG), using it to evaluate the credibility of retrieved documents by analyzing how the LLM attends to provided context versus its own internal weights.
Summary updated