Explaining Modern Gated-Linear RNNs via a Unified Implicit Attention Formulation

## Abstract

Abstract Recent advances in efficient sequence modeling have led to attention-free layers, such as Mamba, RWKV, and various gated RNNs, all featuring sub-quadratic complexity in sequence length and excellent scaling properties, enabling the construction of a new type of foundation models.
In this paper, we present a unified view of these models, formulating such layers as implicit causal self-attention layers. The formulation includes most of their sub-components and is not limited to a specific part of the architecture. The framework compares the underlying mechanisms on similar grounds for different layers and provides a direct means for applying explainability methods. Our experiments show that our attention matrices and attribution method outperform an alternative and a more limited formulation that was recently proposed for Mamba. For the other architectures for which our method is the first to provide such a view, our method is effective and competitive in the relevant metrics compared to the results obtained by state-of-the-art Transformer explainability methods. Our code is publicly available. https://github.com/Itamarzimm/UnifiedImplicitAttnRepr

## 1 Introduction

The very recent State Space Model (SSM) named Mamba by Gu & Dao () has attracted considerable attention since its recent debut (Lieber et al., ; Liu et al., ; Zhu et al., ; Xu et al., ), further establishing it as an efficient and accurate general-purpose model. Like other SSM models (Gu et al., ; ), Mamba is autoregressive during inference and trains efficiently in parallel. Recently, Ali et al. () have highlighted a third aspect of the Mamba model; namely, that it is also an attention model, since it implicitly computes attention.

Attention models can be defined as models that linearly combine the values associated with different elements to create the next set of such associated values. When discussing sequences of tokens, an attention operator considers the values obtained for each token separately, as a hidden representation, and mixes these to obtain a new set of values for each token. The mixing coefficients are also a function of the hidden representations.

Let $X$ be the matrix whose columns are the hidden values associated with each token, and let $\alpha$ be the matrix of mixing coefficients. The set of values of the next layer is initially obtained as $Y=\alpha X$ and it can then undergo other forms of processing, such as nonlinear activations and per-token processing. Given a neural architecture, one can always linearize the mixing operators and write them in the form $Y=\alpha X$ via their first-order approximation. However, to be considered an attention model it is required that $\alpha$ be a function of $X$, which means that the linear operator is data-dependent. This property is shown by Ali et al. () to hold only for the recent selective SSM (S6) , but not for most earlier SSMs. Specifically, for standard state-space layers, it has been demonstrated that they can be linearized into a constant operator, represented by a constant matrix $\alpha$, which is solely controlled by the layer’s parameters. However, in the S6 layers, $\alpha$ is influenced by both the input and the layer’s parameters.

The implicit attention matrix of Ali et al. () considers the S6 mechanism and ignores the influence of other critical mixer components, such as Conv1D, gate branch, linear layers, and SiLU activations. The formulation we propose in this work incorporates these additional elements and, as we show empirically, leads to improved interpretability results in both computer vision and NLP.

Furthermore, using a similar holistic formulation, we show that S6 is not the only sequence model that implicitly computes attention and that an implicit attention representation can also describe other recent layers, such as RWKV (Peng et al., ), Griffin (De et al., ) ,HGRN (Qin et al., ) and more, as illustrated in Figure 1.

To achieve a more accurate representation that better reflects the model’s behavior, we employ a composition of multiple components. The concept of composing non-attention layers and representing them as data-controlled linear operators was initially introduced in Hyena (Poli et al., ), which attempts to replicate attention capabilities through a composition of two sub-quadratic operators (long convolutions and multiplicative gating). Our formulation differs from this approach in two main ways. First, instead of focusing on replicating attention capabilities, we take the reverse step by demonstrating that, through a sequence of algebraic manipulations, several existing modern gated linear RNNs can be viewed as single implicit attention layers. Second, our goal is to find the most accurate implicit attention representation possible, as it crucial for applications like interpretability. This leads to a significant extension over Hyena’s work. For example, while Hyena’s matrices are constructed from the two components mentioned above, our implicit attention representation incorporates additional layers, including non-linear operators such as linear layers, activations, short convolutions, and normalization layers. For instance, our formulation for Mamba-2 is built upon six different layers, some of which appear multiple times, resulting in a much more complex outcome. Additionally, while other works explore the relations between non-attention layers and linear attention (Arora et al., ), we not aware to any work extending the concept of composition of components similar to us, or apply it to existing modern RNN such as Griffin, Mamba, or link in to interpateblity or similar domains.

Our main contributions are as follows: (i) We introduce the implicit self-attention representation, unifying Transformers with non-Transformer layers, such as Griffin, RWKV, ReNet, and others. (ii) We refine the approach of Ali et al. () to produce more accurate attention matrices. The previous work focused exclusively on the S6 layer, without considering the gating and Conv1D sub-layers in Mamba, while our representation incorporates all these factors (and additional peripherals in other models) (iii) While “Attention is not Explanation” (Jain & Wallace, ), Transformer explainability relies heavily on attention matrices. We demonstrate that our implicit attention representation of non-Transformer models can be used to develop new explainability and interpretability techniques for non-Transformer models, enhancing the community’s ability to understand, explore, and manage aspects of robustness, bias, fairness, and safety. As a sample downstream application, we demonstrate excellent out-of-the-box results for attribution-based performance-enhancing techniques.
(iv) Finally, our framework facilitates comparisons between Transformers and other recent architectures, by providing a unified attention view and setting the stage for further improvements and insights.

## 2 Related Work

This section describes the scientific context and provides the necessary terminology and symbols for discussing self-attention and selective SSM layers.

Self-Attention.  Self-attention, a cornerstone of Transformer architectures (Vaswani, ), has profoundly influenced recent developments in NLP and computer vision. This mechanism leverages pairwise token interactions to dynamically allocate focus across different parts of the input sequence, assessing the relevance of each token in relation to others. The computational formula is given by:

$$ $Self-Attention(Q,K,V)=\alpha V,\quad\alpha=\text{softmax}\left(\frac{QK^{T}}{ \sqrt{d_{k}}}\right)$ (1) $$

Here, $Q$,$K$, and $V$ denote the queries, keys, and values respectively, with $d_{l}$ representing the key dimension. Transformers enhance this mechanism by incorporating $H$ parallel attention heads, thus capturing a wider range of dependencies.

Applications of Attention Matrices.  Attention matrices play a crucial role in Transformers, as multiplying these matrices with value vectors is the core operation that captures interactions between tokens. Beyond this essential role in computing self-attention, they are also used for various purposes: (i) Explainability and Interpretability: Although attention itself is not inherently explainable (Jain & Wallace, ), many methods in these domains rely on attention matrices to understand and analyze model behavior (Abnar & Zuidema, ; Chefer et al., ; ; Ali et al., ) . (ii) Multi-modal Learning: Numerous multi-modal learning schemes are based on variations of cross-attention, enabling dependencies to be learned between any pair of tokens of different modalities (Lu et al., ; Tan & Bansal, ). (iii) Weakly Supervised Tasks: Attention matrices can provide a valuable source of supervision, highlighting relevant regions or relationships within the data to guide model learning. These techniques are popular in semantic segmentation (Ru et al., ; Wang et al., ; Ru et al., ), and robustness enhancement (Chefer et al., ). Finally, (iv) Inductive Bias and Regularization Methods: Since attention matrices represent interactions between tokens, they inherently carry semantic meaning. Therefore, they can be manipulated to incorporate domain knowledge or regulate the model effectively (Li et al., ; Attanasio et al., ; Bonaldi et al., ; Zimerman & Wolf, ).

S6 Layers and Mamba. The recently presented selective SSM (Gu & Dao, ) (S6) outperforms the previous SSMs and various other architectures in NLP (Anthony et al., ; Wang et al., ), vision (Liu et al., ; Zhu et al., ), graph classification (Wang et al., ; Behrouz & Hashemi, ), and more. S6 incorporates a dynamic input-dependent form of the discrete matrices $\bar{A},\bar{B},$ and $C$, such that for every time-step the SSM employs a different recurrent rule. This technique differs from the previous state-space layers, which use the same set of matrices and recurrent rules for each time step.

Denoting the input sequence by $\hat{x}:=(\hat{x}_{1},\cdots,\hat{x}_{L})\in\mathbb{R}^{L\times D}$ where $\hat{x}_{i}\in\mathbb{R}^{D}$, the discrete matrices for time step $i$, namely $\bar{A_{i}},\bar{B_{i}},$ and $C_{i}$ are defined as:

$$ $B_{i}=S_{B}(\hat{x}_{i}),\quad C_{i}=S_{C}(\hat{x}_{i}),\quad\Delta_{i}=\text{ Softplus}(S_{\Delta}(\hat{x}_{i})),\quad\bar{A}_{i}=\exp(\Delta_{i}A),\quad \bar{B}_{i}=\Delta_{i}B_{i},$ (2) $$

where $S_{B},S_{C},S_{\Delta}$ are linear projection layers, and Softplus is asmooth approximation of ReLU.

The usage of input-dependent time-variant layers adds to the expressivity of the layer, allowing it to adapt to the input, and potentially captures more complex dependencies. While other input-dependent time-variant mechanisms have been proposed in previous works through gated RNNs, the S5 layer (Smith et al., ), or adaptive filtering via input-dependent IIR filters (Lutati et al., ), S6 also presents an efficient IO-aware implementation, which is parallelized on GPUs via work-efficient parallel scanners (Blelloch, ; Martin & Cundy, ).

The Mamba block combines the S6 layer, Conv1D and other elementwise operators. It borrows elements from Gated MLP, and given an input $x:=(x_{1},\cdots x_{L})$, it is computed by:

$$ $\hat{x}=\text{SiLU( Conv1D( Linear(}x\text{) ) )},\quad\hat{z}=\text{SiLU( Linear(}x\text{) )},\quad\hat{y}^{\prime}=\text{Linear}(\text{Selective SSM}( \hat{x})\otimes\hat{z}),\quad$ (3) $$

where $\otimes$ denotes elementwise multiplication.

The entire Mamba model contains $\Lambda$ stacked Mamba blocks with $D$ channels per block. Below, the tensors of the j-th channel in the i-th block are denoted by superscript indices of the form $i,j$.

The vision Mamba architectures (Liu et al., ; Zhu et al., ) (ViM) follow the vision Transformer (ViT) (Dosovitskiy et al., ) but replace the Transformer’s self-attention mechanism by two bidirectional Mamba layers, These vision models outperform the standard ViT in terms of accuracy and efficiency, for models of similar parameter counts.

Gated-Linear RNNs. RNNs, along with their advanced versions, such as GRU (Chung et al., ) and LSTM (Hochreiter & Schmidhuber, ), play a fundamental role in deep sequence modeling. Their auto-regressive design decouples sequence length from computational complexity per step, making them highly efficient at decoding. However, they don’t scale as effectively as Transformers and often face challenges, such as slow training and vanishing gradients. Recently, linear RNNs have shown improved abilities in capturing long-range dependencies (Gu et al., ; Orvieto et al., ) and enhanced scalability (Peng et al., ; De et al., ). Furthermore, gated linear RNNs deliver surprisingly strong language modeling performance (Mehta et al., ; Wang et al., ; Peng et al., ; Qin et al., ).
The most advanced gated linear RNNs include the following variants: (i) RWKV-6 (Peng et al., ), which draws inspiration from attention-free Transformers (AFT) (Zhai et al., ), (ii) Mamba (Gu & Dao, ), which employs selective SSM, (iii) HGRN2 (Qin et al., ), which utilizes state expansion, and (iv) Hawk (De et al., ), which is built upon an enhanced variant of the LRU (Orvieto et al., ). Other notable examples include GLA (Yang et al., ), GateLoop (Katsch, ), and RenNet (Sun et al., ). These layers achieve results comparable to Transformers on larger scales, matching well-known models, such as Pythia (Biderman et al., ) and LLaMA 2 (Touvron et al., ). Moreover, several studies show that hybrid models combining attention mechanisms with gated linear RNNs can be complementary (De et al., ; Lieber et al., ; Poli et al., ; Ma et al., ; Baron et al., ; Fu et al., ), enhancing both approaches. Despite these successes, interoperability and explainability techniques for these models remain relatively unexplored.

## 3 Method

In this section, we present a general and holistic data-control linear operator representation that can be applied to (at least) many of the recent non-Transformer architectures and which incorporates all components of the architecture. Our objective is to describe each layer in the form of $y=\tilde{\alpha}x$ such that x and y is the input and output respectively, and $\tilde{\alpha}=f(x;\Theta_{\text{arch}})$ is an attention matrix controlled by the parameters of the model and the input. Sec. 3.1 formulates the entire Mamba and Mamba-2 Dao & Gu () architectures as a data-control linear operator, incorporating subcomponents such as Conv1D, gate branches, normalizations and activations. Subsequently, Sections. 3.2 and 3.3 extend our approach to other architectures, such as Griffin (De et al., ) and RWKV (Peng et al., ). Additionally, in Appendix A, we present how to extract holistic data-controlled attention matrices for RetNet (Sun et al., ) and HGRN (Qin et al., ).

Figure: Figure 1: Unified and Interpretable Formulation of Attention-Free Architectures via Attention Matrices: (Left) Schematic overview of the architectures of Mamba, Griffin, and RWKV. (Right) A new view of those layers that rely on implicit attention. Our perspective enables the generation of attention maps, offering valuable applications in areas such as Explainable AI.
Refer to caption: extracted/5937516/figs/allAsAttention.jpg

### 3.1 Formulation of Mamba via Attention matrices

Mamba can be formulated in a way that separates the components that mix channels from those that mix tokens:

$$ $\text{Mamba}(x)=\text{Linear}_{3}\Big{(}\text{ SILU}(\text{Linear}_{2}(\text{ Linear}_{1}(x)))\otimes\text{S6}(\text{SILU}(\text{Conv1D}(\text{Linear}_{1}(x ))))\Big{)}$ (4) $$

Since $\text{Linear}_{1}$ and $\text{Linear}_{3}$ do not mix tokens, they are less relevant to our representation (similar to the MLP layers in Transformers), and we consider the following simplified expression:

$$ $\text{Mamba}(x)=\Big{(}\text{ SILU}(\text{Linear}_{2}(x))\Big{)}\otimes\Big{(} \text{S6}(\text{SILU}(\text{Conv1D}(x)))\Big{)}$ (5) $$

Replacing the element-wise gating multiplication with matrix multiplication leads to:

$$ $\text{Mamba}(x)=\text{diag}\Big{(}\text{ SILU}(\text{Linear}_{2}(x))\Big{)} \Big{(}\text{S6}(\text{SILU}(\text{Conv1D}(x)))\Big{)}$ (6) $$

The S6 layer can be formalized as a data-control linear operator (see Eq. 12 in (Ali et al., )):

$$ $\text{S6}(x)=\hat{\alpha}x,\quad\hat{\alpha}_{i,j}=C_{i}\Big{(}\Pi_{k=j+1}^{i} \bar{A}_{k}\Big{)}\bar{B}_{j}$ (7) $$

By plugging Eq. 7 into Eq. 6 and since $\text{SILU}(x)=\text{Sigmoid}(x)\cdot x$:

$$ $\text{Mamba}(x)=\underbrace{\text{diag}\Big{(}\text{ SILU}(\text{Linear}_{2}(x ))\Big{)}}_{W_{x}^{\prime}\in\mathbb{R}^{L\times L},\quad(\text{gate)}}\hat{ \alpha}\underbrace{\text{diag}\Big{(}\text{Sigmoid}(\text{Conv1D}(x))\Big{)}}_ {Z_{x^{\prime}}\in\mathbb{R}^{L\times L},\quad(\text{Conv \& Act})}(\text{Conv 1D}(x))$ (8) $$

Recall that causal Conv1D layer with filter $f=(f_{1},\cdots,f_{\hat{L}})$ can be converted into a matrix form by arranging shifted copies of the filter into rows, forming a convolution matrix $M$. This matrix is then multiplied by the input sequence to produce an output, where each element represents the dot product of the filter and a corresponding segment of the input.

By plugging the convolution matrix $M$ and the gate matrix $W_{x}^{\prime}$ into Eq. 8, we get:

$$ $\text{Mamba}(x)={W_{x}^{\prime}}{\hat{\alpha}}{Z_{x^{\prime}}}Mx=Hx,\quad H={W _{x}^{\prime}}{\hat{\alpha}}{Z_{x^{\prime}}}M$ (9) $$

Therefore, the entire Mamba layer can be viewed as a data-control linear operator, which implicitly parameterizes the per-channel implicit attention matrices through the parameters of the S6 layer, the Conv1D filter, the linear layer in the gate branch, and is controlled by the input $x$

Mamba-2 This architecture builds upon Mamba by introducing two key enhancements relevant to our formulation: (i) incorporating the concept of multiple heads via a multi-input SSM, and (ii) applying additional normalization (GroupRMSNorm) after the multiplicative gating.

The first modification can be handled by broadcasting parts of the equations across different attention heads. For the second modification, we first compute the per-head statistics necessary for Group Normalization and pack them into a diagonal matrix.

$$ $\mu_{h}=\frac{1}{d}\sum_{i=1}^{d}x_{h}[i],\quad\sigma_{h}=\epsilon+\sqrt{\frac {1}{d}\sum_{i=1}^{d}\left(x_{h}[i]-\mu_{h}\right)^{2}},\quad\mathbb{N}=\text{ diag}\left(\frac{1}{\sigma_{1}},\cdots,\frac{1}{\sigma_{h}},\cdots,\frac{1}{ \sigma_{H}}\right)$ (10) $$

where $x_{h}[i]$ denotes the $i$-th feature of head $h\in[H]$, $d$ is the dimensionality of each head, and $\epsilon$ is a small constant added for numerical stability in GroupRMSNorm.

The matrix $\mathbb{N}$ allows us to represent the GroupRMSNorm operator via matrix multiplication such that $\mathbb{N}x=\text{GroupRMSNorm}(x)$ (where $\mathbb{N}$ is augmented across groups). Thus, we plug these modifications into our formulation of Mamba (Equation 9), obtaining the following implicit-attention formulation for Mamba-2:

$$ $\text{Mamba-2}(x)=\mathbb{N}W_{x}^{\prime}\hat{\alpha}Z_{x^{\prime}}Mx=Hx$ (11) $$

### 3.2 Formulation of Griffin via Attention Matrices

The component that captures interactions between tokens in Hawk and Griffin (regardless of self-attention) is the temporal mixing block, which is built on top of a Real-Gated Linear Recurrent Unit (RG-LRU), Conv1D, and gating. It can be formalized as follows:

$$ $y=\text{Linear}_{3}\Big{(}\Big{(}\text{GeLU}(\text{Linear}_{1}(x^{\prime})) \Big{)}\otimes\Big{(}\text{RG-LRU}(\text{Conv1D}(\text{Linear}_{2}(x^{\prime}) )\Big{)}\Big{)}$ (12) $$

We first rearrange the linear layers and replace elementwise gating with matrix multiplication:

$$ $x=\text{Linear}_{2}(x^{\prime}),\quad y=\text{Linear}_{3}\Big{(}\text{diag} \Big{(}\text{GeLU}(\text{Linear}_{1}^{\prime}(x))\Big{)}\Big{(}\text{RG-LRU}( \text{Conv1D}(x))\Big{)}\Big{)}$ (13) $$

Note that $\text{Linear}_{1}^{\prime}:=\text{Linear}_{1}\text{Linear}_{2}$ and $\text{Linear}_{3}$ do not mix tokens and can therefore be omitted. By substituting Conv1D with matrix multiplication using a causal convolution matrix $M$, we derive:

$$ $y=\text{diag}\Big{(}\text{GeLU}(\text{Linear}_{1}^{\prime}(x)\Big{)}\Big{(} \text{RG-LRU}(Mx)\Big{)}$ (14) $$

RG-LRU is defined by the following recurrent rule:

$$ $r_{t}=\sigma(W_{a}x_{t}+b_{a}),\quad i_{t}=\sigma(W_{x}x_{t}+b_{x}),\quad a_{t }=a^{cr_{t}},\quad h_{t}=a_{t}\otimes h_{t-1}+\sqrt{1-{a_{t}}^{2}}\otimes(i_{t }\otimes x_{t})$ (15) $$

This linear recurrent rule can be converted to a matrix form as follows:

$$ $h=\tilde{\alpha}x,\textbf{ }\begin{bmatrix}h_{1}\\ h_{2}\\ \vdots\\ h_{L}\\ \end{bmatrix}=\begin{bmatrix}\sqrt{1-{a_{1}}^{2}}\otimes i_{1}&0&\cdots&0\\ a_{2}\sqrt{1-{a_{1}}^{2}}\otimes i_{1}&\sqrt{1-{a_{2}}^{2}}\otimes i_{2}& \cdots&0\\ \vdots&\vdots&\ddots&0\\ \Pi_{k=2}^{L}a_{k}\sqrt{1-{a_{1}}^{2}}\otimes i_{1}\quad&\Pi_{k=3}^{L}a_{k} \sqrt{1-{a_{2}}^{2}}\otimes i_{2}\quad&\cdots\quad&\sqrt{1-{a_{L}}^{2}}\otimes i _{L}\end{bmatrix}\begin{bmatrix}x_{1}\\ x_{2}\\ \vdots\\ x_{L}\\ \end{bmatrix}$ (16) $$

By plugging Eq.16 into Eq.14, we see that the entire temporal mixing block can be formalized as a data-control linear operator:

$$ $y=\text{diag}\Big{(}\text{GeLU}(\text{Linear}_{1}^{\prime}(x))\Big{)}\tilde{ \alpha}Mx=Hx,\quad H=\text{diag}\Big{(}\text{GeLU}(\text{Linear}_{1}^{\prime}( x))\Big{)}\tilde{\alpha}M$ (17) $$

### 3.3 Formulation of RWKV via Attention Matrices

The time-mixing block of RWKV includes three components: the WKV operator , a gate branch, and a token shift. For simplicity, we will ignore the token shift operation over the values. The simplified RWKV, which maps the input $x_{t}$ to the output $o_{t}$ , can be formulated as follows:

$$ $r_{t}=W_{r}\cdot(u_{r}\otimes x_{t}+(1-u_{r})\otimes x_{t-1}),\quad k_{t}=W_{k }\cdot(u_{k}\otimes x_{t}+(1-u_{k})\otimes x_{t-1}),\quad v_{t}=x_{t}$ (18) $$

$$ $wkv_{t}=\frac{\sum_{i=1}^{t-1}e^{-(t-1-i)w+k_{i}}\otimes v_{i}+e^{u+k_{t}} \otimes v_{t}}{\sum_{i=1}^{t-1}e^{-(t-1-i)w+k_{i}}+e^{u+k_{t}}},\quad o_{t}=W_ {o}\sigma(r_{t})\otimes wkv_{t}$ (19) $$

where $W_{r},W_{k},W_{o}$ are linear projections, and $u,w,u_{r},u_{k}$ are learnable parameters.

Now, we will reformulate the $wkv_{t}$ operator into a form of causal self-attention:

$$ $\hat{\alpha}_{i,j}=\begin{cases}\frac{e^{u+k_{i}}}{\sum_{m=1}^{i-1}e^{-(t-1-m) w+k_{i}}+e^{u+k_{t}}}&\text{if $j=i$ holds},\\ \frac{e^{-(i-1-j)w+k_{t}}}{\sum_{m=1}^{i-1}e^{-(t-1-m)w+k_{i}}+e^{u+k_{t}}}& \text{if $j<i$ holds},\\ 0&\text{otherwise}.\end{cases}\quad\quad\quad\quad\quad\hat{\alpha}x=wkv$ (20) $$

Note that $W_{o}$ does not mix tokens and can therefore be omitted. By plugging Eq. 20 into Eq. 18, and replacing element-wise gating with matrix multiplication, we obtain:

$$ $o=\text{diag}(\sigma(r))\hat{\alpha}x$ (21) $$

### 3.4 Shared properties

The proposed formulation for Griffin, Mamba, and RWKV is based on the similarities in the structure of the architecture. Our formulation focuses on three main components: (i) the core of the linear attention mechanism (S6 for Mamba, RG-LRU for Griffin, or the WKV operator for RWKV), (ii) a short filter operation implemented via Conv1D in Griffin and Mamba and token shift in RWKV, and (iii) the gate branch, as illustrated in Fig. 1. Additionally, our formulation builds on the following key components: (1) rearranging linear layers and omitting operators that don’t influence the mixer components, (2) representing the gate branch, activations, and normalization layers as a data control linear operator via diagonal matrices, (3) unrolling the linear recurrent layer to obtain a token-to-token map, and (4) fusing several cascaded linear operators and ignore biases.

## 4 Experiments

To assess the effectiveness of our implicit attention formulation, we perform a comprehensive set of experiments. In Sec. 4.1, we begin by visualizing the implicit attention matrices and the corresponding explainability maps built upon them. In Sec 4.2, we demonstrate that integrating our improved attention matrices into existing attribution methods results in SoTA interperablity techniques. We further conduct ablations to analyze the contribution of each architectural component to the overall representation. Finally, in Sec. 4.3, we show how our formulation enables the transfer of performance-enhancing techniques, originally designed for other architectures, to gated RNNs.

Figure: Figure 2: Hidden Attention Matrices: Attention matrices of LLMs. Each row represents a different layer within the models, showcasing the evolution of the attention matrices at 25% (top), 50%, and 75% (bottom) of the layer depth.
Refer to caption: extracted/5937516/figs/attentionMatrices/transfromer/tttransfromer_attention_map_layer_6_channel_9.png

### 4.1 Visualizations

In Figure 2, we present a comparative visualization of the attention matrices from Mamba, RWKV, Griffin, and Transformer models. To enhance clarity, we applied the Softmax function to each row of the attention matrices from the Transformers and conducted min-max normalization on the absolute values of the matrices from the non-Transformer models. In every instance, we used a uniform prompt of size 32. For each model, we examined the attention matrices derived from the standard pre-trained models available in the Hugging Face, including the Recurrent Gemma-2B, RWKV-430M trained on the Pile, and a Mamba-based LLM with 2.8B parameters also trained on the Pile.

As illustrated, the implicit attention matrices of Mamba, Griffin, and RWKV exhibit similarities to those derived from traditional Transformers. Echoing findings from (Ali et al., ), we note that dependencies between distant tokens become more apparent in the deeper layers, as shown in the lower rows. Additionally, the matrices from RWKV are characterized by distinct horizontal tiles, whereas those from Mamba display a more continuous structure.

Visualization of Explainability Maps. Sample explainability maps built on top of our implicit attention formulation are resented in Figure 3. This visualization focuses on the rows of the attention maps that are associated with the [CLS] token, as is traditionally done for interpretability purposes. We explore the attention matrices with three explanation methods: raw attention, attention rollout (Abnar & Zuidema, ), and attribution following Ali et al. (), along with a comparison to the ViT counterparts. Evidently, the explanation methods that are based on our attention formulation (columns e, f, and g) depict much more accurate and sharp maps compared to those of (Ali et al., ) and the ViT counterparts. In Fig. 4 we show similar visualizations in the NLP domain. More qualitative results for the NLP domain can be found in Appendix. D.

Figure: Figure 3: Qualitative results for the different explanation methods for the ViT and ViM, both of small size. (a) The original image, (b) Raw-Attention over ViM, (c) Attention-Rollout over ViM, (d) Mamba-Attribution over ViM, (e) Raw-Attention with our proposed attention over ViM, (f) Attention-Rollout with our proposed attention over ViM, (g) Mamba-Attribution with our proposed attention over ViM, (h) Raw-Attention of ViT, (i) Attention-Rollout for ViT, (j) Transformer-Attribution for ViT. Results for columns (b), (c), and (d) are based on the method of (Ali et al., ), and the ViT results on (i), (j) and (k) rely on Chefer et al. ().
Refer to caption: extracted/5937516/figs/main/1/image_1.png

Figure: Figure 4: Qualitative results for NLP, samples are taken from IMDB movie sentiment classification. In (a), we show the results for the previously proposed Mamba’s attention (Ali et al., ), (b) our proposed Mamba’s attention, and in (c) we show our proposed method over RWKV. In the upper row, we show a negative sentiment, and in the lower row, we show a positive sentiment.
Refer to caption: extracted/5937516/figs/nlp/v1_neg.png

### 4.2 Implicit Attention-Based Attribution

Although empirical evaluation of attribution methods is challenging, this section demonstrates that off-the-shelf techniques, when built on top of our implicit attention formulation, produce SoTA explainability tools. We provide empirical analysis via perturbation and segmentation tests.

Perturbation Tests. To assess the faithfulness of explanations, we adopted an input perturbation scheme similar to (Chefer et al., ; ). This method involves systematically masking image pixels based on their predicted relevance from the explanation method. We conducted experiments with both positive and negative perturbations on both NLP and Vision domains. For positive perturbation, a good explanation prioritizes relevant pixels. We expect the model’s accuracy (specifically, top-1 accuracy) to gradually decrease as we mask pixels in descending order of relevance (most relevant first). As for negative Perturbation, a robust explanation should maintain model accuracy even when irrelevant pixels are masked. Here, we mask pixels in ascending order of relevance (least relevant first). In both scenarios, we evaluate the explanation quality using the Area-Under-Curve (AUC) metric. AUC considers the model’s accuracy as a function of the percentage of masked pixels (ranging from $10\%$ to $90\%$).

The perturbations results for vision models are summarized in Table 1 for various explanation methods under both positive and negative perturbation scenarios on the ImageNet validation set. In the positive perturbation scenario, where lower AUC values indicate better performance, our proposed Mamba’s attention method consistently outperforms the other methods. Specifically, our method achieves the lowest AUC values across all explanation methods, with an AUC of $13.264$ for Raw-Attention, $12.830$ for Attn-Rollout, and a notably low $11.350$ for Attribution. In the negative perturbation scenario, where higher AUC values are better, our method shows the best performance, with AUC values of $47.705$ for Raw-Attention, 50.035 for Attn-Rollout, and $51.310$ for Attribution, outperforming both the method of (Ali et al., ) and the counterpart XAI methods for ViT.

**Table 1: Perturbation Tests for Vision. We present the AUC results (percentages) for the predicted class on the ImageNet validation set. For positive perturbation lower is better, and for negative perturbation higher is better. Previous results by (Ali et al., ) denoted by ^⋄.**
|  | Positive Perturbation $\downarrow$ | Negative Perturbation $\uparrow$ |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
|  | Mamba ^⋄ | Mamba Ours | Transformer | Mamba ^⋄ | Mamba Ours | Transformer |
| Raw-Attention | 17.268 | 13.264 | 20.687 | 34.025 | 47.705 | 40.766 |
| Attn-Rollout | 18.806 | 12.830 | 20.594 | 41.864 | 50.035 | 43.525 |
| Attribution | 16.619 | 11.350 | 15.351 | 39.632 | 51.310 | 48.089 |

In the NLP domain, we conducted perturbation tests in both the zero-shot and fine-tuned settings. In the zero-shot setting, we utilized pre-trained Mamba-based LLMs with sizes of 1.3B and 2.8B on the ARC-E dataset (Clark et al., ), which evaluates the reasoning abilities of LLMs. Results are presented in Table 2 and contain activation and pruning perturbations, as described by Ali et al. (). It is shown that our explainability method improves upon the baseline of Ali et al. () for both model sizes. Specifically, in the activation scenario, our method improves results by at least 2.2%, and by over 10% in the pruning settings. Similar trends are also evident in the fine-tuned scenario, see Appendix C for these results for both Mamba and RWKV. Taken together, these results demonstrate that our attention formulation is much more precise and better reflects the model’s behavior compared to the formulation proposed by Ali et al. (). The same phenomenon occurs with the RWKV model, consistently showing that our formulation can lead to SoTA attribution methods for an entire family of models.

**Table 2: Perturbation Tests for NLP. For activation perturbation lower is better, and for pruning perturbation higher is better. Previous results by (Ali et al., ) denoted by ^⋄.**
|  | Activation Perturbation (AUAC) $\uparrow$ | Pruning Perturbation (AU-MSE)   $\downarrow$ |  |  |
| --- | --- | --- | --- | --- |
|  | Mamba 1.3B | Mamba 1.3B | Mamba 2.8B | Mamba 2.8B Ours |
| Attribution of (Ali et al., ) | 0.915 | 0.918 | 1.765 | 1.239 |
| Our Attribution | 0.934 | 0.939 | 1.588 | 1.082 |

Segmentation Tests. We evaluated our proposed Mamba’s implicit attention mechanism by comparing its generated foreground segmentation maps against ground truth from the ImageNet-Segmentation dataset (Guillaumin et al., ). We employed established metrics (pixel accuracy, mean Intersection-over-Union (mIoU), and mean Average Precision (mAP)) aligning with prior works (Chefer et al., ; Nam et al., ; Gur et al., ). Notably, we compared our method with both the ViT and the previously proposed Mamba’s implicit attention from (Ali et al., ).

Results presented in Table 3 demonstrate that our proposed Mamba’s implicit attention outperforms both the ViT and the previous proposed Mamba’s attention of  (Ali et al., ) on all metrics over the three different XAI methods. This superior performance suggests the potential of these maps for downstreaming tasks such as weakly supervised semantic segmentation, and mitigating background bias in classifiers (Chefer et al., ).

**Table 3: Segmentation results on the ImageNet-Segmentation dataset (percent). Higher is better.**
| Model | Method | Pixel accuracy $\uparrow$ | mAP $\uparrow$ | mIoU $\uparrow$ |
| --- | --- | --- | --- | --- |
| DeiT S | Raw-Attention | 59.69 | 77.25 | 36.94 |
| ViM-S | Raw-Attention (Ali et al., ) | 67.64 | 74.88 | 45.09 |
| ViM-S | Raw-Attention Ours | 67.66 | 80.00 | 47.28 |
| DeiT-S | Attn-Rollout (Abnar & Zuidema, ) | 66.84 | 80.34 | 47.85 |
| ViM-S | Attn-Rollout (Ali et al., ) | 71.01 | 80.78 | 51.51 |
| ViM-S | Attn-Rollout Ours | 76.40 | 83.90 | 58.48 |
| DeiT-S | Transformer-Attr (Chefer et al., ) | 79.26 | 84.85 | 60.63 |
| ViM-S | Mamba-Attr (Ali et al., ) | 74.72 | 81.70 | 54.24 |
| ViM-S | Mamba-Attr Ours | 79.60 | 86.40 | 62.51 |

[Uncaptioned image]: extracted/5937516/figs/ablate_mamba/MAMBA_attention_map_layer_8_channel_finalMAT.png

Ablation study. The architectures we explored implicitly parametrize attention matrices through a composition of several different sub-layers, see Eq.9, 21, and 17. Examples of these sub-layers include linear recurrent layers, gate mechanisms, activations, normalization and other components, such as token-shift or depth-wise convolutions. To better understand the contribution of each of these components, we conduct a sequence of ablation studies. Initially, in Fig. 4.2, we visualize the implicit attention of Mamba, ablating the Conv1D or the gate branch, or focusing solely on the S6 layer. As expected, it seems that the Conv1D causes a smoothing effect, and the Mamba matrices are significantly sharper, with more pixels having non-negligible values compared to those of S6.

In Table 4.2, we compare several ablation variants of our method. As can be seen, our method, which utilizes all the components of Mamba, achieves a much better score than the ablated versions, illustrating the importance of all components. This experiment reveals that including the Conv1D and gating mechanism is crucial for high performance and reliable representation. However, the activation has a relatively low impact on these aspects. A similar ablation study was conducted for RWKV and presented in Appendix C, demonstrating similar trends.

### 4.3 Attribution-Based Performance-Enhancing Techniques

To further demonstrate the practical impact of our representation, we show it can enhances model performance. While various attention-based and explainability-based techniques was previously proposed for improving model performance, our focus is on in-context learning (ICL) and weakly supervised semantic segmentation tasks.

To improve ICL, we adopt the AMPLIFY method of Krishna et al. (), a prompt engineering technique designed for few-shot ICL, which leverages post-hoc explanation methods. In our experiments, we use the Mamba-790m model as a proxy, following the same evaluation protocol as AMPLIFY, but with an attribution method that relies on attention matrices. We report the vanilla model performance, and the performance with AMPLIFY with our attribution method and the attribution method of Ali et al. (). The results are depicted in Tab. 4, show that our method outperforms the baseline across all tested scenarios except one, with an average margin of 1.2 accuracy points over the amplify baseline, and 9.8% over the vanilla baseline.

Detailed results and experimental settings for weakly supervised semantic segmentation are presented in Appendix B.

**Table 4: Performance of various Mamba-based LLMs on Snarks, CommonsenseQA, and Formal Fallacies datasts. We compare the vanilla model performance, and models employ the Amplified method, with our attribution method or the attribution method of Ali et al. () (denoted by ^⋄).**
| Model size | Snarks (%) | CommonsenseQA (%) | Formal Fallacies (%) |
| --- | --- | --- | --- |
| 1.3B | 44.54 | 52.15 | 40.13 |
| 1.3B + AMPLIFY ^⋄ | 53.11 | 53.55 | 44.28 |
| 1.3B + AMPLIFY (Ours) | 56.15 | 54.72 | 45.22 |
| 2.8B | 48.75 | 53.11 | 44.67 |
| 2.8B + AMPLIFY ^⋄ | 58.10 | 56.10 | 47.80 |
| 2.8B + AMPLIFY (Ours) | 60.02 | 56.08 | 47.86 |

## 5 Conclusions

In this study, we have extended the use of self-attention from its traditional role as the core mechanism of Transformers to a representation of neural sequence layers. Our unified framework facilitates the exploration of similarities and differences among non-attention layers, such as Mamba, RWKV, and Griffin, and their interconnections with Transformer architectures. Additionally, it enables the development of innovative explainability techniques for the latest attention-free architectures. Our contributions provide the research community with new tools for analyzing the performance, fairness, and robustness of gated-linear RNN variants, while also identifying their potential vulnerabilities. These advancements set the stage for future improvements and support the implementation of weakly supervised downstream tasks.

Looking ahead, we aim to incorporate additional layers, such as Hyena (Poli et al., ), and HGRN2 (Qin et al., ) into our framework, including their vision-specific variants (Duan et al., ; Fan et al., ; Zimerman & Wolf, ; Spravil et al., ). Furthermore, we plan to examine how differences in these architectures are reflected in their self-attention matrices and explore whether such insights can reveal more about the inductive bias inherent in each architecture.

## 6 Acknowledgments

This work was supported by a grant from the Tel Aviv University Center for AI and Data Science (TAD). This research was also supported by the Ministry of Innovation, Science & Technology ,Israel (1001576154) and the Michael J. Fox
Foundation (MJFF-022407). The contribution of the first author is part of a
PhD thesis research conducted at Tel Aviv University.

## Appendix A Representing additional architectures via implicit attention

In sec. 3 we present the formulation of Griffin, RWKV, and Mamba via attention matrices. In this section, we extend our method to other layers, such as RetNet (Sun et al., ) and HGRN (Qin et al., ).

RetNet
The Retention Network is composed of two primary blocks: (i) the Multi-Scale Retention (MSR) layer and the (ii) FFN layer, which operates independently across tokens. The MSR layer, responsible for token mixing, is built on top of the retention sub-layer and is defined as follows:

$$ $\textbf{head}_{i}=\textbf{Retention}(X,\gamma_{i}),\quad\gamma_{i}=1-2^{-5-i}, \quad Y=\textbf{GroupNorm}_{h}(\textbf{Concat}(\textbf{head}_{1},\cdots, \textbf{head}_{h}))$ (22) $$

Furthermore, the outputs are scaled using a data-control gate branch, parameterized by a matrix $W_{G}\in\mathbb{R}^{D\times D}$:

$$ $\textbf{MSR(X)}=(\textbf{swish}(XW_{G})\otimes Y)$ (23) $$

To refine this formulation, we can represent the element-wise multiplication as a matrix multiplication using a diagonal matrix $G=\textbf{diag}(\textbf{swish}(XW_{G}))$. Additionally, per-head statistics can be integrated into $G$. Given that the parallel representation of Retention can be depicted via an attention matrix $R$ (see Eq. 5 in (Sun et al., )), the entire MSR block simplifies to:

$$ $\textbf{Retention}(x)=GRx$ (24) $$

HGRN  The Hierarchically Gated RNN (HGRN) is first defined with the following recurrent rule:

$$ $\mathbf{f}_{t}=\mathrm{Sigmoid}\left(\mathbf{x}_{t}\mathbf{W}_{f}+\mathbf{b}_{ f}\right)\in\mathbb{R}^{1\times d},\quad\mathbf{i}_{t}=\mathrm{Sigmoid}\left( \mathbf{x}_{t}\mathbf{W}_{i}+\mathbf{b}_{i}\right)\in\mathbb{R}^{1\times d}$ (25) $$

$$ $\mathbf{c}_{t}=\mathrm{SiLU}\left(\mathbf{x}_{t}\mathbf{W}_{t}+\mathbf{b}_{z} \right)\in\mathbb{R}^{1\times d},\quad\mathbf{h}_{t}=\mathbf{f}_{t}\otimes \mathbf{h}_{t-1}+\mathbf{i}_{t}\otimes\mathbf{c}_{t}\in\mathbb{R}^{1\times d}$ (26) $$

where the output of the recurrent $h_{t}$ is multiplied by $g_{t}=\textbf{SiLU}(\textbf{Linear}(x))$ to produce the output:

$$ $o_{t}=g_{t}\otimes h_{t}$ (27) $$

Note that the recurrent rule of the HGRN layer can be computed via an implicit attention represented by a matrix $\alpha_{r}$ (see Eq. 5 in (Qin et al., )), as follows:

$$ $H:=(h_{1},\cdots,h_{L}),\quad C=(c_{1},\cdots,\quad c_{L}),\quad H=\alpha_{r}c$ (28) $$

Hence, by define $G=\textbf{diag}(\textbf{SiLU}(\textbf{Linar}(x)))$, $G_{act}=\textbf{diag}(\textbf{sigmoid}(x))$.

Furthermore, we can rearrange the linear layer such that $W_{t}$ and $b_{z}$ will be omitted, and obtain:

$$ $G_{\textbf{ACT}}=\textbf{diag}(\textbf{Sigmoid(x)}),\quad o=G{\alpha}_{r}G_{ \textbf{ACT}}x$ (29) $$

which is a linear operator characterized by an input-dependent matrix, defined as $G=\textbf{diag}(\textbf{Sigmoid}(x))$. The output $o$ is given by $o=G\alpha_{r}$.

$$ $\mathbf{f}_{t}=\mathrm{Sigmoid}\left(\mathbf{x}_{t}\mathbf{W}_{f}+\mathbf{b}_{ f}\right)\in\mathbb{R}^{1\times d},\quad\mathbf{i}_{t}=\mathrm{Sigmoid}\left( \mathbf{x}_{t}\mathbf{W}_{i}+\mathbf{b}_{i}\right)\in\mathbb{R}^{1\times d}$ (30) $$

$$ $\mathbf{c}_{t}=\mathrm{SiLU}\left(\mathbf{x}_{t}\mathbf{W}_{t}+\mathbf{b}_{z} \right)\in\mathbb{R}^{1\times d},\quad\mathbf{h}_{t}=\mathbf{f}_{t}\otimes \mathbf{h}_{t-1}+\mathbf{i}_{t}\otimes\mathbf{c}_{t}\in\mathbb{R}^{1\times d}$ (31) $$

where the output of the recurrent $h_{t}$ is multiplied by $g_{t}=\textbf{SiLU}(\textbf{Linar}(x))$ to produce the output:

$$ $o_{t}=g_{t}\otimes h_{t}$ (32) $$

Note that the recurrent rule of the HRGU layer can be computed via an implicit attention represented by a matrix ${\alpha}_{r}$ (see Eq. 5 in (Qin et al., )), as follows:

$$ $H:=(h_{1},\cdots,h_{L}),\quad C=(c_{1},\cdots,\quad c_{L}),\quad H=\alpha_{r}c$ (33) $$

Hence, by define $G=\textbf{diag}(\textbf{SiLU}(\textbf{Linar}(x)))$, $G_{act}=\textbf{diag}(\textbf{sigmoid}(x))$.

Furthermore, we can rearrange the linear layer such the $W_{t}$,$b_{z}$ will be omitted, and obtain:

$$ $G_{\textbf{ACT}}=\textbf{diag}(\textbf{Sigmoid(x)}),\quad o=G{\alpha}_{r}G_{ \textbf{ACT}}x$ (34) $$

as requested.

## Appendix B Weakly Supervised Semantic Segmentation

In weakly supervised semantic segmentation (WSSS), a common approach involves first training a classifier on image-level labels and then extracting Class Activation Maps (CAMs) for individual images, which highlight regions that the classifier deems relevant to specific classes. The SoTA methods then employ these CAMs as pseudo-masks to train a segmentation decoder.

In this context, we adopt our proposed Mamba-Attr XAI method for vision-Mamba models. We assess its competitiveness against the well-established CAMs in generating pseudo-labels for Transformers. To ensure a fair comparison, we fine-tune both DeiT-Small and ViM-Small models under identical conditions over the Pascal-voc 2012 (Everingham et al., ) dataset, excluding multi-scale training, inference, or any other modifications. This controlled setting isolates the influence of our Mamba-Attr method on the quality of the generated pseudo-labels.

The results are presented in Table 5. Evidently, Mamba-Attr XAI method achieves competitive results surpassing the baseline approach of Class Activation Maps (CAMs) without any additional modifications. This is evident in the mean Intersection-over-Union (mIoU) score, where Mamba-Attr ($52.11\%$) outperforms the CAM of DeiT-Small ($35.99\%$) by a sizable gap. While Mamba-Attr does not reach the state-of-the-art performance of Toco (Ru et al., ) ($61.10\%$), it achieves, out of the box, a substantial improvement over CAM and comes surprisingly close to this much more elaborate multi-phase learning method which utilizes multiple loss terms specifically designed to enhance the quality of the initial CAM map. These results suggest that Mamba-Attr XAI offers a powerful and efficient solution for WSSS tasks with vision-Mamba models.

**Table 5: Evaluation and comparison of the pseudo-labels for the different classes in Pascal-voc 2012 (Everingham et al., ). Results are in mIoU**
|  | bkg | aero | bicycle | bird | boat | bottle | bus | car | cat | chair | cow | dog | horse | motor | person | plant | sheep | sofa | train | tv | mIoU |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Deit-S + Toco | 86.00 | 56.49 | 37.27 | 76.80 | 45.73 | 58.31 | 82.56 | 71.95 | 76.75 | 30.66 | 79.13 | 71.04 | 81.31 | 71.41 | 59.51 | 44.87 | 80.85 | 41.81 | 60.73 | 29.72 | 61.10 |
| Deit-S | 49.12 | 17.53 | 25.01 | 14.49 | 19.43 | 55.55 | 49.33 | 37.92 | 61.32 | 15.85 | 34.90 | 55.27 | 32.36 | 29.83 | 64.82 | 33.24 | 23.84 | 32.53 | 32.76 | 36.40 | 35.99 |
| Mamba-Attr | 81.81 | 77.33 | 37.23 | 70.88 | 56.45 | 43.83 | 72.30 | 54.11 | 48.25 | 30.20 | 40.25 | 20.76 | 53.10 | 55.95 | 64.94 | 54.46 | 50.35 | 56.57 | 49.22 | 38.58 | 52.11 |

## Appendix C Perturbation Experiments for NLP

In this section, we present results for the perturbation test in the NLP domain with fine-tuned classifiers. In this setting, we fine-tune the last layers of various LLMs and append the [CLS] token to all samples to generate explanation maps, similar to the methods used in vision models.

In Figure 5, we present perturbation results for both positive and negative settings. We utilize Mamba(^1^11[https://huggingface.co/trinhxuankhai/mamba_text_classification](https://huggingface.co/trinhxuankhai/mamba_text_classification)), RWKV(^2^22[https://huggingface.co/BlinkDL/rwkv-2-pile-430m](https://huggingface.co/BlinkDL/rwkv-2-pile-430m)) and BERT(^3^33[https://github.com/hila-chefer/Transformer-Explainability](https://github.com/hila-chefer/Transformer-Explainability)) models as the models of interest and fine-tune them on the IMDB sentiment classification dataset, employing the [CLS] token for all samples. Subsequently, we evaluate the explanation quality using a similar procedure as proposed in (Ali et al., ) for the perturbation experiment.

The results reveal that Mamba-attr, based on our new attention formulation, achieves superior AUC for both negative and positive perturbations compared to the previous attention formulation by (Ali et al., ). Additionally, our unified attention formulation is effective for RWKV models, yielding comparable results to those of Mamba and BERT.

Moreover, as an ablation, the first column of Figure 5 demonstrates that including the gate branch, as presented in our full method, consistently improves performance.

Figure: Figure 5: Evaluation of explanations using input perturbations. Results for IMDB activation task (top row) in which the most relevant words are added first, and for IMDB pruning task (lower row) in which the words of least relevance are removed first. Results are shown for 3 different models: RWKV, Mamba, and BERT, respectively.
Refer to caption: x1.png

## Appendix D Additional qualitative results for NLP

Additional NLP results obtained on IMDB dataset are presented in Figure 6. In panel (a), we show the results for the previously proposed Mamba’s attention (Ali et al., ). Panel (b) shows our proposed Mamba’s attention. Lastly, panel(c) presents our proposed method over RWKV. In red, we show a negative sentiment, and in blue, we show a positive sentiment.

As can be seen from these qualitative results, the explanation maps generated by our new attention formulation exhibit sparser and more accurate heatmaps of relevant words than those of Ali et al. (), aligning with the desired properties of XAI methods. Similarly, the results for RWKV models show comparable success to those of Mamba.

Figure: Table 6: Additional qualitative results on the IMDB dataset. (a) The Mamba attention of Ali et al. (). (b) Our Mamba attention method. (c) Our RWKV attention.
[Uncaptioned image]: extracted/5937516/figs/appendix_nlp/1_v1_neg.png

## Peer Reviews

confidence: 2
contribution: 3
initial_rating: 6
presentation: 2
questions: - What is the best method to evaluate the unified framework beside the interpretability analysis?
soundness: 3
strengths: - The unified framework makes it easier to study and compare the different sequence modelling algorithms.
- It is important for the community to learn about such work.
- The experimental results are interesting.
summary: The paper studies the problem of sequence modelling. The authors aim to provide a unified framework of the recent attention-free methods such as Mamba and RWKV. The paper presents empirical results to validate the proposed unified framework.
weaknesses: Although it is hard to evaluate such approaches empirically, interpretability-based metrics are not very conclusive in general.

---

confidence: 3
contribution: 2
initial_rating: 5
presentation: 3
questions: A critical question is: given that previous work has noted the attention-like properties of models such as Mamba, what specific benefits does the implicit attention framework offer over these prior interpretations?

What are the current explainability methods or metrics for modern gated-linear RNNs and how's the comparison between them and attention matrices?
soundness: 3
strengths: The paper offers a clear explanation of how implicit attention could be used to interpret gated RNNs, making it accessible to readers interested in explainability across model types.

By applying the framework to both NLP and vision tasks, the authors demonstrate its cross-domain relevance.
summary: This paper introduces a unified framework that reformulates various gated recurrent neural network (RNN) architectures, such as Mamba, RWKV, and Griffin, into implicit causal self-attention layers. This reinterpretation aims to make these models more interpretable by constructing attention-like matrices for use in visual and NLP explainability tasks. Experimental evaluations demonstrate that this approach achieves competitive performance in robustness and attribution metrics, though prior work has already suggested that certain gated models, including Mamba, are attention-based.
weaknesses: Previous work has already conceptualized models like Mamba as attention-like, meaning that simply reinterpreting these gated RNNs under an implicit attention framework may not be largely novel.

The paper does not thoroughly compare its implicit attention framework with existing interpretability tools for gated RNNs.

---

confidence: 2
contribution: 3
initial_rating: 6
presentation: 3
questions: See above
soundness: 3
strengths: In my view, this is a pretty complete paper. From my understanding, the authors present an extension of the paper Ali et al. (2024) to include additional architectural components in the linearization and not just the S6 mechanism considered before. The authors show that the model improves interpretability through visualizations and a set of both perturbation and segmentation tests. The ablation gives quite a lot of strength to their arguments, but I am not so familiar with these types of explainability results so I am not able to comment on the details.
summary: This paper writes out gated recurrent architectures such as Mamba, RKWV, and Griffin as causal self-attention layers. The main objective of this is to increase interpretability, which is tested through perturbation and segmentation tests.
weaknesses: While the authors have explored the interpretability side of things extensively, I was wondering if it would be worth comparing the performance of the linearized models compared to its recurrent counterparts when trained on some small datasets?

---

confidence: 3
contribution: 3
initial_rating: 8
presentation: 4
questions: mentioned above.
soundness: 3
strengths: - Covering multiple models including most popular modern non-transformer sequence models.
- Evaluating the performance of the resulting attributions in multiple quantitate experiments and down-stream tasks (across both vision and NLP).
- Showing the impact of various sub-layers in the ablations study
summary: This paper tries to provide an implicit self-attention formulation for most state-of-the art non-transformer sequence models (known as Gated Linear RNNs) such as Mamba, Griffin, RWKV, and ReNet. In this way, it can exploit techniques used in attention explainablity to explain these new models.

Compared to the closest work (Ali et al, 2024), which only formulates the S6 layer in Mamba, the main contribution of paper is:
- Formulating more layers with implicit self-attention and propose a unified and more accurate attention-based representation for all the SOTA gated linear RNNs.

Other contributions include:
- Introducing new explainablity technique for these models leveraging the self-attention formulation
- Showing performance of their explanations and attributions by purturbation testing and segmentation.
- Showing their proposed formulation can give attributions which can further used in some performance-enhancing techniques (based on in-context learning) for large language models.
weaknesses: - In their ablation study, the authors could discuss the trade-off between the time explainability and more accurate formulation/explainability.

- The main baseline paper (Ali et al, 2024) has not been published yet. So, it is hard to evaluate this paper. Actually, the performance of the model in downstream tasks such as segmentation and attribution-based performance-enhancement helped me to have better evaluation of the proposed method.

Meta-review: This paper provides a unified view of attention-free architectures as implicit causal self-attention layers, which they apply to explainability. They also show good results on semantic segmentation and in-context learning.

Overall, the reviewer's side on the acceptance. The main criticism is that the idea that these models exhibit attention-like behavior has been noted before, but the paper does a good job comparing. An interesting direction could have been exploring the tradeoffs between the complexity of the implicit attention formulation vs accuracy

Decision: Accept (Poster)