Abstract
Large Language Models (LLMs) are increasingly deployed in high-stakes environments, yet their propensity for hallucination necessitates robust confidence measures. Standard approaches, such as average sequence likelihood, often fail because they treat all tokens with equal weight, conflating syntactic fluency with semantic accuracy. This paper discusses Contextualized Sequence Likelihood (CSL), a novel method that leverages internal attention mechanisms to prioritize semantically significant tokens. By re-weighting token probabilities based on their importance to the model's internal decision-making process, CSL provides more reliable confidence estimates with minimal computational overhead.
Introduction
When an LLM generates a response, determining whether the output is factually grounded or a plausible-sounding hallucination is a critical challenge. The conventional metric for confidence is the average log-probability of the generated sequence. However, this metric is often dominated by high-probability syntactic tokens (e.g., "the", "and", "is") rather than the "load-bearing" tokens that carry factual weight (e.g., names, dates, or specific entities). Consequently, a model might appear confident in a grammatically perfect but factually incorrect statement, or unconfident in a correct but uniquely phrased answer.
To address this, researchers from the University of Illinois at Urbana-Champaign developed Contextualized Sequence Likelihood (CSL). CSL identifies and up-weights the tokens most critical to the meaning of a sentence, allowing for a confidence score that reflects semantic certainty rather than mere linguistic probability.
Methodology
The CSL Framework
The core innovation of CSL lies in using the model's own internal attention weights as a proxy for token importance. The process involves four primary steps:
- Attention Elicitation: The model is presented with an "attention-eliciting prompt," typically asking it to verify the correctness of its own previous output. This forces the model to "look back" at the generated tokens to make a judgment.
- Extracting Importance: During this self-evaluation, the researchers extract the attention weights from the model's internal layers. Specifically, they measure how much the "decision token" (the token where the model predicts 'True' or 'False') attends to each token in the original sequence.
- Expert Head Selection: Not all attention heads are equally informative. Some focus on punctuation or local syntax. Using a small validation set, the method identifies the "top $k$" (typically 10) attention heads that demonstrate the highest correlation with factual accuracy.
- Logit Reweighting: The final CSL score is calculated as a weighted sum of the original token log-probabilities, where the weights are derived from the selected expert attention heads.
CSL-Next
For scenarios where a secondary prompt is undesirable, the authors introduced CSL-Next. This variant extracts attention weights from the very next token the model would have generated following the answer, providing a zero-shot importance signal without requiring an explicit self-evaluation step.
Experimental Evaluation
The researchers evaluated CSL across three diverse Question Answering (QA) benchmarks:
- CoQA: Conversational question answering.
- TriviaQA: Large-scale reading comprehension.
- Natural Questions (nq): Real-world Google search queries.
The method was tested on several state-of-the-art open-source LLMs, including LLaMA2-13B, Mistral-7B, and Gemma-7B.
Key Findings
Superior Predictive Accuracy
CSL consistently outperformed vanilla sequence likelihood and existing baselines like TokenSAR. Performance was measured using the Area Under the Receiver Operating Characteristic curve (AUROC). On the Natural Questions dataset using LLaMA2, CSL achieved an AUROC of approximately 73.7, a significant improvement over the 66.6 achieved by standard likelihood.
Stability and Robustness
A key insight from the study is the stability of "expert" attention heads. Heads identified as effective on one dataset (e.g., CoQA) remained highly effective when applied to different datasets (e.g., TriviaQA). This suggests that certain attention heads inherently specialize in semantic verification across various contexts.
Computational Efficiency
Unlike uncertainty quantification methods that require multiple sampling passes (such as Semantic Entropy or Degree-based methods), CSL requires only a single additional forward pass (or zero in the case of CSL-Next). This makes it highly suitable for real-time applications where latency is a concern.
Discussion and Limitations
While CSL represents a significant advancement in LLM reliability, several challenges remain. The interpretability of attention weights is not absolute; a head may weight a token for reasons that are not immediately obvious to human observers. Furthermore, the effectiveness of the attention-eliciting prompt may vary across different tasks, such as creative writing or summarization, compared to the QA tasks studied here.
Finally, CSL is an internal confidence measure and cannot account for "unknown unknowns." If a model's training data is fundamentally flawed, it may remain confidently incorrect. Future research may explore integrating CSL with external knowledge retrieval to further bridge the gap between internal confidence and external truth.
Conclusion
Contextualized Sequence Likelihood offers a computationally efficient and robust method for improving LLM confidence scores. By shifting the focus from syntactic fluency to semantic importance through the use of internal attention signals, CSL provides a more nuanced and reliable metric for determining when an LLM's output can be trusted.
Summary updated