Abstract
As state-space models (SSMs) like Mamba emerge as efficient alternatives to Transformers, understanding their internal mechanics becomes crucial for AI safety and interpretability. This paper explores whether factual recall in Mamba follows the same localized patterns observed in Transformers. By adapting causal tracing and model editing techniques, we find that Mamba stores and processes facts in a remarkably similar "recall-then-move" fashion. Specifically, factual information is localized to an "early site" at the last subject token and a "late site" at the final prompt token. Our findings suggest that the constraints of autoregressive processing may impose a universal structure on factual knowledge organization across different neural architectures.
Introduction
The dominance of the Transformer architecture has allowed researchers to develop a sophisticated understanding of how language models store and retrieve information. We know, for instance, that Transformers often store factual associations in MLP layers and utilize attention heads to propagate this information. However, the rise of Mamba—a selective state-space model that eschews attention for convolutions and recurrent-like updates—raises a fundamental question: are these mechanistic insights architecture-specific, or do they reflect broader principles of autoregressive modeling?
This study addresses this by testing the "locality of factual recall" hypothesis in Mamba-2.8b. We investigate whether Mamba, despite its radical architectural differences, organizes factual knowledge in a way that mirrors its Transformer-based counterparts.
Methodology
To probe Mamba's internal states, we adapted several established interpretability tools:
- Causal Tracing (Activation Patching): This technique identifies which internal activations are most critical for a specific prediction. By running a "clean" prompt (e.g., "Michael Jordan plays...") and a "corrupted" one ("Pelé plays..."), we swap activations to see which restoration most effectively recovers the correct answer ("basketball").
- Model Editing (ROME): We applied Rank-One Model Editing to Mamba’s projection matrices ($W_a, W_g, W_o$) to determine if specific facts could be surgically updated with high specificity and generalization.
- Linear Relation Embedding (LRE): We evaluated whether the relationship between a subject and an object could be represented as a linear transformation in the hidden state space.
Localization of Factual Recall
Our causal tracing experiments revealed a striking similarity to Transformers. As shown in Figure 2, the "Indirect Effect" (IE) of restoring residual states is concentrated in two primary areas:
- Early Site: Middle layers at the last token of the subject. This is where the model appears to perform a "lookup" of the entity's attributes.
- Late Site: Final layers at the last prompt token, where the information is integrated to produce the final prediction.
This "recall-then-move" pattern suggests that the information bottleneck created by processing text sequentially forces the model to localize attribute retrieval at the end of the subject string, regardless of the underlying mathematical operations (attention vs. SSM).
Component-Level Analysis and Editing
Beyond the residual stream, we analyzed specific internal components of the Mamba block: the output projection ($o_i$), the gate ($g_i$), and the SSM state ($s_i$).
As illustrated in Figure 6, the output projection $o_i$ shows the strongest causal importance at both the early and late sites. This identifies the $W_o$ matrix as a functional equivalent to the MLP layers in Transformers, making it the ideal target for model editing. Indeed, applying ROME to $W_o$ in layers 15–40 yielded high efficacy in "reprogramming" factual associations while maintaining generalization to related prompts.
Discussion and Conclusion
Our results indicate that Mamba's internal mechanics are surprisingly similar to those of Transformers. The discovery of the "early site" phenomenon in an SSM suggests that the organization of factual knowledge is driven more by the task of autoregressive next-token prediction than by specific architectural choices.
However, Mamba presents unique challenges. Its convolutional layers cause information to "leak" across neighboring tokens, making surgical interventions slightly less precise than in Transformers. Future work should focus on developing SSM-specific path-patching techniques to further unravel how these models manage long-range dependencies without explicit attention mechanisms.
Summary updated