TL;DR
Standard uncertainty metrics for LLMs—like token probabilities or self-consistency—frequently break down when a model encounters a new, unseen data domain. This paper introduces Layerwise CP, a framework that leverages an LLM's internal hidden states across its entire depth to compute more robust nonconformity scores for Conformal Prediction. By looking inside the model rather than just at its surface-level text outputs, the method delivers significantly tighter and more reliable prediction sets under distribution shift.
What Problem Does This Paper Address?
When deploying Large Language Models (LLMs) in high-stakes domains like medicine or law, knowing when to trust a model's answer is critical. Conformal Prediction (CP) is a popular framework used to give mathematical guarantees on uncertainty; instead of outputting a single answer, it outputs a set of possible answers guaranteed to contain the correct one with a user-defined probability.
However, CP relies heavily on a "nonconformity score" to rank candidate answers. Existing methods typically derive this score from surface-level statistics (e.g., final token probabilities or how often an answer appears across multiple generation samples). The catch? These surface statistics are highly brittle under domain shift (when deployment data differs from calibration data). Furthermore, because multiple wordings can mean the same thing, surface-level token probabilities often misrepresent the true underlying semantic uncertainty.
Methods
The authors propose moving away from output-facing statistics, opting instead to look at the model's internal computational trajectory. They introduce Layer-Wise Information (LI) scores to serve as the nonconformity metric within a standard split conformal prediction pipeline.
Here is how it works:
- Sample Candidates: For a given question, sample $M$ candidate responses from the LLM.
- Compute Per-Layer Entropy: For each response, project the hidden states of every transformer layer through the pretrained LM head. They calculate the predictive entropy under two conditions: with the question context, and with a null (empty) context.
- Extract Usable Information: The difference between the null-context entropy and the context-conditioned entropy defines the "usable information" at that specific layer. This captures how much the question actually helped the model resolve uncertainty at that stage of depth.
- Aggregate and Normalize: They sum these layer-wise gains and losses across the model's depth, normalize the scores within the candidate pool, and combine them 50/50 with standard answer frequency (cross-sample consensus).
This final combined score is used to construct the conformal prediction set. The underlying conformal wrapper remains standard, meaning its mathematical validity guarantees are preserved.
Datasets
The method was evaluated across multiple open-source white-box LLM families (including Qwen-2.5, LLaMA-3.1, and Vicuna) using the following benchmarks:
- MMLU-Pro & MedMCQA: For closed-ended, multiple-choice question answering. Crucially, MMLU-Pro was used for a subject-wise cross-domain protocol (e.g., calibrating the conformal threshold on law questions but testing on math questions).
- TriviaQA & CoQA: For open-domain, free-form question answering.
Key Insights and Ideas
- The Internal Trajectory is Non-Monotonic: LLMs do not form answers linearly. Reliability-relevant evidence can be generated, lost, or recovered across intermediate layers before reaching the final layer. Relying solely on final-layer statistics discards this rich internal history.
- Internal Representations Resist Domain Shift: While surface-level token probabilities shift wildly when a model moves from a familiar domain to an unfamiliar one, the internal dynamics of how context resolves uncertainty remain remarkably stable.
- Information-Theoretic Alignment: Tighter conformal sets mean less residual ambiguity. By achieving smaller prediction sets at the same risk levels, the paper demonstrates that internal states provide a cleaner, more discriminative ranking signal than text-level outputs.
Key Results
The most striking advantages of Layerwise CP emerged during cross-domain evaluation, where calibration and deployment distributions were intentionally mismatched:
- Cross-Domain Efficiency: On cross-domain MMLU-Pro tasks, Layerwise CP reduced the Average Prediction Set Size (APSS) from 2.172 to 1.804 compared to SConU-Pro (a strong text-level baseline), while simultaneously lowering the Empirical Miscoverage Rate (EMR) from 0.144 to 0.119.
- Better Pareto Frontiers: Across various user-specified risk budgets ($\beta$), Layerwise CP consistently pushed the operating points down and to the left on the EMR-APSS plane, indicating smaller prediction sets alongside better accuracy guarantees.
- Open-Domain Consistency: On TriviaQA, the method achieved joint improvements in both validity and efficiency across different model backbones.
Limitations and Future Work
- White-Box Access Required: Because the LI score relies on extracting hidden states and intermediate logits across all transformer layers, this method cannot be applied to black-box commercial APIs (like GPT-4 or Claude). It requires full access to the model weights.
- Computational Overhead: Extracting hidden states and running parallel forward passes with a null context introduces additional inference-time compute costs.
- Theoretical Guarantees Under Shift: While the empirical results under domain shift are strong, standard conformal prediction theorems assume exchangeability. The authors note that proving a formal mathematical link between layer-wise information stability and guaranteed coverage under shift remains an open avenue for future theoretical work.
Summary updated