TL;DR
This paper reveals that Mamba models, a recent advancement in sequence modeling, can be understood as a form of implicit attention. By reformulating Mamba's internal mechanisms, the authors develop novel explainability tools that allow us to "see" Mamba's attention patterns, enabling direct comparisons with Transformers and offering new insights into their effectiveness.
What Problem Does This Paper Address?
Mamba models have shown impressive performance across various domains, particularly in handling long sequences with linear complexity. However, their internal workings and how they capture dependencies have remained largely unexplored. Unlike Transformers, which explicitly use self-attention matrices for interpretability, Mamba's "selective state-space layers" (SSMs) lack a clear window into their decision-making process. This opacity makes debugging difficult and hinders their application in sensitive domains requiring explainability. The authors aim to bridge this gap by showing that Mamba models do have an attention-like mechanism, and by developing tools to visualize and analyze it.
Methods
The core contribution of this paper is a novel perspective on Mamba models: viewing them as attention-driven. They achieve this by:
- Reformulating Mamba's computation: The authors mathematically re-express the selective SSM layer's operations, particularly its data-controlled linear operator, in a way that reveals an "implicit attention matrix."
- Developing "Hidden Attention Matrices": This reformulation allows them to extract these matrices, analogous to the attention matrices in Transformers.
- Creating Explainability Tools: Leveraging these hidden attention matrices, they adapt existing Transformer explainability techniques (like Attention Rollout and Transformer-Attribution) to Mamba models. This includes developing "Mamba-Attribution" and "Mamba-Rollout."
- Theoretical Analysis: They also provide theoretical arguments and proofs to demonstrate the expressiveness of Mamba's attention mechanism compared to Transformer heads and layers.
Datasets
The paper uses the following datasets:
- ImageNet: For vision tasks, specifically for comparing attention maps and evaluating explainability methods.
- IMDb movie review sentiment classification dataset: For NLP tasks, used to evaluate the proposed Mamba-Attr method.
Key Insights and Ideas
- Mamba is (implicitly) attention-based: The most significant insight is that Mamba's efficiency doesn't come at the cost of attention-like information processing. Its selective SSMs can be viewed as a form of data-controlled, implicit attention.
- Mamba generates more attention matrices: Due to its architecture (many channels vs. few heads in Transformers), Mamba models can produce a significantly larger number of attention matrices, potentially offering a richer, albeit more complex, view of their internal reasoning.
- Mamba's attention is less prone to oversmoothing: The paper suggests that Mamba's attention patterns exhibit less inter-token similarity across layers compared to Transformers, which could be a factor in its ability to handle long-range dependencies and avoid the oversmoothing problem.
- Mamba's expressiveness: Theoretically, a single Mamba channel can express as much as a Transformer head, but a single Transformer layer cannot express as much as a single Mamba channel, suggesting a potentially higher expressive power in Mamba's core building block.
Key Results
- Qualitative Visualization: Figures 4 and 5 show that Mamba's hidden attention maps, when visualized, exhibit patterns similar to Transformer attention maps, capturing dependencies across tokens and layers.
- Explainability Performance:
- In positive perturbation tests (where lower AUC is better), Mamba's Raw-Attention and Attn-Rollout showed better performance than ViT.
- In negative perturbation tests (where higher AUC is better), Transformer-based methods generally outperformed Mamba.
- In segmentation tests, Mamba models (especially with Raw-Attention and Attn-Rollout) demonstrated significantly higher pixel accuracy and mIoU compared to Vision Transformers. Transformer-Attribution still outperformed Mamba-Attribution.
- NLP Task Performance: On the IMDb dataset, Mamba-Attr showed comparable or occasionally superior performance to Transformer-Attr in both pruning and activation tasks. Qualitative results suggest Mamba-Attr often produces sparser, more focused explanations.
Limitations and Future Work
- Mamba-Attribution vs. Transformer-Attribution: While Mamba-Attr shows promise, the paper notes that it may benefit from further adjustments to match the performance of its Transformer counterpart, particularly in segmentation tasks.
- Sensitivity to Patch Removal: The authors suggest that Mamba models might be more sensitive to the removal of patches in perturbation tests, and future work could explore blurred patches.
- Future Directions: The authors plan to investigate the relationships between Mamba, Self-Attention, and other recent architectures (RWKV, Retention, Hyena) and develop XAI methods for LLMs based on these layers. They also aim to explore the theoretical implications of Mamba's expressiveness for in-context learning.
Summary updated