Introduction
Vision Transformers (ViTs) have revolutionized computer vision, yet their internal decision-making processes remain largely opaque. While we understand the architectural components—self-attention and multi-layer perceptrons (MLPs)—the mechanistic journey from raw pixels to high-level categorical predictions is difficult to trace. This paper addresses this "black box" problem by adapting "logit lens" techniques from Natural Language Processing (NLP) to the vision domain. By projecting intermediate hidden states into the final class embedding space, we can "read" the model's internal reasoning at every layer without the need for additional training or optimization.
Methodology: Activation Space Projection
The core of this approach is Activation Space Projection. In a standard ViT, the final layer projects a high-dimensional representation into a probability distribution over classes using an embedding matrix $E$. The authors apply this same matrix to intermediate hidden states to interpret the model's "thoughts" mid-calculation.
- Projection Mechanism: Any image token at any layer is multiplied by the pre-trained output embedding matrix. This translates abstract vectors into a distribution over known classes (e.g., "Golden Retriever," "Space Shuttle").
- Class Identifiability: To quantify the clarity of these internal representations, the authors define a metric for how "identifiable" the ground-truth class is within these intermediate projections.
- MLPs as Key-Value Memories: Building on recent theoretical work, the authors treat MLP layers as key-value memory systems. By projecting the output weights ($W_{out}$) of these layers into the class space, they can identify the specific concepts these "memories" inject into the representation.
- Gradient-based Explainability: By analyzing the gradients of the projection loss, the framework identifies which spatial patches contribute most to a specific class prediction at different depths.
Experimental Framework
The study evaluates several architectures, including ViT-B/16, B/32, and L/16, across multiple datasets:
- ImageNet-1k: The primary benchmark for classification.
- ImageNet-S: A subset with semantic labels used to analyze the difference between foreground (object) and background (context) tokens.
- CIFAR100: Used to validate the method on fine-tuned models with different label sets.
Key Insights
The Intelligence of Image Tokens
A significant finding is that categorical information is not confined to the special [CLS] token. Individual image patches (tokens) begin to align with the correct class representation surprisingly early in the network. In a ViT-B/32, image tokens reach a class identifiability rate of over 60% by the final block, demonstrating that the model builds a distributed consensus across the image rather than relying solely on a single global token.
Contextual Dependency
The research highlights that background tokens are not merely noise. These "context" tokens also develop class-specific information. Experiments involving the removal of background tokens resulted in a decrease in the model's ability to identify the primary foreground object, suggesting that ViTs leverage environmental cues to reinforce categorical concepts.
MLPs as Semantic Memory Banks
The role of MLP layers is distinct from self-attention. While self-attention layers provide weaker, more disseminated updates early in the hierarchy, MLPs act as decisive "memory" units in later stages. These layers inject sharp categorical boosts. Furthermore, these updates are compositional; a single MLP might simultaneously promote several semantically related classes (e.g., "racket," "tennis ball," and "volleyball"), representing a broader conceptual cluster of "court sports."
Results and Explainability
The projection method serves as a powerful diagnostic tool. Unlike "linear probing," which requires training auxiliary classifiers for each layer, this method is zero-shot and reflects the model's actual internal state.
In a ViT-B/32, the model achieves high identifiability significantly above chance well before the final layer. The authors demonstrate the utility of this through gradient-based heatmaps. For instance, in cases of misclassification—such as an "Impala" being mistaken for an "Ibex"—the heatmaps reveal that the model was over-indexing on specific features like horn structure, which are shared between the two species. This level of granularity allows researchers to pinpoint exactly where and why a model's logic diverges from the ground truth.
Conclusion and Future Directions
This work provides a simple yet effective framework for interpreting the internal dynamics of Vision Transformers. By leveraging the existing class embedding space, it offers a window into how models transform pixels into concepts. While the study focuses on supervised classification, future research may extend these techniques to self-supervised models (like DINO) or explore "model surgery," where these insights are used to actively correct biases or errors by intervening in the MLP "memory" layers.
Summary updated