Abstract: Transformer models have revolutionized fields from natural language processing to computer vision, yet their internal computational dynamics remain poorly understood raising concerns about predictability and robustness. In this work, we introduce Entropy-Lens, a scalable, model-agnostic framework that leverages information theory to interpret frozen, off-the-shelf large-scale transformers. By quantifying the evolution of Shannon entropy within intermediate residual streams, our approach extracts computational signatures that distinguish model families, categorize task-specific prompts, and correlate with output accuracy. We further demonstrate the generality of our method by extending the analysis to vision transformers. Our results suggest that entropy-based metrics can serve as a principled tool for unveiling the inner workings of modern transformer architectures.
Introduction
Large Language Models (LLMs) are often characterized as "black boxes." While their final outputs are observable, the internal mechanisms by which they arrive at specific token choices across dozens of layers remain opaque. Most interpretability research focuses on high-dimensional latent representations that are difficult to map back to token space. To address this, we introduce Entropy-Lens, a diagnostic tool that tracks the Shannon entropy of internal predictions at every layer, distilling high-dimensional data into a readable, one-dimensional signal.
The Entropy-Lens Framework
The Entropy-Lens builds upon the logit-lens technique. By projecting the residual stream of each layer through the model's final output head, we obtain a probability distribution over the vocabulary. We then compute the Shannon entropy of these distributions. High entropy indicates uncertainty as the model considers many candidates, while low entropy suggests confidence in a narrow set of tokens.
Through this profiling, we identify two primary computational strategies:
- Expansion: An increase in entropy where the model opens up its candidate pool.
- Pruning: A decrease in entropy where the model refines and narrows its choices.
Computational Signatures and Depth Invariance
A key finding is that model families (e.g., Llama, Gemma, GPT-2) exhibit unique and recognizable entropy "fingerprints." For instance, GPT models typically start with high uncertainty and sharpen choices gradually, whereas Llama models often exhibit a low-entropy start followed by a high-uncertainty "plateau" before final refinement.
Furthermore, these profiles exhibit depth invariance. When normalized by depth, the entropy signature of a 1B parameter model is nearly identical to its 8B counterpart. This suggests that scaling increases the "resolution" of a computational strategy rather than fundamentally altering it.
Model and Task Identification
The distinctiveness of these signatures allows for highly accurate classification. Using only entropy profiles, we can identify model families with 97.99% accuracy and model size categories with 96.31% accuracy.
Beyond model identification, the framework is sensitive to task and format. A k-nearest neighbor (kNN) classifier can distinguish between a model writing a poem versus a scientific paper with approximately 98% accuracy based solely on the internal entropy profile.
Performance Correlation and Interventions
Entropy profiles serve as a signal for output quality. We found that these profiles contain sufficient information to predict answer correctness on the MMLU benchmark with up to 73.6% AUC.
Intervention experiments reveal that the "expansion" phase is critical to performance. In Llama models, skipping the single layer associated with maximal expansion caused MMLU performance to collapse to random chance. This suggests that the ability to "open up" the candidate pool is more vital to final accuracy than the subsequent pruning phases.
Conclusion
Entropy-Lens provides a principled, scalable, and model-agnostic tool for peering into the internal dynamics of transformers. By mapping the evolution of uncertainty, we can identify architectural fingerprints, detect task-specific strategies, and predict model performance, moving us closer to a mechanistic understanding of these complex systems.
Summary updated