Introduction
Large Language Models (LLMs) often generate "hallucinations"—confidently stated but incorrect information. In critical domains like medicine or law, these errors are significant risks. Uncertainty estimation aims to quantify the reliability of a model's response, allowing systems to flag potentially incorrect outputs.
Traditional methods for uncertainty estimation typically rely on token probabilities (unsupervised/grey-box) or sampling multiple responses to check for consistency (semantic entropy). However, these approaches often overlook the rich internal representations of the model and are limited by the fact that LLMs are optimized for next-token prediction rather than factual accuracy.
A Supervised Framework for Uncertainty
This research introduces a supervised pipeline that trains an external Uncertainty Estimator (specifically, a Random Forest regressor) to predict the quality of a response based on internal model features.
The framework operates across three visibility regimes:
- White-box (Wb-S): Full access to the target LLM allows for extracting features from hidden layers and output logits.
- Grey-box (Gb-S): Access is limited to token probabilities and entropy.
- Black-box (Bb-S): For closed-source models like GPT-4, a separate open-source "Tool LLM" (e.g., Llama-3) is used to process the prompt and the black-box response. The Tool LLM’s internal activations serve as the feature set for the uncertainty estimator.
Theoretical analysis suggests that while final output probabilities may be misaligned with truthfulness due to the cross-entropy training objective, internal hidden layers retain critical information necessary for identifying errors.
Experimental Methodology
The approach was evaluated across three task categories:
- Question Answering: CoQA (reading comprehension) and TriviaQA (fact-based).
- Multiple Choice: MMLU, covering 57 subjects across STEM and humanities.
- Machine Translation: WMT-14 (French to English).
The researchers utilized various open-source models, including LLaMA-2 (7B/13B), LLaMA-3 (8B), and Gemma (2B/7B), as both target and tool models.
Key Findings
- The "Middle Layer" Advantage: Activations from middle layers were found to be better predictors of uncertainty than the final layer. The final layer is highly specialized for token prediction, whereas middle layers maintain a more holistic internal state regarding the truthfulness of the content.
- Uncertainty Neurons: Specific neurons were identified that correlate strongly with model correctness, firing more frequently when the model is "guessing."
- Cross-Model Transferability: A Tool LLM can effectively predict errors in a different black-box LLM, suggesting that patterns of uncertainty are somewhat universal across architectures.
- Performance Gains: The supervised approach significantly outperformed unsupervised benchmarks. On TriviaQA with LLaMA-2-7B, the supervised method achieved an AUROC of 0.925, compared to 0.773 for the best probability-based baseline.
Conclusion and Future Directions
The supervised framework demonstrates that a small amount of labeled data can drastically improve an LLM's ability to "know what it doesn't know." While the current method requires labeled datasets for training, it offers a robust path toward better-calibrated AI systems. Future work may explore real-time "Inference Time Intervention" to steer models away from uncertain paths and the integration of human-in-the-loop feedback for more complex, subjective tasks.
Summary updated