Generalized Probabilistic Attention Mechanism in Transformers

## Abstract

Abstract The Transformer architecture has become widely adopted due to its demonstrated success, attributed to the attention mechanism at its core. Despite these successes, the attention mechanism of Transformers is associated with two well-known issues: rank-collapse and gradient vanishing. In this paper, we present a theoretical analysis that it is inherently difficult to address both issues simultaneously in the conventional attention mechanism. To handle these issues, we introduce a novel class of attention mechanism, referred to as generalized probabilistic attention mechanism (GPAM), and its dual-attention implementation within the Transformer architecture. Unlike conventional attention mechanisms, GPAM allows for negative attention scores while preserving a fixed total sum. We provide theoretical evidence that the proposed dual-attention GPAM (daGPAM) effectively mitigates both the rank-collapse and gradient vanishing issues which are difficult to resolve simultaneously with the conventional attention mechanisms. Furthermore, we empirically validate this theoretical evidence, demonstrating the superiority of daGPAM compared to other alternative attention mechanisms that were proposed to address the same issues. Additionally, we demonstrate the practical benefits of GPAM in natural language processing tasks, such as language modeling and neural machine translation.

###### Axiom 1 .

###### #1 .

## 1 Introduction

The Transformer model, as introduced by (Vaswani, ), has emerged as a pivotal architecture driving the advancement of contemporary deep learning models across various domains, including natural language processing (Brown et al., ), audio signal processing (Gulati et al., ), and image processing (Dosovitskiy et al., ). Central to the Transformer’s success is the attention mechanism, which facilitates the contextualization of input token representations. Based on the similarities of query and key vectors, the attention mechanism mixes value vectors as follows (a single scaled dot-product self-attention head (Vaswani, )):

$$ $\displaystyle\mathbf{Y}$ $\displaystyle=\mathbf{P}\mathbf{X}_{V},$ (1) $\displaystyle\mathbf{P}_{ij}$ $\displaystyle=\frac{exp(\mathbf{A}_{ij})}{\sum_{k=1}^{T}exp(\mathbf{A}_{ik})},$ (2) $\displaystyle\mathbf{A}$ $\displaystyle=\left(\sqrt{d_{qk}}\right)^{-1}\mathbf{X}_{Q}\mathbf{X}_{K}^{ \top},$ (3) $$

where $\mathbf{X}_{Q}=\mathbf{X}\mathbf{W}_{Q}$, $\mathbf{X}_{K}=\mathbf{X}\mathbf{W}_{K}$, and $\mathbf{X}_{V}=\mathbf{X}\mathbf{W}_{V}$. $\mathbf{X}\in\mathbb{R}^{T\times d}$ is input representations with $T$ sequence length and $d$ dimensionality, and $\mathbf{W}_{Q},\mathbf{W}_{K}\in\mathbb{R}^{d\times d_{qk}}$, and $\mathbf{W}_{V}\in\mathbb{R}^{d\times d_{v}}$ are weight matrices.

Despite its empirical success, the conventional attention mechanism, particularly the self-attention mechanism, has been shown to exhibit two significant limitations. The first issue is the phenomenon known as the rank-collapse problem (Dong et al., ), where output token representations become similar to others, leading to a loss of rank as they progress through each layer. While a controlled degree of rank-reduction can be beneficial for eliminating redundant information (Tishby & Zaslavsky, ), excessive rank-reduction risks the loss of critical information. Previous studies have extensively documented the self-attention layer’s tendency for intensive rank-reduction (Dong et al., ; Noci et al., ; ). The second issue is the gradient vanishing problem (Richter & Wattenhofer, ; Wang et al., ). During the softmax-based normalization step, the gradient is consistently less than 1 and saturates close to 0, thereby impeding upper attention layers’ sufficient flow of gradients to the lower layers. Moreover, in this paper, we demonstrate that these two issues are inherently challenging to address both simultaneously.

Previous approaches to addressing the rank-collapse problem in Transformers have primarily focused on preserving input token representations. One strategy amplifies the coefficient of the shortcut branch in the residual connection (Noci et al., ), while another reduces the contextualization effect by regularizing the attention matrix, $\mathbf{P}$, to be similar to an identity matrix (He et al., ; Noci et al., ). However, these methods can diminish the attention layer’s ability to capture meaningful contextual information (Veit et al., ; Zhang et al., ). To address the gradient vanishing problem, alternative attention mechanisms have been proposed to replace the conventional softmax-based mechanism, Eqs.2 and 3 (Richter & Wattenhofer, ; Wang et al., ). Despite their theoretical effects for improving gradient flow, these alternative mechanisms have not demonstrated practical advantages in benchmark experiments.

Figure: Figure 1: Examples of convex and affine combinations $\mathbf{Y}^{c}$ and $\mathbf{Y}^{a}$, given $\mathbf{X}$ value representations.
Refer to caption: extracted/5923029/Figures/figure1_comparison_convex_affine.png

In contrast to prior approaches, we posit that the underlying issues stem from the convex combination structure in the conventional attention mechanism. The normalized attention scores, $\mathbf{P}_{ij}$, as defined in Eq.2, are non-negative and sum to 1 along the query axis, making the conventional attention mechanism a valid convex combination of input representations. Consequently, as illustrated in Fig.2, the output representations, $\mathbf{Y}^{c}$, are constrained within the convex hull (yellow plane) of the input value representations. This fundamental constraint limits the diversity of output representations, causing them to become more similar to one another than the input value representations, thereby intensifying the rank-collapse problem.

This consideration naturally raised the question: how about making it an affine combination? The affine combination is a generalization of the convex combination, allowing the normalized attention scores to take negative values while still maintaining a total sum to be 1. As depicted in Fig.2, the output representations, $\mathbf{Y}^{a}$, are no longer constrained to lie within the convex hull, but instead within the affine hull (green plane), thereby removing the fundamental constraint that can lead to rank-collapse. However, from a probabilistic perspective, the notion of negative normalized attention scores may seem unconventional, since negative probability is unfamiliar concept. Nevertheless, the discussions by prominent physicists, such as P. Dirac (Dirac, ) and R. Feynman (Feynman, ), have concretized the concept of negative probability by generalizing the Kolmogorov’s probability conditions as follows:
{axiom}[Kolmogorov’s Probability Conditions.]
(1) $P(e)\geq 0$, and (2) $\sum\limits_{e\in\Omega}P(e)=1$ where $P(e)\in\mathbb{R}$ is the probability measure of event $e$ and $\Omega$ is event space.(^1^11For simplicity, we mention only the two main conditions.)
{axiom}[Generalized Probability Conditions (Székely, )]
(1) $\sum\limits_{e\in\Omega}|P(e)|<\infty$, and (2) $\sum\limits_{e\in\Omega}P(e)=1$ where $P(e)\in\mathbb{R}$ is the probability measure of event $e$ and $\Omega$ is event space.
It is important to note that the first condition of generalized probability allows for the possibility of negative probabilities. Building on this long-standing line of research, we introduce the attention mechanism based on the affine (or scaled-affine) combination, which we refer to as the generalized probabilistic attention mechanism (GPAM). As a generalized framework, GPAM encompasses the conventional attention mechanism as a special case where all attention values are non-negative.

In this paper, we explore GPAM in the Transformer architecture, and as a cornerstone design of GPAM, we propose a dual-attention design that facilitates GPAM with adding only a negligible number of parameters. Specifically, we add an additional attention matrix computation to the original scaled dot-product self-(or cross-) attention mechanism with a small additional weight matrix which increases less than 1% of total parameters on average. Then, the resulting two attention matrices are treated as positive and negative parts of the final attention score, respectively. By combining these two attention scores with pre-defined or trainable scalar weights, we ensure that our proposed dual-attention GPAM (daGPAM) a valid affine (or scaled-affine) combination. Fig.2 illustrates the structure of this design.
When we propose a GPAM method, we show theoretically that our method is advantageous for mitigating not only the rank-collapse problem, but also the gradient vanishing problem.
Our empirical validations give evidences for the above theories in various aspects. In addition, we experimentally demonstrate and explain the superiority of daGPAM compared to other alternative attention mechanisms that was proposed to address the mentioned problems. Finally, we demonstrate the benefits of daGPAM in benchmark experiments in tasks such as language modeling (LM) and neural machine translation (NMT).

## 2 Related Works

### 2.1 Rank-Collapse Problem in Transformer

Recent studies have analyzed the occurrence and practical risks of the rank-collapse problem in Transformers (Dong et al., ; Yan et al., ; Noci et al., ; He et al., ; Noci et al., ). The rank-collapse phenomenon refers to the tendency of token representations to become increasingly similar to one another as they are processed through successive layers. The first theoretical exploration of this issue demonstrated that the pure attention layer, as described by Eqs.1$\sim$3, reduces the ‘residual’ at an exponential rate with increasing layer depth. The residual metric quantifies how close token representations are to their mean point in terms of Euclidean distance, and is formally defined as follows:

$$ $\displaystyle res(\mathbf{X})=\mathbf{X}-\mathbf{1}\bar{\mathbf{x}}^{\top}\in \mathbb{R}^{T\times d},\textrm{where }\bar{\mathbf{x}}=\operatorname*{arg\,min }_{\mathbf{x}}\|\mathbf{X}-\mathbf{1}\mathbf{x}^{\top}\|.$ (4) $$

Then, the relationship of input/output residual is derived as follows:

###### Lemma 1 ( Dong et al. ( 2021 ) , Simplified) .

For any single scaled dot-product self-attention layer with a term $\gamma$ that depends on the attention entries, the composite norm of output residual is bounded by

$$ $\displaystyle\|res(\mathbf{Y})\|_{1,\infty}\leq\frac{4\sqrt{2}\gamma\|\mathbf{ W}_{QK}\|_{1}\|\mathbf{W}_{V}\|_{1,\infty}}{\sqrt{d_{qk}}}\|res(\mathbf{X})\|^ {3}_{1,\infty},$ (5) $$

where $\mathbf{W}_{QK}=\mathbf{W}_{Q}\mathbf{W}_{K}^{\top}$. In the region that holds $4\sqrt{2}\gamma\|\mathbf{W}_{QK}\|_{1}\|\mathbf{W}_{V}\|_{1,\infty}<\sqrt{d_{
qk}}$, the output residual norm is diminished compared to the cubic rate of input residual norm.

Building on this lemma and extending it to multi-layer cases, prior research has argued for the existence of the rank-collapse problem and empirically demonstrated that a substantial region of the parameter space that falls into rank-collapse issue (Dong et al., ). For a complete description of the lemma, please refer to Appendix A.1.1, and read the original paper for the proof. In addition to the rank-collapse problem, related concepts such as attention collapse, over-smoothing, over-correlation, and dimensional collapse have been identified in various domains, including vision Transformers (Zhou et al., ; Tang et al., ; Gong et al., ; Wang et al., ), contrastive learning (Jing et al., ; Hua et al., ), graph neural networks (Li et al., ; Jin et al., ; Guo et al., ; Roth & Liebig, ), and general neural networks (Feng et al., ; Jacot, ).

Previous studies have attempted to address the rank-collapse problem through various strategies, such as strengthening the shortcut branch (Tang et al., ; Noci et al., ), regularizing the attention matrix to be similar to an identity matrix (He et al., ; Noci et al., ), and regularizing to preserve local information (Yan et al., ). However, these approaches may weaken the contextualization effect of the attention layer. Alternative methods have proposed various sequence-wise normalization techniques aimed at explicitly diversifying token representations (Hua et al., ; Guo et al., ). However, these techniques may be unsuitable for short sentences and autoregressive architectures due to their reliance on inadequate statistic across sequences. In contrast to these approaches, our GPAM develops the attention layer using a novel methodology grounded in the principles of convex and affine combinations.

###### Lemma 1 ( Dong et al. ( 2021 ) , Simplified) .

### 2.2 Gradient Vanishing Problem in Transformer

Several previous studies have identified the gradient vanishing problem within the Transformer architecture (Zhang et al., ; Richter & Wattenhofer, ; Liu et al., ; Wang et al., ). A primary contributor to this issue is the gradients of the softmax function, as represented in Eq.2, which consistently yield gradient values less than 1. The following lemma derives these gradients.

###### Lemma 2 (Gradient Vanishing in Attention Mechanism) .

The gradient that the input unnormalized attention score, Eq.3, receives through the normalized attention score, Eq.2, (without $1/\sqrt{d_{qk}}$) is derived as follows:

$$ $\displaystyle\frac{\partial\mathbf{P}_{ij}}{\partial\mathbf{A}_{ij}}=\mathbf{P }_{ij}(1-\mathbf{P}_{ij}),\quad\frac{\partial\mathbf{P}_{ik,k\neq j}}{\partial \mathbf{A}_{ij}}=-\mathbf{P}_{ik}\mathbf{P}_{ij},$ (6) $$

The maximum magnitude of each gradient is 0.25 when $\mathbf{P}_{ij}=0.5$ for the first, and $\mathbf{P}_{ij}=0.5$ and $\mathbf{P}_{ik}=0.5$ for the last.

Previous research has demonstrated that there exists a significant saturation range of $\mathbf{A}_{ij}$ values, leading to the gradients in Eq.6 approaching close to 0 (Richter & Wattenhofer, ).

Previous studies have sought to address the gradient vanishing problem by proposing various forms of unnormalized attention scores, including non-exponentiated raw scores (Richter & Wattenhofer, ) and scores transformed by periodic functions (Wang et al., ). Additionally, some approaches have eliminated the normalization step entirely to ensure that the gradient remains equal to 1 (Richter & Wattenhofer, ). While these approaches are theoretically effective in mitigating the gradient vanishing issue, they have not demonstrated practical advantages in benchmark experiments.

###### Lemma 2 (Gradient Vanishing in Attention Mechanism) .

### 2.3 Alternative Attention Mechanisms

Among the previous studies that have proposed alternative attention mechanisms comparable to our GPAM (Wang et al., ; Richter & Wattenhofer, ; He et al., ; Noci et al., ), some methods unintentionally permit negative attention scores, similar to our approach. Additionally, there is prior research that intentionally incorporates negative attention scores within its framework (Tay et al., ). However, most of these studies do not adhere to the generalized probability conditions, specifically: (1) a finite range and (2) a total sum equal to 1 (or another fixed value). We will discuss the significance of adhering to these conditions and demonstrate the practical advantages through experiment results.

## 3 Relationship of Rank-Collapse and Gradient Vanishing

In this section, we analyze an inherent relationship between the rank-collapse and gradient vanishing problems within the conventional attention mechanism. We conjecture that the maximum total norm of gradients, defined as $G(\mathbf{P}_{i})=\sum_{j=1}^{T}\|\frac{\partial\mathbf{P}_{ik}}{\partial
\mathbf{A}_{ij}}\|_{1}$, is attained when complete rank-collapse occurs. We substantiate this conjecture through the following lemma.

###### Lemma 3 (Maximum Total Norm of Gradients) .

The total norm of gradients, $G(\mathbf{P}_{i})$, is maximized when $\mathbf{P}_{i}$ is the uniform distribution, that is $\mathbf{P}_{i}=[\frac{1}{T},\frac{1}{T},\cdots,\frac{1}{T}]$ which is the case of complete rank-collapse.

See Appendix A.1.2 for the proof.
To mitigate the gradient vanishing problem, it is better to input similar token representations to make a smooth normalized attention score distribution. However, that remedy can make the rank-collapse problem severe. Therefore, mitigating both problems together is challenging.

###### Lemma 3 (Maximum Total Norm of Gradients) .

## 4 Dual-Attention Structure of Generalized Probabilistic Attention Mechanism

In this section, we explain our proposed dual-attention implementation of GPAM within the Transformer architecture, as illustrated in Fig.2. We further elucidate the dynamics of daGPAM with respect to the output space and representations. Additionally, we present theoretical foundations supporting the assertion that our daGPAM effectively addresses both the rank-collapse and gradient vanishing problems simultaneously.

### 4.1 Dual-Attention GPAM (daGPAM) Structure

Based on the original scaled dot-product attention mechanism (Vaswani, ), we add another process of computing negative attention matrix while the original attention matrix is treated as the positive attention matrix. During the computation of the negative attention matrix, we use different query vectors, but transformed from the original query vectors. Subsequently, both the positive and negative attention matrices are integrated to derive the final attention matrix, and it is multiplied to the value representations to output the final representations. This process is formulated as follows (we use ‘$+$’ notation to the parts of the original attention part):

$$ $\displaystyle\mathbf{Y}$ $\displaystyle=\mathbf{P}^{G}\mathbf{X}_{V},$ (7) $\displaystyle\mathbf{P}^{G}$ $\displaystyle=(1+\lambda^{+})\mathbf{P}^{+}-\lambda^{-}\mathbf{P}^{-},$ (8) $\displaystyle\mathbf{P}_{ij}^{+}$ $\displaystyle=\frac{exp(\mathbf{A}_{ij}^{+})}{\sum_{k=1}^{T}exp(\mathbf{A}_{ik }^{+})},\quad\mathbf{A}^{+}=\left(\sqrt{d_{qk}}\right)^{-1}\mathbf{X}_{Q}^{+} \left(\mathbf{X}_{K}^{+}\right)^{\top},$ (9) $\displaystyle\mathbf{P}_{ij}^{-}$ $\displaystyle=\frac{exp(\mathbf{A}_{ij}^{-})}{\sum_{k=1}^{T}exp(\mathbf{A}_{ik }^{-})},\quad\mathbf{A}^{-}=\left(\sqrt{d_{qk}}\right)^{-1}\left(\sigma( \mathbf{X}_{Q}^{+})\mathbf{W}_{Q}^{-}\right)\left(\mathbf{X}_{K}^{+}\right)^{ \top},$ (10) $$

where $\mathbf{X}_{Q}^{+}=\mathbf{X}\mathbf{W}_{Q}^{+}$, $\mathbf{X}_{K}^{+}=\mathbf{X}\mathbf{W}_{K}^{+}$, and $\mathbf{X}_{V}=\mathbf{X}\mathbf{W}_{V}$. For the new, negative parts, we only add the non-linear activation, $\sigma$ (we used ReLU throughout this work), and linear transformation with weight matrix $\mathbf{W}_{Q}^{-}\in\mathbb{R}^{d_{qk}\times d_{qk}}$ that has small number of parameters (note that $d>d_{qk}$). $\lambda^{+}$ and $\lambda^{-}$ are pre-defined or trainable scalars that control the effect of positive and negative normalized attention scores, respectively.

daGPAM exhibits several notable properties concerning its final normalized attention scores, denoted as $\mathbf{P}^{G}$. Specifically, the total sum of these scores is $\Sigma=(1+\lambda^{+}-\lambda^{-})$(^2^22For simplicity, we utilize the $\Sigma$ symbol to represent $\sum_{j=1}^{T}\mathbf{P}_{ij}^{G}$.) and the range of the scores is constrained such that $-\lambda^{-}\leq\mathbf{P}_{ij}^{G}\leq(1+\lambda^{+})$. In the special case where
$\lambda^{+}=\lambda^{-}=0$, daGPAM becomes the conventional attention mechanism, Eqs.1$\sim$3. In general, when $\lambda^{+}=\lambda^{-}$, therefore $\Sigma=1$, daGPAM facilitates a valid affine combination. In the next section, we will further elucidate the case where $\lambda^{+}\neq\lambda^{-}$, that facilitates scaled-affine combination whose affine hull is simply translated.

### 4.2 Dynamics of Dual-Attention GPAM

Figure: Figure 3: Different output space and representations according to $\lambda$ combinations. $\lambda^{-}$ varies while $\lambda^{+}$ is fixed to 1.
Refer to caption: extracted/5923029/Figures/figure3_lambda_illustrations.png

In this section, we explain the dynamic how the output space and representations of daGPAM are influenced by the combination of $\lambda^{+}$ and $\lambda^{-}$. We begin by explaining the dynamic of the output space. Based on the formulations in the previous section, the final output representations can be derived and expressed as follows: $\mathbf{Y}=\Sigma(\hat{\mathbf{P}}^{G}\mathbf{X}_{V})=\Sigma\hat{\mathbf{Y}}$ where $\hat{\mathbf{P}}^{G}_{ij}=\mathbf{P}^{G}_{ij}/\Sigma$. It is important to note that $\hat{\mathbf{Y}}$ represents a valid affine combination of $\mathbf{X}_{V}$ since the total sum of $\hat{\mathbf{P}}^{G}$ is equal to 1. Consequently, the possible outcomes for $\mathbf{Y}$ can be interpreted as $\Sigma$-scaled versions of the outcomes from $\hat{\mathbf{Y}}$ which reside within the affine hull defined by $\mathbf{X}_{V}$.
This concept is visually represented in Fig.3, where each colored plane illustrates the translated affine hull corresponding to different combinations of $\lambda$s. It is noteworthy that the degree of translation is contingent upon $\Sigma$ rather than the specific values of $\lambda$s, so in this example, only $\lambda^{-}$ was adjusted. Constraining the output to lie within affine hull (or translated) is critical for effective information processing. The translated affine hull represents a lower-dimensional hyperplane, which is a condensed subset of the $d$-dimensional space determined by the processed representations from lower layers. This constraint enhances the influence of lower layers on the information processing of upper layers, thereby improving overall model efficacy.

Secondly, we examine the dynamic of output representations in relation to $\lambda$s. Utilizing the definitions established in Eqs.7 and 8, we can express $\mathbf{Y}$ in an alternative form as follows: $\mathbf{Y}=(1+\lambda^{+})(\mathbf{P}^{+}\mathbf{X}_{V})-\lambda^{-}(\mathbf{P
}^{-}\mathbf{X}_{V})=(1+\lambda^{+})\mathbf{Y}^{+}-\lambda^{-}\mathbf{Y}^{-}$. Here, $\mathbf{Y}^{+}$ represents the output of conventional attention mechanism, and both $\mathbf{Y}^{+}$ and $\mathbf{Y}^{-}$ are derived from convex combination of $\mathbf{X}_{V}$, as depicted in the third (orange) hyperplane of Fig.3. We can further reformulate this as follows: $\mathbf{Y}=\Sigma\mathbf{Y}^{+}+\lambda^{-}(\mathbf{Y}^{+}-\mathbf{Y}^{-})=
\Sigma\mathbf{Y}^{+}+\lambda^{-}\Delta$. A crucial characteristic of $\Delta$ is that it represents a direct movement on the hyperplane from the original point $\mathbf{Y}^{+}$, and it is manipulated by $\lambda^{-}$, while the original point $\mathbf{Y}^{+}$ is manipulated by $\Sigma$. Consequently, when $\lambda^{-}$ is large to make $\Sigma$ less than 1, daGPAM scales-down the original point while amplifying the movement on the hyperplane, resulting in an increase in the relative diversity of output representations compared to their average norm. This dynamic is illustrated in Fig.3 with empirically computed cosine similarity, $\theta$, based on our toy experiment setting(^3^33We implemented daGPAM, Eqs.7$\sim$10, with $\mathbf{X}$ and the weight matrices which are randomly initialized by standard Gaussian distribution. Then, we computed the average cosine similarity of each output representations $\mathbf{Y}$ with each $\lambda$ combination over 100 times repeatedly.). It shows that the cosine similarity decreases with only changing $\lambda^{-}$ to make a small $\Sigma$.

### 4.3 Theoretic Advantages of Dual-Attention GPAM

In this section, we discuss the theoretical advantages of daGPAM in addressing the issues of rank-collapse and gradient vanishing. First, to enhance our theoretical understanding of the rank-collapse problem, we derive the input/output relationship of the residual, Eq.4, based on daGPAM structure. The results of this derivation is presented in the following lemma.

###### Lemma 4 (Dual-Attention GPAM residual Bound, Simplified) .

For any single daGPAM self-attention layer with for a term $\gamma$ that depends on the attention entries, the composite norm of output residual is bounded by

$$ $\displaystyle\|res(\mathbf{Y})\|_{1,\infty}$ $\displaystyle\leq B^{org}+\frac{4\sqrt{2}\gamma\left(\left|\lambda^{+}\| \mathbf{W}^{+}_{QK}\|_{1}-\lambda^{-}\|\mathbf{W}^{-}_{QK}\|_{1}\right|\right) \|\mathbf{W}_{V}\|_{1,\infty}}{\sqrt{d_{qk}}}\|res(\mathbf{X})\|^{3}_{1,\infty},$ (11) $$

where $\mathbf{W}^{+}_{QK}=\mathbf{W}^{+}_{Q}(\mathbf{W}^{+}_{K})^{\top}$ and $\mathbf{W}^{-}_{QK}=(\mathbf{W}^{+}_{Q}\mathbf{W}^{-}_{Q})(\mathbf{W}^{+}_{K})
^{\top}$. $B^{org}$ is the upper bound derived by Lemma 1. Because the second term is positive, this upper bound is always greater than the original.

The complete lemma and its proof are provided in Appendix A.1.3. Based on this lemma, we argue that daGPAM can have greater or equal residual bound compared to the conventional attention mechanism, which suggests a higher likelihood that the average distance between output representations is
either maintained or not reduced
compared to the average distance of input representations.

Secondly, we derive the gradients of daGPAM. Due to the complexity of this derivation, throughout this derivation, we consider the simple case that approximates the negative unnormalized attention score is simply the positive score with -1 multiplication, that is $\mathbf{A}^{+}=-\mathbf{A}^{-}$ with approximating $\sigma$ to identity activation and $\mathbf{W}_{Q}^{-}\approx-\mathbf{I}$ where $\mathbf{I}$ is identity matrix with size $d_{qk}$. . The result of this derivation is as follows (we simply denote $\mathbf{A}^{+}$ as $\mathbf{A}$ for comparison between the original lemma 2):

###### Lemma 5 (Dual-Attention GPAM Gradients) .

The gradient that the input unnormalized attention score, $\mathbf{A}$, receives through the normalized attention score, $\mathbf{P}^{G}$ (without $1/\sqrt{d_{qk}}$) is derived as follows:

$$ $\displaystyle\frac{\partial\mathbf{P}_{ij}^{G}}{\partial\mathbf{A}_{ij}}$ $\displaystyle=g^{org}_{j}+\lambda^{+}\mathbf{P}_{ij}^{+}(1-\mathbf{P}_{ij}^{+} )+\lambda^{-}\mathbf{P}_{ij}^{-}(1-\mathbf{P}_{ij}^{-}),$ (12) $\displaystyle\frac{\partial\mathbf{P}_{ik,k\neq j}^{G}}{\partial\mathbf{A}_{ij}}$ $\displaystyle=g^{org}_{k}+\lambda^{+}(-\mathbf{P}_{ik}^{+}\mathbf{P}_{ij}^{+}) +\lambda^{-}(-\mathbf{P}_{ik}^{-}\mathbf{P}_{ij}^{-}),$ (13) $$

where $g^{org}_{j}$ and $g^{org}_{k}$ are the derived gradient of the conventional attention mechanism, Eq.6, respectively.

The proof of this lemma is provided in Appendix A.1.4. Because the last two additional terms have the same sign of the original, daGPAM always flow greater gradients than the conventional attention mechanism. Therefore, daGPAM can mitigate the rank-collapse and gradient vanishing problems together.

###### Lemma 4 (Dual-Attention GPAM residual Bound, Simplified) .

###### Lemma 5 (Dual-Attention GPAM Gradients) .

## 5 Empirical Validations

To evaluate the effectiveness of daGPAM in addressing the rank-collapse problem relative to the conventional attention mechanism, we conducted rank-collapse analyses at initialization (faithfulness test) (Poole et al., ; Schoenholz et al., ; Yang & Schoenholz, ; Hayou et al., ; Noci et al., ) and after the training phase. To assess the impact on the gradient vanishing problem, we monitored the gradient norm history of the query weights, specifically $\|\frac{\partial L}{\partial\mathbf{W}_{Q}}\|_{2}$, throughout the training process. Finally, to argue the importance of preserving generalized probability conditions, as discussed in Section 2.3, we compare daGPAM with other several alternative attention mechanisms in preliminary experiments.

All empirical analyses were conducted within the framework of our preliminary experimental settings, specifically utilizing the Penn Treebank dataset (PTB, 1M total number of tokens (Marcus et al., )), for a world-level LM task using a 15-layered decoder-only Transformer model. We employed open-source resource(^4^44https://github.com/kimiyoung/transformer-xl/) for data-related processes, including preprocessing and tokenization. Detailed configurations regarding the model architecture and optimization processes are presented in Table 4 in Appendix A.2. We replaced only the conventional attention layers, self-attention layer, with daGPAM. We explored various configurations, including different combinations of constant $\lambda$s and trainable $\lambda$ methods.

### 5.1 Rank-Collapse Analyses

For the two rank-collapse analyses, we measured the amount of diversity based on the output representations of self-attention layer (output of multi-head attention layer) for all layers (15, in this experiment). We used two different metrics to measure the diversity.

- •
Average relative norm of ‘residual’ (Dong et al., ) : $res(\mathbf{Y})=\frac{1}{T}\sum_{i=1}^{T}\frac{\|\mathbf{Y}_{i}-\bar{\mathbf{y
}}\|_{2}}{\|\mathbf{Y}_{i}\|_{2}}$.
- •
Average cosine similarity (Noci et al., ): $cos(\mathbf{Y})=\frac{1}{T^{2}}\sum_{i=1}^{T}\sum_{j=1}^{T}\frac{\mathbf{Y}_{i
}\cdot\mathbf{Y}_{j}}{\|\mathbf{Y}_{i}\|_{2}\|\mathbf{Y}_{i}\|_{2}}$.

Higher or lower values of $res(\mathbf{Y})$ or $cos(\mathbf{Y})$, respectively, mean less collapsed representations $\mathbf{Y}$.

Figure: Figure 4: The results of rank-collapse analyses (left two graphs) and gradient histories during training (right two graphs). Horizontal axis of rank-collapse analyses indicate layer index, while those of gradient histories indicate training iterations.
Refer to caption: extracted/5923029/Figures/figure4_empirical_validations.png

The left two columns of Fig.4 present the results of the two rank-collapse analyses. In the analysis at initialization, as known, the rank-collapse phenomenon becomes more pronounced in the upper layers. However, except for the case with $(\lambda^{+}=1.0,\lambda^{-}=0.5)$, daGPAM models exhibited a less intensive tendency toward rank-collapse. Notably, this mitigation becomes more effective when $\Sigma$ is smaller, such as in the case of $(\lambda^{+}=1.0,\lambda^{-}=2.0)$, where $\Sigma=0$ showed the greatest reduction in rank-collapse. In the analysis after training phase, all daGPAM models demonstrated a less intensive tendency for rank-reduction compared to the baseline. These empirical findings are consistent with Lemma 4 and the discussions in Section 4.2. Additionally, we provide further analyses addressing other aspects beyond the scope of the above experiments, including the effect of varying $\lambda^{+}$, a rank-collapse analysis based on the output of the multi-layer perceptron (MLP) layer (i.e., the final output of the Transformer layer), and an examination of the actual influence of the attention layer compared to the shortcut branch. These additional results can be found in Appendix A.3.

### 5.2 Gradient History during Training

In addition to addressing the rank-collapse issue, we tracked the gradient norm history of the query weight matrix to verify our claim regarding the gradient vanishing problem (Lemma 5). The right two columns of Fig.4 illustrate the gradient norms of query weights across layers 5, 8, 11, and 14. In each case, the query weights in daGPAM model exhibited larger gradients compared to the baseline, supporting the predictions in Lemma 5. Furthermore, the observation that higher layers receive stronger gradients might align with Lemma 3. As described in the lemma, significant rank-collapse leads to the maximum gradient flow through the softmax operation. Combining with the analysis result of higher layers’ more collapsed output representations (Section 5.1), we guess the lemma could explain why upper layers receive greater gradients than lower layers.

### 5.3 Comparison between Other Alternative Attention Mechanisms

**Table 1: PTB experiment results of various attention mechanisms. Symbol ‘*’ means that the initial numbers are trainable. ‘X’ means the model does not follow that condition, that is unbounded infinite range or non-fixed total sum of normalized attention scores.**
| Model | # Param. | Finite Range of $\mathbf{P}$ | Fixed Sum $\Sigma$ | PTB (PPL) |
| --- | --- | --- | --- | --- |
| Baseline Transformer | 29.2M | [0, 1] | 1 | 108.26 |
| NON (Richter & Wattenhofer, ) | 29.2M | X | X | 168.97 |
| NAP (Richter & Wattenhofer, ) | 29.2M | X | 0* | 258.85 |
| CoDA (Tay et al., ) | 29.2M | [-1, 1] | X | 133.11 |
| Sin-Softmax (Wang et al., ) | 29.2M | [0, 1] | 1 | 123.04 |
| ValueSkipInit (He et al., ) | 29.2M | [0, 2]* | 2* | 108.40 |
| Shaped (Noci et al., ) | 29.2M | [-$\frac{1}{T}$, 2-$\frac{1}{T}$] | 1 | 109.06 |
| daGPAM ($\lambda^{+}=1.0$, $\lambda^{-}=1.0$) | 29.6M | [-1, 2] | 1 | 109.01 |
| daGPAM (Trainable $\lambda$s) | 29.6M | [-1, 2]* | 1* | 106.38 |

In this section, we compare the performance of daGPAM with other alternative attention mechanisms discussed in Section 2.3. We specifically focus on analyzing each mechanism’s adherence to the generalized probability conditions and its corresponding performance, in order to highlight the significance of adhering these conditions. For a fair comparison, we re-implemented all alternative attention mechanisms and applied them to the Transformer baseline, replacing the conventional attention mechanism in the same manner as with daGPAM.

Table 1 presents the results of various attention mechanisms trained on the PTB LM task, evaluated using perplexity (PPL). Our daGPAM models resulted in approximately 1% increases in parameters. Each model is labeled to indicate whether it adheres to the generalized probability conditions, specifically finite range and a fixed total sum of normalized attention scores. The models which do not adhere to the conditions exhibit significant performance degradation. Conversely, with the exception of ‘Sin-Softmax,’ most models that adhered to both conditions performed similarly to the baseline Transformer. Although the ‘ValueSkipInit’ and ‘Shaped’ models did not degrade performance, they also failed to provide improvements, because these methods regularize the attention matrix to be similar to the identity matrix, thereby weakening the contextualization effect. In contrast, daGPAM enhances the attention mechanism itself, leading to improved performance in the ‘daGPAM (Trainable $\lambda$s)’ model.

## 6 Practical Benefits in Benchmark Experiments

In this section, we compare the performance of our models on several benchmark tasks. We conducted LM experiments on the Wikitext103 (word-level LM) and Enwiki8 (character-level LM) datasets. We followed the same data-related processes based on the same open-source of the PTB dataset used in our preliminary experiment. For the baseline model, we re-implemented TransformerXL (Dai, ), heavily following the public code(^5^55https://github.com/kimiyoung/transformer-xl/). This model is larger than the standard Transformer and is optimized for long-context sentences. We followed the original congifurations of model and optimization, except for modifications in the number of layers and the hyperparameters related to daGPAM approach. For further details on the basic configurations, refer to (Dai, ).

Second, we performed NMT experiments on the IWSLT14 English-German dataset (160K training pairs) and the WMT14 English-German dataset (3.9M training pairs) (Heo et al., ). The data preprocessing steps, including tokenization and subword byte-pair encoding, were carried out using the Fairseq toolkit (Ott et al., ). For the baseline models, we re-implemented PreLN (Xiong et al., ) and Admin (Liu et al., ) encoder-decoder Transformer architectures, which are widely used NMT baselines nowadays. The basic model configurations and optimization settings are provided in Table 4 of Appendix A.2. Throughout our experiments with daGPAM models (including models in LM task) using constant $\lambda$ values, we empirically determined the optimal combination of $\lambda$s, which are reported in Tables 5 and 6 in Appendix A.2.

### 6.1 Language Modeling

**Table 2: Experiments on wikitext103 and Enwiki8 LM tasks. ‘daGPAM (Const)’ and ‘daGPAM (Train)’ mean daGPAM models with pre-defined constant $\lambda$s and trainable $\lambda$s, respectively.**
| Model | Wikitext103 | Enwiki8 |  |  |  |
| --- | --- | --- | --- | --- | --- |
| 8L | 16L | 24L | 6L | 12L |  |
| TransformerXL | 25.96 | 23.58 | 22.90 | 1.1570 | 1.0544 |
| daGPAM (Const) | 25.39 | 23.09 | 22.52 | 1.1534 | 1.0473 |
| daGPAM (Train) | 25.33 | 23.20 | 22.57 | 1.1532 | 1.0528 |

For the evaluation of LM experiments, we utilized PPL for the Wikitext103 (word-level) task and bits per character (BPC) for the Enwiki8 (character-level) task. The experiments were conducted by varying the number of layers in the TransformerXL model. For the TransformerXL baseline models, the number of parameters are (130.6M / 151.1M / 171.6M) and (10.3M / 41.1M) for Wikitext103 (8L / 16L / 24L) and Enwiki8 (6L / 12L), respectively. In comparison, the number of parameters for daGPAM models are (130.7M / 151.3M / 172.0M) and (10.4M / 41.4M) for the tasks, respectively. On average, our approach increased only 0.43% of total parameters.

Table 2 demonstrates the results of LM experiments. It shows that daGPAM models consistently improve performance across different layered model architectures. Specifically, our best-performing models improve approximately 0.5 PPL on the Wikitext103 task and 0.0055 BPC on the Enwiki8 task in average. Additionally, we conducted an analysis of the impact of different $\lambda$ combinations within daGPAM model, with results detailed in Appendix A.3.4. Notably, we found that configurations where $\Sigma$ is close to 0.5 yielded the optimal performance in the Wikitext103 LM task. Also, the average $\Sigma$ calculated from the trained $\lambda$ values in the ‘daGPAM (Train)’ (8L) is 0.3948, with $\lambda^{+}=0.3303$ and $\lambda^{-}=0.9355$.

### 6.2 Neural Machine Translation

**Table 3: Experiments on IWSLT14 and WMT14 NMT tasks. ‘daGPAM (Const)’ and ‘daGPAM (Train)’ were individually applied to the two architectures, respectively: PreLN (at the first row) and Admin (at the second row)**
| Model | IWSLT14 | WMT14 |  |  |
| --- | --- | --- | --- | --- |
| En-to-De | De-to-En | En-to-De | De-to-En |  |
| PreLN | 28.54 | 33.90 | 26.40 | 31.26 |
| daGPAM (Const) | 29.25 | 34.43 | 26.73 | 31.43 |
| daGPAM (Train) | 29.11 | 34.11 | 27.19 | 31.45 |
| Admin | 28.32 | 33.48 | 26.27 | 30.61 |
| daGPAM (Const) | 28.60 | 33.62 | 26.76 | 31.20 |
| daGPAM (Train) | 28.43 | 33.23 | 26.79 | 31.10 |

For the evaluation of NMT experiments, we utilized case-sensitive SacreBLEU (Post, ). For the baseline models, the number of parameters are 64.67M and 153.84M for the IWSLT14 and WMT14 tasks, respectively. In comparison, the number of parameters for daGPAM models are 65.26M and 155.02M parameters, which is around 0.84% addition in average. Table 3 presents the results of the NMT experiments. Similar to the results of the LM experiments, daGPAM models consistently outperformed the baseline models. Specifically, our best-performing models demonstrated, in average, 0.42 BLEU point improvement for the IWSLT14 task and 0.52 BLEU points for the WMT14 task.

## 7 Conclusion

In this paper, we proposed a novel class of attention mechanism, generalized probabilistic attention mechanism (GPAM), which allows the negative attention score during the information processing. Also, we proposed one specific type of GPAM, dual-attention GPAM (daGPAM). While showing that the rank-collapse and gradient vanishing problems in the conventional attention mechanism is in trade-off relationship, we showed that daGPAM could mitigate both problems. Our empirical validations provide strong evidences supporting our theories and understanding of this approach. Additionally, our benchmark experiments demonstrate meaningful performance improvements with only a minimal increase in the number of parameters.

## 8 Future Works

Although we proposed only one structure of GPAM (daGPAM), GPAM does not have to be limited to the structure. Actually, the operation of daGPAM increases computational cost due to the added scaled dot-product attention process of negative part. In future, we aim to develop a more efficient structure than daGPAM while preserving the feature of GPAM. Also, beyond the standard Transformer architecture discussed here, GPAM can be applied to other architectures, such as graph neural networks and vision Transformer, as they are also known to experience the rank-collapse problem.

#### Acknowledgments

## Appendix A Appendix

### A.1 Proofs of Lemmas

#### A.1.1 Full Description of Lemma 1

In this section, we describe the complete version of the simplified lemma 1. For the proof of this lemma, see (Dong et al., ).

###### Lemma 6 ( Dong et al. ( 2021 ) ) .

For any single scaled dot-product self-attention layer that holds $|\mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}}|\leq 1.256$ for any $(i,j,j^{{}^{\prime}})$ where $\mathbf{E}=res(\mathbf{X})\frac{\mathbf{W}_{QK}}{\sqrt{d_{qk}}}res(\mathbf{X})
^{\top}$, and with $\gamma$ that satisfies $\sqrt{\sum_{i=1}^{T}\max\limits_{j,j^{{}^{\prime}}}|\mathbf{E}_{ij}-\mathbf{E}
_{ij^{{}^{\prime}}}|}\leq\gamma\sqrt{\max\limits_{j,j^{{}^{\prime}}}\sum_{i=1}
^{T}|\mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}}|}$, the composite norm of residual of its output is bounded by

$$ $\displaystyle\|res(\mathbf{Y})\|_{1,\infty}\leq\frac{4\sqrt{2}\gamma\|\mathbf{ W}_{QK}\|_{1}\|\mathbf{W}_{V}\|_{1,\infty}}{\sqrt{d_{qk}}}\|res(\mathbf{X})\|^ {3}_{1,\infty},$ (14) $$

where $\mathbf{W}_{QK}=\mathbf{W}_{Q}\mathbf{W}_{K}^{\top}$. In the region that holds $4\sqrt{2}\gamma\|\mathbf{W}_{QK}\|_{1}\|\mathbf{W}_{V}\|_{1,\infty}<\sqrt{d_{
qk}}$, the output residual norm is diminished compared to the cubic rate of input residual norm.

###### Lemma 6 ( Dong et al. ( 2021 ) ) .

#### A.1.2 Proof of Lemma 3

In this section, we prove our proposed Lemma 3 which was introduced as follows:

###### Lemma 7 (Maximum Total Norm of Gradients) .

The total norm of gradients, $G(\mathbf{P}_{i})$, is maximized when $\mathbf{P}_{i}$ is uniform distribution, that is $\mathbf{P}_{i}=[\frac{1}{T},\frac{1}{T},\cdots,\frac{1}{T}]$ which is the case of complete rank-collapse.

###### Proof.

Based on Eq.6, $G(\mathbf{P}_{i})$ is derived as follows:

$$ $\displaystyle G(\mathbf{P}_{i})=\sum_{j=1}^{T}\sum_{k=1}^{T}\left|\frac{ \partial\mathbf{P}_{ik}}{\partial\mathbf{A}_{ij}}\right|$ $\displaystyle=\sum_{j=1}^{T}\left(\sum_{k=1,k\neq j}^{T}|-\mathbf{P}_{ik} \mathbf{P}_{ij}|+\mathbf{P}_{ij}(1-\mathbf{P}_{ij})\right),$ $\displaystyle=\sum_{j=1}^{T}\left(\sum_{k=1}^{T}\mathbf{P}_{ik}\mathbf{P}_{ij} +\mathbf{P}_{ij}(1-2\mathbf{P}_{ij})\right),$ $\displaystyle=\sum_{j=1}^{T}\mathbf{P}_{ij}\sum_{k=1}^{T}\mathbf{P}_{ik}+\sum_ {j=1}^{T}\mathbf{P}_{ij}-2\sum_{j=1}^{T}(\mathbf{P}_{ij})^{2},$ $\displaystyle=2-2\sum_{j=1}^{T}(\mathbf{P}_{ij})^{2}.$ (15) $$

Then, our goal is to find the input probability distribution, $\mathbf{P}_{i}$, that maximizes Eq.15, with constraint $\sum_{k=1}^{T}\mathbf{P}_{ik}=1$. We use Lagrange’s multiplier method to optimize this constrained maximization problem. With Lagrange coefficient, $\zeta$, we derive the new objective to maximize: $L(\mathbf{P}_{i},\zeta)=2-2\sum_{j=1}^{T}(\mathbf{P}_{ij})^{2}-\zeta(\sum_{k=1
}^{T}\mathbf{P}_{ik}-1)$. The Jacobian of $L(\mathbf{P}_{i},\zeta)$ with respect to $(\mathbf{P}_{i},\zeta)$ is formulated as follows:

$$ $\displaystyle\mathbb{J}_{L}=\begin{bmatrix}\frac{\partial L}{\partial\mathbf{P }_{i1}}&\cdots&\frac{\partial L}{\partial\mathbf{P}_{iT}}&\frac{\partial L}{ \partial\zeta}\end{bmatrix}=\begin{bmatrix}(-4\mathbf{P}_{i1}-\zeta)&\cdots&(- 4\mathbf{P}_{iT}-\zeta)&(-\sum_{k=1}^{T}\mathbf{P}_{ik}+1)\end{bmatrix}.$ $$

With setting the Jacobian to zero, the solutions are $\mathbf{P}_{ij}=-\frac{\zeta}{4}$ and $\zeta=-\frac{4}{T}$. Thus, an optimal value of $G(\mathbf{P}_{i})$ is achieved when $\mathbf{P}_{i}^{*}=[\frac{1}{T},\frac{1}{T},\cdots,\frac{1}{T}]$.

To verify this point is the maximum, we compare $G(\mathbf{P}_{i}^{*})$ with the total magnitude given slightly noised probabilities, $\mathbf{P}_{i}^{\epsilon_{x,y}}$ whose $x$-th probability is $\frac{1}{T}+\epsilon$, and $y$-th probability is $\frac{1}{T}-\epsilon$, where $x,y<T$ and $0<\epsilon<\frac{1}{T}$. The two values are obtained as follows:

$$ $\displaystyle G(\mathbf{P}_{i}^{*})$ $\displaystyle=2-2\sum_{j=1}^{T}\left(\frac{1}{T}\right)^{2}=2-2\frac{1}{T},$ $\displaystyle G(\mathbf{P}_{i}^{\epsilon_{x,y}})$ $\displaystyle=2-2\left(\sum_{j=1,j\neq x,y}^{T}\left(\frac{1}{T}\right)^{2}+ \left(\frac{1}{T}+\epsilon\right)^{2}+\left(\frac{1}{T}-\epsilon\right)^{2} \right),$ $\displaystyle=2-2\left(\sum_{j=1}^{T}\left(\frac{1}{T}\right)^{2}+2\epsilon^{2 }\right),$ $\displaystyle=2-2\frac{1}{T}-4\epsilon^{2}<G(\mathbf{P}_{i}^{*}).$ $$

We can get the same result with any different combination of $x$ and $y$. Analogously, adding (and subtracting) multiple $\epsilon_{i}$ outputs lower than the optimal value. Therefore, $G(\mathbf{P}_{i}^{*})$ is the maximum.

∎

###### Lemma 7 (Maximum Total Norm of Gradients) .

###### Proof.

#### A.1.3 Full Description and Proof of Lemma 4

###### Lemma 8 (Dual-Attention GPAM residual Bound, Completed) .

Based on the constraints of Lemma 6 that are similarly applied to both positive/negative attention parts and jointly $\sqrt{\sum_{i=1}^{T}\max\limits_{j,j^{{}^{\prime}}}|\mathbf{E}^{+}_{ij}-
\mathbf{E}^{+}_{ij^{{}^{\prime}}}|\max\limits_{j,j^{{}^{\prime}}}|\mathbf{E}^{
-}_{ij}-\mathbf{E}^{-}_{ij^{{}^{\prime}}}|}\leq\sqrt{2}\gamma\sqrt{\max\limits
_{j_{1},j^{{}^{\prime}}_{1},j_{2},j^{{}^{\prime}}_{2}}\sum_{i=1}^{T}|\mathbf{E
}^{+}_{ij_{1}}-\mathbf{E}^{+}_{ij^{{}^{\prime}}_{1}}||\mathbf{E}^{-}_{ij_{2}}-
\mathbf{E}^{-}_{ij^{{}^{\prime}}_{2}}|}$, the output residual’s composite norm of any single daGPAM self-attention layer is bounded by

$$ $\displaystyle\|res(\mathbf{Y})\|_{1,\infty}$ $\displaystyle\leq\frac{4\sqrt{2}\gamma\left(\|\mathbf{W}^{+}_{QK}\|_{1}+\left| \lambda^{+}\|\mathbf{W}^{+}_{QK}\|_{1}-\lambda^{-}\|\mathbf{W}^{-}_{QK}\|_{1} \right|\right)\|\mathbf{W}_{V}\|_{1,\infty}}{\sqrt{d_{qk}}}\|res(\mathbf{X})\| ^{3}_{1,\infty},$ $\displaystyle=B^{org}+\frac{4\sqrt{2}\gamma\left(\left|\lambda^{+}\|\mathbf{W} ^{+}_{QK}\|_{1}-\lambda^{-}\|\mathbf{W}^{-}_{QK}\|_{1}\right|\right)\|\mathbf{ W}_{V}\|_{1,\infty}}{\sqrt{d_{qk}}}\|res(\mathbf{X})\|^{3}_{1,\infty},$ (16) $$

where $\mathbf{W}^{+}_{QK}=\mathbf{W}^{+}_{Q}(\mathbf{W}^{+}_{K})^{\top}$ and $\mathbf{W}^{-}_{QK}=(\mathbf{W}_{Q}^{+}\mathbf{W}^{-}_{Q})(\mathbf{W}^{+}_{K})
^{\top}$ with assumption that the non-linear ReLU activation $\sigma$ is identity. $B^{org}$ is the upper bound derived by Lemma 6. Since the second term is positive, this upper bound is always greater than the original.

###### Proof.

In this proof, we follow the derivations in (Dong et al., ), except the triangle inequality for the Frobenius norm formulation in the middle.

By the technique described in Sec.A.4.2, the positive and negative unnormalized attention matrices, Eqs.9 and 10, are approximated as follows:

$$ $\displaystyle\mathbf{A}^{+}$ $\displaystyle\approx\frac{1}{\sqrt{d_{qk}}}\left(\mathbf{R}\mathbf{W}^{+}_{QK} \mathbf{R}^{\top}+\mathbf{1}\bar{\mathbf{x}}^{\top}\mathbf{W}^{+}_{QK}\mathbf{ R}^{\top}\right),$ $\displaystyle\mathbf{A}^{-}$ $\displaystyle\approx\frac{1}{\sqrt{d_{qk}}}\left(\mathbf{R}\mathbf{W}^{-}_{QK} \mathbf{R}^{\top}+\mathbf{1}\bar{\mathbf{x}}^{\top}\mathbf{W}^{-}_{QK}\mathbf{ R}^{\top}\right),$ $$

where $\mathbf{W}^{+}_{QK}=\mathbf{W}^{+}_{Q}(\mathbf{W}^{+}_{K})^{\top}$ and $\mathbf{W}^{-}_{QK}=(\mathbf{W}_{Q}^{+}\mathbf{W}^{-}_{Q})(\mathbf{W}^{+}_{K})
^{\top}$ with assumption that the non-linear ReLU activation $\sigma$ is identity, and $\mathbf{R}=res(\mathbf{X})=\mathbf{X}-\mathbf{1}\bar{\mathbf{x}}^{\top}$. Then, the positive and negative normalized attention score matrices are formulated as follows:

$$ $\displaystyle\mathbf{P}^{+}$ $\displaystyle=softmax\left(\mathbf{E}^{+}+\mathbf{1}(\mathbf{r}^{+})^{\top} \right),$ $\displaystyle\mathbf{P}^{-}$ $\displaystyle=softmax\left(\mathbf{E}^{-}+\mathbf{1}(\mathbf{r}^{-})^{\top} \right),$ $$

where $\mathbf{E}^{+}=\frac{1}{\sqrt{d_{qk}}}\mathbf{R}\mathbf{W}^{+}_{QK}\mathbf{R}^
{\top}$, $\mathbf{E}^{-}=\frac{1}{\sqrt{d_{qk}}}\mathbf{R}\mathbf{W}^{-}_{QK}\mathbf{R}^
{\top}$, $\mathbf{r}^{+}=\frac{1}{\sqrt{d_{qk}}}\mathbf{R}(\mathbf{W}^{+}_{QK})^{\top}
\bar{\mathbf{x}}$, and $\mathbf{r}^{-}=\frac{1}{\sqrt{d_{qk}}}\mathbf{R}(\mathbf{W}^{-}_{QK})^{\top}
\bar{\mathbf{x}}$.

Following the technique described in Sec.A.4.3, each normalized attention matrix is lower and upper bounded as follows:

$$ $\displaystyle\left(\mathbf{I}-2\mathbf{D}^{+}\right)\mathbf{1}softmax(\mathbf{ r}^{+})^{\top}$ $\displaystyle\leq\mathbf{P}^{+}\leq\left(\mathbf{I}+2\mathbf{D}^{+}\right) \mathbf{1}softmax(\mathbf{r}^{+})^{\top},$ $\displaystyle\left(\mathbf{I}-2\mathbf{D}^{-}\right)\mathbf{1}softmax(\mathbf{ r}^{-})^{\top}$ $\displaystyle\leq\mathbf{P}^{-}\leq\left(\mathbf{I}+2\mathbf{D}^{-}\right) \mathbf{1}softmax(\mathbf{r}^{-})^{\top},$ $$

where $\mathbf{D}$ is a diagonal matrix whose $i$-th diagonal element is $\mathbf{D}_{ii}=\max\limits_{j,j^{{}^{\prime}}}|\mathbf{E}_{ij}-\mathbf{E}_{ij
^{{}^{\prime}}}|$. Based on the design of daGPAM, Eq.8, $\mathbf{P}^{G}=(1+\lambda^{+})\mathbf{P}^{+}-\lambda^{-}\mathbf{P}^{-}$, its lower and upper bound is formulated as follows:

$$ $\displaystyle(1+\lambda^{+})\left(\mathbf{I}-2\mathbf{D}^{+}\right)\mathbf{1} softmax(\mathbf{r}^{+})^{\top}$ $\displaystyle-\lambda^{-}\left(\mathbf{I}-2\mathbf{D}^{-}\right)\mathbf{1} softmax(\mathbf{r}^{-})^{\top}$ $\displaystyle\leq$ $\displaystyle\mathbf{P}^{G}\leq$ $\displaystyle(1+\lambda^{+})\left(\mathbf{I}+2\mathbf{D}^{+}\right)\mathbf{1} softmax(\mathbf{r}^{+})^{\top}$ $\displaystyle-\lambda^{-}\left(\mathbf{I}+2\mathbf{D}^{-}\right)\mathbf{1} softmax(\mathbf{r}^{-})^{\top}.$ $$

Now, the output of the single daGPAM self-attention layer, $\mathbf{Y}=\mathbf{P}^{G}\mathbf{X}_{V}=\mathbf{P}^{G}\mathbf{X}\mathbf{W}_{V}$, is derived as follows:

$$ $\displaystyle\mathbf{Y}$ $\displaystyle=\mathbf{P}^{G}\mathbf{X}\mathbf{W}_{V},$ $\displaystyle=\mathbf{P}^{G}(\mathbf{1}\bar{\mathbf{x}}^{\top}+\mathbf{R}) \mathbf{W}_{V},$ $\displaystyle=\mathbf{P}^{G}\mathbf{1}\bar{\mathbf{x}}^{\top}\mathbf{W}_{V}+ \mathbf{P}^{G}\mathbf{R}\mathbf{W}_{V},$ $\displaystyle=\mathbf{1}\bar{\mathbf{x}}^{\top}\mathbf{W}_{V}+\mathbf{P}^{G} \mathbf{R}\mathbf{W}_{V},$ $\displaystyle\leq\mathbf{1}\bar{\mathbf{x}}^{\top}\mathbf{W}_{V}+[(1+\lambda^{ +})\left(\mathbf{I}+2\mathbf{D}^{+}\right)\mathbf{1}softmax(\mathbf{r}^{+})^{\top}$ $\displaystyle\qquad-\lambda^{-}\left(\mathbf{I}+2\mathbf{D}^{-}\right)\mathbf{ 1}softmax(\mathbf{r}^{-})^{\top}]\mathbf{R}\mathbf{W}_{V},$ $\displaystyle=\left(\mathbf{1}\bar{\mathbf{x}}^{\top}+(1+\lambda^{+})\mathbf{1 }softmax(\mathbf{r}^{+})^{\top}\mathbf{R}-\lambda^{-}\mathbf{1}softmax(\mathbf {r}^{-})^{\top}\mathbf{R}\right)\mathbf{W}_{V}$ $\displaystyle\qquad+2\left((1+\lambda^{+})\mathbf{D}^{+}\mathbf{1}softmax( \mathbf{r}^{+})^{\top}-\lambda^{-}\mathbf{D}^{-}\mathbf{1}softmax(\mathbf{r}^{ -})^{\top}\right)\mathbf{R}\mathbf{W}_{V},$ $\displaystyle\mathbf{Y}-\mathbf{1}(\mathbf{r}^{\prime})^{\top}$ $\displaystyle\leq 2\left((1+\lambda^{+})\mathbf{D}^{+}\mathbf{1}softmax( \mathbf{r}^{+})^{\top}-\lambda^{-}\mathbf{D}^{-}\mathbf{1}softmax(\mathbf{r}^{ -})^{\top}\right)\mathbf{R}\mathbf{W}_{V},$ $$

where $\mathbf{r}^{\prime}=\mathbf{W}_{V}^{\top}\left(\bar{\mathbf{x}}+(1+\lambda^{+}
)\mathbf{R}^{\top}softmax(\mathbf{r}^{+})-\lambda^{-}\mathbf{R}^{\top}softmax(
\mathbf{r}^{-})\right)$.
Analogously, the lower bound of $(\mathbf{Y}-\mathbf{1}(\mathbf{r}^{\prime})^{\top})$ is given by

$$ $\displaystyle\mathbf{Y}-\mathbf{1}(\mathbf{r}^{\prime})^{\top}$ $\displaystyle\geq-2\left((1+\lambda^{+})\mathbf{D}^{+}\mathbf{1}softmax( \mathbf{r}^{+})^{\top}-\lambda^{-}\mathbf{D}^{-}\mathbf{1}softmax(\mathbf{r}^{ -})^{\top}\right)\mathbf{R}\mathbf{W}_{V}.$ $$

Following the definition of (Dong et al., ), we can see $(\mathbf{Y}-\mathbf{1}(\mathbf{r}^{\prime})^{\top})$ is an appropriate approximation of $res(\mathbf{Y})=\mathbf{R}^{{}^{\prime}}$ with assuming $\mathbf{r}^{\prime}\approx\operatorname*{arg\,min}_{\bar{\mathbf{x}}^{\prime}}
\|\mathbf{Y}-\mathbf{1}\bar{\mathbf{x}}^{\prime\top}\|$.

Based on the triangle inequality, the upper bound of the Frobenius norm of $\mathbf{R}^{{}^{\prime}}$, that is $\|\mathbf{R}^{{}^{\prime}}\|_{F}$, is obtained by

$$ $\displaystyle\|\mathbf{R}^{{}^{\prime}}\|_{F}$ $\displaystyle\leq 2\left\lVert\left((1+\lambda^{+})\mathbf{D}^{+}\mathbf{1} softmax(\mathbf{r}^{+})^{\top}-\lambda^{-}\mathbf{D}^{-}\mathbf{1}softmax( \mathbf{r}^{-})^{\top}\right)\right\rVert_{F}\|\mathbf{R}\|_{F}\|\mathbf{W}_{V }\|_{F},$ $\displaystyle=2\sqrt{(1+\lambda^{+})^{2}\|\mathbf{D}^{+}\mathbf{1}softmax( \mathbf{r}^{+})^{\top}\|^{2}_{F}+(\lambda^{-})^{2}\|\mathbf{D}^{-}\mathbf{1} softmax(\mathbf{r}^{-})^{\top}\|^{2}_{F}}$ $\displaystyle\qquad\overline{+2\langle(1+\lambda^{+})\mathbf{D}^{+}\mathbf{1} softmax(\mathbf{r}^{+})^{\top},-\lambda^{-}\mathbf{D}^{-}\mathbf{1}softmax( \mathbf{r}^{-})^{\top}\rangle_{F}}\sqrt{\|\mathbf{R}\|^{2}_{F}}\sqrt{\|\mathbf {W}_{V}\|^{2}_{F}}$ $\displaystyle\leq 2\sqrt{(1+\lambda^{+})^{2}\|\mathbf{D}^{+}\mathbf{1}\|_{1}\| \mathbf{D}^{+}\mathbf{1}\|_{\infty}+(\lambda^{-})^{2}\|\mathbf{D}^{-}\mathbf{1 }\|_{1}\|\mathbf{D}^{-}\mathbf{1}\|_{\infty}}$ $\displaystyle\qquad\overline{-2(1+\lambda^{+})\lambda^{-}\langle\mathbf{D}^{+} \mathbf{1}softmax(\mathbf{r}^{+})^{\top},\mathbf{D}^{-}\mathbf{1}softmax( \mathbf{r}^{-})^{\top}\rangle_{F}}\|\mathbf{R}\|_{1,\infty}\|\mathbf{W}_{V}\|_ {1,\infty},$ (17) $$

where $\|\cdot\|_{1,\infty}=\sqrt{\|\cdot\|_{1}\|\cdot\|_{\infty}}\geq\sqrt{\|\cdot\|
_{F}^{2}}$ by the Schatten norm inequality. The last inequality is obtained by the upper bounds described in Sec. A.4.4. $\langle\cdot,\cdot\rangle_{F}$ is the Frobenius inner product.

Based on the derived upper bound described in Sec.A.4.5, we derive following inequalities:

$$ $\displaystyle\|\mathbf{D}^{+}\mathbf{1}\|_{1}\|\mathbf{D}^{+}\mathbf{1}\|_{\infty}$ $\displaystyle\leq 8\gamma^{2}\|\mathbf{E}^{+}\|_{1}^{2},$ $\displaystyle\|\mathbf{D}^{-}\mathbf{1}\|_{1}\|\mathbf{D}^{-}\mathbf{1}\|_{\infty}$ $\displaystyle\leq 8\gamma^{2}\|\mathbf{E}^{-}\|_{1}^{2},$ $$

where $\gamma$ jointly holds the two initial conditions $\sqrt{\sum_{i=1}^{T}\max\limits_{j,j^{{}^{\prime}}}|\mathbf{E}^{+}_{ij}-
\mathbf{E}^{+}_{ij^{{}^{\prime}}}|}\leq\gamma\sqrt{\max\limits_{j,j^{{}^{
\prime}}}\sum_{i=1}^{T}|\mathbf{E}^{+}_{ij}-\mathbf{E}^{+}_{ij^{{}^{\prime}}}|}$ and
$\sqrt{\sum_{i=1}^{T}\max\limits_{j,j^{{}^{\prime}}}|\mathbf{E}^{-}_{ij}-
\mathbf{E}^{-}_{ij^{{}^{\prime}}}|}\leq\gamma\sqrt{\max\limits_{j,j^{{}^{
\prime}}}\sum_{i=1}^{T}|\mathbf{E}^{-}_{ij}-\mathbf{E}^{-}_{ij^{{}^{\prime}}}|}$.

The Frobenius inner product term in the inequality is further derived as follows:

$$ $\displaystyle\langle\mathbf{D}^{+}\mathbf{1}softmax(\mathbf{r}^{+})^{\top},$ $\displaystyle\mathbf{D}^{-}\mathbf{1}softmax(\mathbf{r}^{-})^{\top}\rangle_{F} =\sum_{i}^{T}\sum_{j}^{T}\mathbf{D}^{+}_{ii}softmax(\mathbf{r}^{+})_{j}\mathbf {D}^{-}_{ii}softmax(\mathbf{r}^{-})_{j},$ $\displaystyle=\left(\sum_{i}^{T}\mathbf{D}^{+}_{ii}\mathbf{D}^{-}_{ii}\right) \left(\sum_{j}^{T}softmax(\mathbf{r}^{+})_{j}softmax(\mathbf{r}^{-})_{j}\right),$ $\displaystyle\leq\left(\sum_{i}^{T}\mathbf{D}^{+}_{ii}\mathbf{D}^{-}_{ii} \right)\left(1\sum_{j}^{T}softmax(\mathbf{r}^{-})_{j}\right),$ $\displaystyle=\sum_{i}^{T}\mathbf{D}^{+}_{ii}\mathbf{D}^{-}_{ii},$ $\displaystyle=\sum_{i}^{T}\max\limits_{j,j^{{}^{\prime}}}|\mathbf{E}^{+}_{ij}- \mathbf{E}^{+}_{ij^{{}^{\prime}}}|\max\limits_{j,j^{{}^{\prime}}}|\mathbf{E}^{ -}_{ij}-\mathbf{E}^{-}_{ij^{{}^{\prime}}}|,$ $\displaystyle\leq 2\gamma^{2}\max\limits_{j_{1},j^{{}^{\prime}}_{1},j_{2},j^{{ }^{\prime}}_{2}}\sum_{i}^{T}|\mathbf{E}^{+}_{ij_{1}}-\mathbf{E}^{+}_{ij^{{}^{ \prime}}_{1}}||\mathbf{E}^{-}_{ij_{2}}-\mathbf{E}^{-}_{ij^{{}^{\prime}}_{2}}|,$ $\displaystyle\leq 8\gamma^{2}\max\limits_{j_{1},j_{2}}\sum_{i}^{T}|\mathbf{E}^ {+}_{ij_{1}}||\mathbf{E}^{-}_{ij_{2}}|,$ $\displaystyle\leq 8\gamma^{2}\left(\max\limits_{j}\sum_{i}^{T}|\mathbf{E}^{+}_ {ij}|\right)\left(\max\limits_{j}\sum_{i}^{T}|\mathbf{E}^{-}_{ij}|\right),$ $\displaystyle=8\gamma^{2}\|\mathbf{E}^{+}\|_{1}\|\mathbf{E}^{-}\|_{1}.$ $$

The inequality from 5-th to 6-th line is based on the initial condition of this lemma. The techniques used for the latter inequalities are similar to the techniques used in Sec. A.4.5.

Incorporating above derivations to Eq.17, $\|\mathbf{R}^{{}^{\prime}}\|_{F}$ is obtained by

$$ $\displaystyle\|\mathbf{R}^{{}^{\prime}}\|_{F}$ $\displaystyle\leq 4\sqrt{2}\gamma\left(\sqrt{(1+\lambda^{+})^{2}\|\mathbf{E}^{ +}\|_{1}^{2}-2(1+\lambda^{+})\lambda^{-}\|\mathbf{E}^{+}\|_{1}\|\mathbf{E}^{-} \|_{1}+(\lambda^{-})^{2}\|\mathbf{E}^{-}\|_{1}^{2}}\right)\|\mathbf{R}\|_{1, \infty}\|\mathbf{W}_{V}\|_{1,\infty},$ $\displaystyle=4\sqrt{2}\gamma\left(\left|((1+\lambda^{+})\|\mathbf{E}^{+}\|_{1 }-\lambda^{-}\|\mathbf{E}^{-}\|_{1})\right|\right)\|\mathbf{R}\|_{1,\infty}\| \mathbf{W}_{V}\|_{1,\infty},$ $$

By substituting $\mathbf{E}^{+}$ and $\mathbf{E}^{-}$ with their original form, respectively, we achieve the result of Lemma as follows:

$$ $\displaystyle\|\mathbf{R}^{{}^{\prime}}\|_{F}$ $\displaystyle\leq 4\sqrt{2}\gamma\left(\left|(1+\lambda^{+})\|\frac{1}{\sqrt{d _{qk}}}\mathbf{R}\mathbf{W}^{+}_{QK}\mathbf{R}^{\top}\|_{1}-\lambda^{-}\|\frac {1}{\sqrt{d_{qk}}}\mathbf{R}\mathbf{W}^{-}_{QK}\mathbf{R}^{\top}\|_{1}\right| \right)\|\mathbf{R}\|_{1,\infty}\|\mathbf{W}_{V}\|_{1,\infty},$ $\displaystyle\leq\frac{4\sqrt{2}\gamma}{\sqrt{d_{qk}}}\left(\left|(1+\lambda^{ +})\|\mathbf{R}\|_{1}\|\mathbf{W}^{+}_{QK}\|_{1}\|\mathbf{R}^{\top}\|_{1}- \lambda^{-}\|\mathbf{R}\|_{1}\|\mathbf{W}^{-}_{QK}\|_{1}\|\mathbf{R}^{\top}\|_ {1}\right|\right)\|\mathbf{R}\|_{1,\infty}\|\mathbf{W}_{V}\|_{1,\infty},$ $\displaystyle=\frac{4\sqrt{2}\gamma}{\sqrt{d_{qk}}}\left(\left|(1+\lambda^{+}) \|\mathbf{R}\|_{1}\|\mathbf{W}^{+}_{QK}\|_{1}\|\mathbf{R}\|_{\infty}-\lambda^{ -}\|\mathbf{R}\|_{1}\|\mathbf{W}^{-}_{QK}\|_{1}\|\mathbf{R}\|_{\infty}\right| \right)\|\mathbf{R}\|_{1,\infty}\|\mathbf{W}_{V}\|_{1,\infty},$ $\displaystyle=\frac{4\sqrt{2}\gamma}{\sqrt{d_{qk}}}\left(\left|(1+\lambda^{+}) \|\mathbf{W}^{+}_{QK}\|_{1}-\lambda^{-}\|\mathbf{W}^{-}_{QK}\|_{1}\right| \right)\|\mathbf{R}\|_{1,\infty}^{3}\|\mathbf{W}_{V}\|_{1,\infty},$ $\displaystyle\leq\frac{4\sqrt{2}\gamma}{\sqrt{d_{qk}}}\left(\|\mathbf{W}^{+}_{ QK}\|_{1}+\left|\lambda^{+}\|\mathbf{W}^{+}_{QK}\|_{1}-\lambda^{-}\|\mathbf{W} ^{-}_{QK}\|_{1}\right|\right)\|\mathbf{R}\|_{1,\infty}^{3}\|\mathbf{W}_{V}\|_{ 1,\infty}.$ $$

∎

###### Lemma 8 (Dual-Attention GPAM residual Bound, Completed) .

###### Proof.

#### A.1.4 Proof of Lemma 5

In this section, we prove our proposed Lemma 5 which was introduced as follows:

###### Lemma 9 (Dual-Attention GPAM Gradients) .

The gradient that the input unnormalized attention score, $\mathbf{A}$, receives through the normalized attention score, $\mathbf{P}^{G}$ (without $1/\sqrt{d_{qk}}$) is derived as follows:

$$ $\displaystyle\frac{\partial\mathbf{P}_{ij}^{G}}{\partial\mathbf{A}_{ij}}$ $\displaystyle=(1+\lambda^{+})\mathbf{P}_{ij}^{+}(1-\mathbf{P}_{ij}^{+})+ \lambda^{-}\mathbf{P}_{ij}^{-}(1-\mathbf{P}_{ij}^{-}),$ $\displaystyle=g^{org}_{j}+\lambda^{+}\mathbf{P}_{ij}^{+}(1-\mathbf{P}_{ij}^{+} )+\lambda^{-}\mathbf{P}_{ij}^{-}(1-\mathbf{P}_{ij}^{-}),$ (19) $\displaystyle\frac{\partial\mathbf{P}_{ik,k\neq j}^{G}}{\partial\mathbf{A}_{ij}}$ $\displaystyle=(1+\lambda^{+})(-\mathbf{P}_{ik}^{+}\mathbf{P}_{ij}^{+})+\lambda ^{-}(-\mathbf{P}_{ik}^{-}\mathbf{P}_{ij}^{-}),$ $\displaystyle=g^{org}_{k}+\lambda^{+}(-\mathbf{P}_{ik}^{+}\mathbf{P}_{ij}^{+}) +\lambda^{-}(-\mathbf{P}_{ik}^{-}\mathbf{P}_{ij}^{-}),$ (20) $$

where $g^{org}_{j}$ and $g^{org}_{k}$ are the derived gradient of the conventional attention mechanism, Eq.6, respectively.

###### Proof.

Basically, the final gradients are simply formulated as follows:

$$ $\displaystyle\frac{\partial\mathbf{P}_{ij}^{G}}{\partial\mathbf{A}_{ij}}$ $\displaystyle=(1+\lambda^{+})\frac{\partial\mathbf{P}_{ij}^{+}}{\partial \mathbf{A}_{ij}}-\lambda^{-}\frac{\partial\mathbf{P}_{ij}^{-}}{\partial\mathbf {A}_{ij}},$ $\displaystyle\frac{\partial\mathbf{P}_{ik,k\neq j}^{G}}{\partial\mathbf{A}_{ij}}$ $\displaystyle=(1+\lambda^{+})\frac{\partial\mathbf{P}_{ik,k\neq j}^{+}}{ \partial\mathbf{A}_{ij}}-\lambda^{-}\frac{\partial\mathbf{P}_{ik,k\neq j}^{-}} {\partial\mathbf{A}_{ij}}.$ $$

We use the results of the derived gradients in Lemma 2 for the partial gradients of positive parts, $\frac{\partial\mathbf{P}_{ij}^{+}}{\partial\mathbf{A}_{ij}}$ and $\frac{\partial\mathbf{P}_{ik,k\neq j}^{+}}{\partial\mathbf{A}_{ij}}$. The partial gradients of negative parts are derived as follows ($\mathbf{W}$ is the same as $\mathbf{W}_{Q}^{-}$ that we simplified as negative identity matrix):

$$ $\displaystyle\frac{\partial\mathbf{P}_{ij}^{-}}{\partial\mathbf{A}_{ij}}$ $\displaystyle=\mathbf{W}_{jj}\frac{e^{\mathbf{W}_{jj}\mathbf{A}^{+}_{ij}}}{ \sum_{t=1}^{n}e^{\mathbf{W}_{tt}\mathbf{A}^{+}_{it}}}-\frac{e^{\mathbf{W}_{jj} \mathbf{A}^{+}_{ij}}}{(\sum_{t=1}^{n}e^{\mathbf{W}_{tt}\mathbf{A}^{+}_{it}})^{ 2}}\left(\sum_{z=1}^{n}\mathbf{W}_{zj}e^{\mathbf{W}_{zz}\mathbf{A}^{+}_{iz}} \right),$ $\displaystyle=\mathbf{W}_{jj}\mathbf{P}_{ij}^{-}-\mathbf{P}^{-}_{ij}\left(\sum _{z=1}^{n}\mathbf{W}_{zj}\mathbf{P}^{-}_{iz}\right),$ $\displaystyle=\mathbf{W}_{jj}\mathbf{P}_{ij}^{-}(1-\mathbf{P}_{ij}^{-}),$ $\displaystyle=-\mathbf{P}_{ij}^{-}(1-\mathbf{P}_{ij}^{-}),$ $\displaystyle\frac{\partial\mathbf{P}_{ik,k\neq j}^{-}}{\partial\mathbf{A}_{ij}}$ $\displaystyle=\mathbf{W}_{kj}\frac{e^{\mathbf{W}_{kj}\mathbf{A}^{+}_{ij}}}{ \sum_{t=1}^{n}e^{\mathbf{W}_{tt}\mathbf{A}^{+}_{it}}}-\frac{e^{\mathbf{W}_{kj} \mathbf{A}^{+}_{ij}}}{(\sum_{t=1}^{n}e^{\mathbf{W}_{tt}\mathbf{A}^{+}_{it}})^{ 2}}\left(\sum_{z=1}^{n}\mathbf{W}_{zj}e^{\mathbf{W}_{zz}\mathbf{A}^{+}_{iz}} \right),$ $\displaystyle=\mathbf{W}_{kj}\mathbf{P}_{ik}^{-}-\mathbf{P}^{-}_{ik}\left(\sum _{z=1}^{n}\mathbf{W}_{zj}\mathbf{P}^{-}_{iz}\right),$ $\displaystyle=\mathbf{W}_{jj}(-\mathbf{P}^{-}_{ik}\mathbf{P}^{-}_{ij}),$ $\displaystyle=-(-\mathbf{P}^{-}_{ik}\mathbf{P}^{-}_{ij}),$ $$

During derivations, we used the simplification that $\mathbf{W}_{ij}=0$ if $i\neq j$ and $\mathbf{W}_{ii}=-1$. Finally, the lemma is proved by substituting $\frac{\partial\mathbf{P}_{ij}^{+}}{\partial\mathbf{A}_{ij}}$, $\frac{\partial\mathbf{P}_{ik,k\neq j}^{+}}{\partial\mathbf{A}_{ij}}$, $\frac{\partial\mathbf{P}_{ij}^{-}}{\partial\mathbf{A}_{ij}}$, and $\frac{\partial\mathbf{P}_{ik,k\neq j}^{-}}{\partial\mathbf{A}_{ij}}$, from the above formulations with the newly derived formulations.

∎

###### Lemma 9 (Dual-Attention GPAM Gradients) .

###### Proof.

### A.2 Experimental Settings

In this section, we describe the experimental settings of our experiments. Except the benchmark LM experiments (Section 6.1), we used the described model and optimization configurations in Table 4 for preliminary experiments (Section 5) and the benchmark NMT experiments (Section 6.2). For the experiments of benchmark LM experiments (Section 6.1), we followed the same experiment settings as the original work (Dai, ), except the different number of layers and other things related to our proposed daGPAM. For the settings of the optimal $\lambda$ combinations that we used for daGPAM (constant $\lambda$ setting) models, we demonstrated them in Tables5 and 6.

During training of all experiments, we saved the best checkpoint based on validations. Especially, for NMT experiments, IWSLT14 and WMT14, we used checkpoint ensemble technique (Ott et al., ) with 10 latest checkpoints at each validation. Except the benchmark LM experiments, we early stopped the training whenever the model does not over the previous best performance ‘Patience’ times. For the experiments of benchmark LM experiments, we ran experiments with the original work’s default training iteration settings.

**Table 4: Model and optimizer configurations used for our experiments. We tried to use the same notations with (Vaswani, ), except the number of layers (# of Layers) and multi-head attention’s heads (# of Heads) for clarity. ‘RAdam’ means rectified Adam (Liu et al., ). ‘ISRS’ indicates inverse square root learning rate schedule (Ott et al., ) and ‘# of Tokens’ indicates the number of tokens in a mini-batch at every iteration.**
| Config. | PTB | IWSLT14 | WMT14 |  |  |
| --- | --- | --- | --- | --- | --- |
| Transformer | PreLN | Admin | PreLN | Admin |  |
| $d_{model}$ | 256 | 512 | 512 | 512 | 512 |
| $d_{ff}$ | 2100 | 1024 | 1024 | 2048 | 2048 |
| $d_{qk}$ | 64 | 64 | 64 | 64 | 64 |
| $P_{drop}$ | 0.3 | 0.3 | 0.3 | 0.1 | 0.1 |
| $\epsilon_{ls}$ | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 |
| # of Layers | 15 | 6 | 6 | 6 | 6 |
| # of Head | 4 | 4 | 4 | 8 | 8 |
| Optimizer | RAdam | RAdam | RAdam | RAdam | RAdam |
| Learning Rate | 0.00025 | 0.0005 | 0.0005 | 0.001 | 0.001 |
| Scheduler | ISRS | None | ISRS | None | ISRS |
| # of Tokens | 4K | 4K | 4K | 25K | 25K |
| Patience | 50 | 50 | 50 | 50 | 50 |

**Table 5: Empirically found optimal $\lambda$ combination for our daGPAM model with constant $\lambda$s in LM experiments.**
| Model | Wikitext103 | Enwiki8 |  |  |  |
| --- | --- | --- | --- | --- | --- |
| 8L | 16L | 24L | 6L | 12L |  |
| $(\lambda^{+},\lambda^{-})$ | (1.0, 1.5) | (1.5, 2.0) | (1.0, 1.0) | (1.0, 1.5) | (1.0, 1.0) |

**Table 6: Empirically found optimal $\lambda$ combination for our daGPAM model with constant $\lambda$s in NMT experiments.**
| Model | IWSLT14 En-to-De | IWSLT14 De-to-En | WMT14 En-to-De | WMT14 De-to-En |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| PreLN | Admin | PreLN | Admin | PreLN | Admin | PreLN | Admin |  |
| $(\lambda^{+},\lambda^{-})$ | (1.5, 1.5) | (2.0, 1.5) | (1.0, 1.5) | (2.0, 1.5) | (1.0, 1.0) | (1.0, 1.0) | (1.5, 1.5) | (1.0, 1.0) |

We utilized single GTX1080Ti GPU for all of the preliminary experiments (Section 5). The PTB LM experiments took 12 hours in average. For all of our benchmark experiments (Section 6), we utilized single RTX3090 GPU. The TransformerXL-based LM experiments took averagely 20 and 240 hours for Wikitext-103 and Enwiki8 tasks, respectively. The NMT experiments took 75 and 120 hours in average for IWSLT14 and WMT14 tasks, respectively.

### A.3 Additional Experiment Results

#### A.3.1 Faithfulness Test with Varying λ + superscript 𝜆 \lambda^{+} italic_λ start_POSTSUPERSCRIPT + end_POSTSUPERSCRIPT

Figure: Figure 5: Results of faithfulness test (rank-collapse analysis at initialization) varying $\lambda^{+}$ with fixing $\lambda^{-}$ to 1.
Refer to caption: extracted/5923029/Figures/figure_faithfulness_test_lambda_pos_varies.png

In addition to the rank-collapse analysis at initialization that is conducted with varying $\lambda^{-}$ while fixing $\lambda^{+}$ to 1 (Fig.4 in Section 5.1), we conducted the same analysis with varying $\lambda^{+}$ while fixing $\lambda^{-}$ to 1. As demonstrated in Fig.5, daGPAM models achieved less intensive rank-reduciton tendency than the baseline. Similar to the phenomenon explained in Section 5.1, daGPAM model that has $\Sigma$ smaller than 1 shows much less intensive tendency. For example, the $(\lambda^{+}=0.5,\lambda^{-}=1.0)$ configuration shows the least intensive tendency, and this tendency is quite similar to the tendency of $(\lambda^{+}=1.0,\lambda^{-}=1.5)$ configuration in Fig.4.

#### A.3.2 Rank-Collapse Analysis of MLP Layer’s Output Representations

Figure: Figure 6: Results of rank-collapse analysis after training with MLP layer’s output representations.
Refer to caption: extracted/5923029/Figures/figure_rank_collapse_after_training_mlp_out.png

In addition to the rank-collapse analysis after training based on attention layer’s output representations (Fig.4 in Section 5.1), we conducted the same analysis based on the MLP layer’s output representations which are the final outputs of each Transformer block. As demonstrated in Fig.6, daGPAM models show mitigated rank-collapse phenomenon compared to the baseline, similar to the resulting phenomenon of attention layers’ outputs.

#### A.3.3 Influence of Attention Layers

Figure: Figure 7: Cosine similarity results between the representations produced by the attention layer and the subsequent residual connection, relative to the initial representations. This cosine similarity serves as an indicator of the impact of the attention layer in comparison to the shortcut branch within the residual connection.
Refer to caption: extracted/5923029/Figures/figure_influence_of_attention_layer.png

To assure that our proposed model develops the attention layer rather than enhancing the shortcut branch like some previous works (Noci et al., ), we measured the cosine similarity between residual connection’s output representations and the initial representations (word embedding vectors). This cosine similarity means the influence of attention layer within the residual connection. As demonstrated in Fig.7, we found that daGPAM models usually achieve less cosine similarity which means the attention layers output representations are more diverse compared to the baseline’s. Based on this analysis, we believe that daGPAM actually affects the attention layer rather than enhancing shortcut branch.

#### A.3.4 Wikitext103 LM Experiments with Various λ 𝜆 \lambda italic_λ s

Figure: Figure 8: PPL results of daGPAM models (based on 8-layered TransformerXL) with various constant $\lambda$s were trained on Wikitext103 LM task. The darker the color is, the better PPL is.
Refer to caption: extracted/5923029/Figures/figure_wikitext_results_with_lambdas.png

To provide profound understanding on the effects of $\lambda$s in practice, we conducted more Wikitext103 LM experiments of daGPAM models based on 8-layered TransformerXL architecture with varying each $\lambda$ from 0.5 to 3.0 with 0.5 interval. Note that the total sum of normalized attention score is $\Sigma=(1+\lambda^{+}-\lambda{-})$. We discovered that, at each value of $\lambda^{+}$, increasing $\lambda^{-}$ improves performance until it makes $\Sigma$ lower than -2.0. Usually, the best performance was achieved when $\Sigma$ is 0.5. Interestingly, we found that, when $\Sigma$ is 0.0, performance instantly drops. We understand the 0.0 $\Sigma$ can overly amplify the direct movement on the hyperplane, $\Delta$, while eliminate the effect original point $\mathbf{Y}^{+}$ as we explained in Section 4.2. This may cause too diverse output representations. Empirically, we found that the cases when $\Sigma$ is close to 0.5, usually be the optimal setting for daGPAM models.

### A.4 Technical Lemmas from (Dong et al., 2021 )

#### A.4.1 Properties of Matrix Norm

In this section, we describe the formulation and properties of matrix norm which are frequently used in our proof derivations. We note that L-1 and L-$\infty$ norms of a $T\times d$ matrix, $\mathbf{M}$, which are formulated as follow:

$$ $\displaystyle\|\mathbf{M}\|_{1}$ $\displaystyle=\max\limits_{1\leq i\leq d}\left(\sum_{j=1}^{T}|\mathbf{M}_{ji}| \right),$ $\displaystyle\|\mathbf{M}\|_{\infty}$ $\displaystyle=\max\limits_{1\leq i\leq T}\left(\sum_{j=1}^{d}|\mathbf{M}_{ij}| \right).$ $$

Noticeably, $\|\mathbf{M}\|_{1}=\|\mathbf{M}^{\top}\|_{\infty}$. If there is a matrix $\mathbf{N}$ which is multiplicative with $\mathbf{M}$, then $\|\mathbf{M}\mathbf{N}\|\leq\|\mathbf{M}\|\|\mathbf{N}\|$. This property holds for L-1 and L-$\infty$ norms.

#### A.4.2 Simplification of Unnormalized Attention Matrix

Given the definition of the unnormalized attention matrix $\mathbf{A}$, Eq.3, $\mathbf{A}$ is related to the residual, Eq.4, as follows:

$$ $\displaystyle\mathbf{A}$ $\displaystyle=\frac{1}{\sqrt{d_{qk}}}(\mathbf{R}+\mathbf{1}\bar{\mathbf{x}}^{ \top})\mathbf{W}_{QK}(\mathbf{R}+\mathbf{1}\bar{\mathbf{x}}^{\top})^{\top}$ $\displaystyle=\frac{1}{\sqrt{d_{qk}}}\left(\mathbf{R}\mathbf{W}_{QK}\mathbf{R} ^{\top}+\mathbf{R}\mathbf{W}_{QK}\bar{\mathbf{x}}\mathbf{1}^{\top}+\mathbf{1} \bar{\mathbf{x}}^{\top}\mathbf{W}_{QK}\mathbf{R}^{\top}+\mathbf{1}\bar{\mathbf {x}}^{\top}\mathbf{W}_{QK}\bar{\mathbf{x}}\mathbf{1}^{\top}\right),$ $$

where $\mathbf{W}_{QK}=\mathbf{W}_{Q}\mathbf{W}_{K}^{\top}$ and $\mathbf{R}=res(\mathbf{X})=\mathbf{X}-\mathbf{1}\bar{\mathbf{x}}^{\top}$. By following the shift invariance property of the softmax function (Cordonnier et al., ) which means a constant term added to every element of a row is negligible, we approximate $\mathbf{A}$ as follows:

$$ $\displaystyle\widetilde{\mathbf{A}}$ $\displaystyle\approx\frac{1}{\sqrt{d_{qk}}}\left(\mathbf{R}\mathbf{W}_{QK} \mathbf{R}^{\top}+\mathbf{1}\bar{\mathbf{x}}^{\top}\mathbf{W}_{QK}\mathbf{R}^{ \top}\right).$ $$

Note that every eliminated (by the approximation) terms has the form, $\mathbf{c}\mathbf{1}^{\top}$, so that we can express $\mathbf{A}=\widetilde{\mathbf{A}}+\mathbf{c}^{{}^{\prime}}\mathbf{1}^{\top}$ where the vector, $\mathbf{c}^{{}^{\prime}}$, is the summation of every eliminated terms without the common factor, $\mathbf{1}^{\top}$. Then, the output of the softmax function with $\mathbf{A}$ as input is $softmax(\mathbf{A})=softmax(\widetilde{\mathbf{A}}+\mathbf{c}^{{}^{\prime}}
\mathbf{1}^{\top})=softmax(\widetilde{\mathbf{A}})$. Therefore, we can safely use the approximated unnormalized attention matrix instead of the original during the attention mechanism.

#### A.4.3 Bounds of Normalized Attention Matrix

With incorporating the approximation of the unnormalized attention matrix to the definition of the normalized attention matrix, Eq.2 (without considerations of positive and negative signs), we can formulate the normalized attention matrix as follows:

$$ $\displaystyle\mathbf{P}=softmax(\frac{1}{\sqrt{d_{qk}}}\mathbf{A})=softmax \left(\mathbf{1}\mathbf{r}^{\top}+\mathbf{E}\right),$ $$

where $\mathbf{E}=\frac{1}{\sqrt{d_{qk}}}\mathbf{R}\mathbf{W}_{QK}\mathbf{R}^{\top}$ and $\mathbf{r}=\frac{1}{\sqrt{d_{qk}}}\mathbf{R}(\mathbf{W}_{QK})^{\top}\bar{
\mathbf{x}}$.

The $(i,j)$-th element of $\mathbf{P}$ is derived as follow:

$$ $\displaystyle\mathbf{P}_{ij}=\frac{\exp\left((\mathbf{1}\mathbf{r}^{\top})_{ij }+\mathbf{E}_{ij}\right)}{\sum_{t=1}^{T}\exp\left((\mathbf{1}\mathbf{r}^{\top} )_{it}+\mathbf{E}_{it}\right)}=\frac{\exp\left((\mathbf{1}\mathbf{r}^{\top})_{ ij}\right)\exp\left(\mathbf{E}_{ij}\right)}{\sum_{t=1}^{T}\exp\left((\mathbf{1 }\mathbf{r}^{\top})_{it}\right)\exp\left(\mathbf{E}_{it}\right)}.$ $$

This value is upper bounded when we replace $\exp(\mathbf{E}_{it})$ in the denominator with $\min\limits_{j^{{}^{\prime}}}\exp(\mathbf{E}_{ij^{{}^{\prime}}})$. Likewise, it is lower bounded when we replace the same term with $\max\limits_{j^{{}^{\prime}}}\exp(\mathbf{E}_{ij^{{}^{\prime}}})$. Based on these ideas, we can bound the $(i,j)$-th element of $\mathbf{P}$ as follows:

$$ $\displaystyle\frac{\exp(\mathbf{E}_{ij})}{\max\limits_{j^{{}^{\prime}}}\exp( \mathbf{E}_{ij^{{}^{\prime}}})}\widetilde{\mathbf{P}}_{ij}$ $\displaystyle\leq\mathbf{P}_{ij}\leq\frac{\exp(\mathbf{E}_{ij})}{\min\limits_{ j^{{}^{\prime}}}\exp(\mathbf{E}_{ij^{{}^{\prime}}})}\widetilde{\mathbf{P}}_{ij},$ $\displaystyle\left(\min\limits_{j^{{}^{\prime}}}\exp(\mathbf{E}_{ij}-\mathbf{E }_{ij^{{}^{\prime}}})\right)\widetilde{\mathbf{P}}_{ij}$ $\displaystyle\leq\mathbf{P}_{ij}\leq\left(\max\limits_{j^{{}^{\prime}}}\exp( \mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}})\right)\widetilde{\mathbf{P}}_{ ij},$ $$

where $\widetilde{\mathbf{P}}_{ij}=\frac{\exp\left((\mathbf{1}\mathbf{r}^{\top})_{ij}
\right)}{\sum_{t=1}^{T}\exp\left((\mathbf{1}\mathbf{r}^{\top})_{it}\right)}=
softmax(\mathbf{1}\mathbf{r}^{\top})_{ij}=(\mathbf{1}softmax(\mathbf{r})^{\top
})_{ij}$. Given the fact that $\exp(x)$ is approximated by $1+x+\frac{1}{2!}x^{2}+\frac{1}{3!}x^{3}+\dots$ with Taylor series near to $x=0$ and it is upper bounded $\exp(x)\leq 1+2x$ where the condition $|x|\leq 1.256$ holds, we know that $\max\limits_{j^{{}^{\prime}}}\exp(\mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}})$ is upper bounded by $1+2\max\limits_{j^{{}^{\prime}}}(\mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}})$ with the condition that $|\mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}}|\leq 1.256$. Analogously, $\min\limits_{j^{{}^{\prime}}}\exp(\mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}})$ is lower bounded by $1-2\min\limits_{j^{{}^{\prime}}}(\mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}})$. Therefore, the lower and upper bounds of $(i,j)$-th element of $\mathbf{P}$ are derived as follows:

$$ $\displaystyle\left(1-2\min\limits_{j^{{}^{\prime}}}(\mathbf{E}_{ij}-\mathbf{E} _{ij^{{}^{\prime}}})\right)\widetilde{\mathbf{P}}_{ij}$ $\displaystyle\leq\mathbf{P}_{ij}\leq\left(1+2\max\limits_{j^{{}^{\prime}}}( \mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}})\right)\widetilde{\mathbf{P}}_{ ij},$ $\displaystyle\left(1+2\max\limits_{j^{{}^{\prime}}}(\mathbf{E}_{ij^{{}^{\prime }}}-\mathbf{E}_{ij})\right)\widetilde{\mathbf{P}}_{ij}$ $\displaystyle\leq\mathbf{P}_{ij}\leq\left(1+2\max\limits_{j^{{}^{\prime}}}( \mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}})\right)\widetilde{\mathbf{P}}_{ ij}.$ (21) $$

Note that the negative sign of lower bound of the first inequality goes inside of the $\min$ operation while changing it to $\max$ operation. Finally, the matrix level inequality is formulated as follows:

$$ $\displaystyle\left(\mathbf{I}-2\mathbf{D}\right)\widetilde{\mathbf{P}}$ $\displaystyle\leq\mathbf{P}\leq\left(\mathbf{I}+2\mathbf{D}\right)\widetilde{ \mathbf{P}},$ $$

where $\mathbf{I}$ is identity matrix. $\mathbf{D}$ is a diagonal matrix whose $i$-th diagonal element is $\mathbf{D}_{ii}=\max\limits_{j,j^{{}^{\prime}}}|\mathbf{E}_{ij}-\mathbf{E}_{ij
^{{}^{\prime}}}|$. We note that the last inequality is even larger/smaller bounds than those of Eq.21 because it takes the maximum value across $j$ and $j^{{}^{\prime}}$ simultaneously.

#### A.4.4 Upper Bounds of L-1 and L- ∞ \infty ∞ Norms of the Matrix Formed ( 𝐙𝟏 ⁢ s ⁢ o ⁢ f ⁢ t ⁢ m ⁢ a ⁢ x ⁢ ( 𝐫 ) ⊤ ) 𝐙𝟏 𝑠 𝑜 𝑓 𝑡 𝑚 𝑎 𝑥 superscript 𝐫 top (\mathbf{Z}\mathbf{1}softmax(\mathbf{r})^{\top}) ( bold_Z1 italic_s italic_o italic_f italic_t italic_m italic_a italic_x ( bold_r ) start_POSTSUPERSCRIPT ⊤ end_POSTSUPERSCRIPT )

By following the property of matrix norm (Sec.A.4.1), the L1 norm of the matrix can be upper bounded as follows:

$$ $\displaystyle\|\mathbf{Z}\mathbf{1}softmax(\mathbf{r})^{\top}\|_{1}$ $\displaystyle\leq\|\mathbf{Z}\mathbf{1}\|_{1}\|softmax(\mathbf{r})^{\top}\|_{1},$ $\displaystyle=\|\mathbf{Z}\mathbf{1}\|_{1},$ $$

based on the facts that $\|softmax(\mathbf{r})^{\top}\|_{1}=\sum_{i=1}^{T}|softmax(\mathbf{r})_{i}|=1$. Similarly, the upper bound of L-$\infty$ norm is as follows:

$$ $\displaystyle\|\mathbf{Z}\mathbf{1}softmax(\mathbf{r})^{\top}\|_{\infty}$ $\displaystyle\leq\|\mathbf{Z}\mathbf{1}\|_{\infty}\|softmax(\mathbf{r})^{\top} \|_{\infty},$ $\displaystyle\leq\|\mathbf{Z}\mathbf{1}\|_{\infty},$ $$

based on the fact that $\|softmax(\mathbf{r})^{\top}\|_{\infty}=\max\limits_{i}|softmax(\mathbf{r})_{i
}|\leq 1$.

#### A.4.5 Upper Bound of ‖ 𝐃𝟏 ‖ 1 ⁢ ‖ 𝐃𝟏 ‖ ∞ subscript norm 𝐃𝟏 1 subscript norm 𝐃𝟏 \|\mathbf{D}\mathbf{1}\|_{1}\|\mathbf{D}\mathbf{1}\|_{\infty} ∥ bold_D1 ∥ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ∥ bold_D1 ∥ start_POSTSUBSCRIPT ∞ end_POSTSUBSCRIPT

About the L-1 and L-$\infty$ norms of $\mathbf{D}\mathbf{1}$, we follow the same definition of Sec.A.4.3 for the matrix $\mathbf{D}$ whose diagonal element is $\mathbf{D}_{ii}=\max\limits_{j,j^{{}^{\prime}}}|\mathbf{E}_{ij}-\mathbf{E}_{ij
^{{}^{\prime}}}|$. Based on the initial condition of Lemma 6 which is related to $\gamma$: $\sqrt{\sum_{i=1}^{T}\max\limits_{j,j^{{}^{\prime}}}|\mathbf{E}_{ij}-\mathbf{E}
_{ij^{{}^{\prime}}}|}\leq\gamma\sqrt{\max\limits_{j,j^{{}^{\prime}}}\sum_{i=1}
^{T}|\mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}}|}$. Then, the multiplication of L-1 and L-$\infty$ norms is derived and upper bounded as follows:

$$ $\displaystyle\|\mathbf{D}\mathbf{1}\|_{1}\|\mathbf{D}\mathbf{1}\|_{\infty}$ $\displaystyle=\max\limits_{i,j,j^{{}^{\prime}}}|\mathbf{E}_{ij}-\mathbf{E}_{ij ^{{}^{\prime}}}|\sum_{i=1}^{T}\max\limits_{j,j^{{}^{\prime}}}|\mathbf{E}_{ij}- \mathbf{E}_{ij^{{}^{\prime}}}|,$ $\displaystyle\leq 2\max\limits_{i,j}|\mathbf{E}_{ij}|\sum_{i=1}^{T}\max\limits _{j,j^{{}^{\prime}}}|\mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}}|,$ $\displaystyle\leq 2\|\mathbf{E}\|_{1}\sum_{i=1}^{T}\max\limits_{j,j^{{}^{ \prime}}}|\mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}}|,$ $\displaystyle\leq 2\gamma^{2}\|\mathbf{E}\|_{1}\left(\max\limits_{j,j^{{}^{ \prime}}}\sum_{i=1}^{T}|\mathbf{E}_{ij}-\mathbf{E}_{ij^{{}^{\prime}}}|\right),$ $\displaystyle\leq 2\gamma^{2}\|\mathbf{E}\|_{1}\left(2\max\limits_{j}\sum_{i=1 }^{T}|\mathbf{E}_{ij}|\right),$ $\displaystyle=8\gamma^{2}\|\mathbf{E}\|_{1}\|\mathbf{E}\|_{1}=8\gamma^{2}\| \mathbf{E}\|_{1}^{2},$ $$

## Peer Reviews

confidence: 3
contribution: 3
initial_rating: 6
presentation: 4
questions: How does the method work in long context scenarios? Even a simple benchmark like Long Range Arena would be helpful. My intuition feels like there should be a larger improvement.
soundness: 3
strengths: The method and presentation are good. They give intuitive, theoretical and experiential justification of the ideas.

The experiment results improve over the baseline.
summary: The paper introduces a new attention mechanism that replaces the attention scores. The attention scores in softmax for each query are a convex sum, so scores must be positive. They argue for using an affine sum which also sums to 1 but allows for negative scores.

They are motivated by rank collapse and gradient vanishing. Rank collapse is mitigated since the negative sums introduce more diversity. They show that gradient vanishing is a related problem.

To validate their method they perform several small scale benchmarks, namely perplexity and translation and find their methods improve against the baselines.
weaknesses: The range of evaluations is pretty limited and extra computation is needed.

A benchmark against just increasing the number of attention heads would be useful.

---

confidence: 3
contribution: 2
initial_rating: 5
presentation: 3
questions: - Do the authors believe other attention variants solve the rank collapse / vanishing gradients problem, and can this be experimentally validated?
- How does rank collapse (Figure 4) reflect in downstream performance? It would be interesting to see that a higher degree of rank collapse results in lower downstream results, but without this correlation it is hard to reason about the value of reducing rank collapse.
soundness: 3
strengths: - The paper includes theory on how daGPAM can reduce rank collapse and vanishing gradients. It does so by showing the residual norm of daGPAM and also its gradient is greater than the respective values for vanilla attention (the original values for attention having been computed by [[Dong et al](https://proceedings.mlr.press/v139/dong21a.html)]).
- The paper is well written and easy to follow, and contextualizes relevant work well.
summary: The authors propose daGPAM -- an attention module that computes an additional negative coefficient attention matrix aiming to solve rank collapse and vanishing gradients in transformers.
weaknesses: - I think the downstream experiments for this paper could be fleshed out more. I appreciate that some sort of comparison with alternative attention mechanisms like CoDA is present, but I think only having these comparisons on PTB is insufficient. So many attention variants have been proposed over the years, and none have really taken hold, so I think the empirical bar should be high for current and future variants. Even though this paper shows evidence of reducing rank collapse, rank collapse is ultimately something that matters as it reflects in downstream performance, so I think rank collapse on its own is not enough in the absence of strong empirical results. I think this could be addressed by the authors including more attention variants (CoDA etc) in the LM and NMT experiments.

---

confidence: 3
contribution: 2
initial_rating: 5
presentation: 3
questions: 1. The optimal $\lambda^{+}$ and $\lambda^{-}$ values seem to vary across different tasks. Can the authors provide an ablation study on choosing different settings of the hyper-params. 
2. Can the authors provide the inference time and memory cost of the model?
soundness: 2
strengths: 1. The writing is easy to follow
2. The paper shows quite interesting results gradient vanishing and rank-collapse is hard to solve simultaneously total norm of gradients is maximized can lead to rank-collapse.
3. The authors theoretically show that their method can mitigate both the rank-collapse issue and reduce the the gradient vanishing problem.
summary: The paper introduces GPAM, an attention mechanism that allows negative attention scores while maintaining a fixed sum, addressing both rank-collapse and gradient vanishing problems in Transformers. Their proposed dual-attention GPAM (daGPAM), adds a negative attention matrix computation alongside the original one, requiring small additional parameters. The authors show the theoretical advantage of their model and examine their models on language tasks.
weaknesses: My main concerns are:
1. The improvement of daGPAM is very marginal, and not significant in both Language modeling (on Wikitext-103 and Enwiki8, the improvement is around 0,5 PPL) and machine translation tasks (on IWSLT14 and WMT14, maximum improvement is around 0.7% BLEU score.) 
2. Computational cost: the dual-attention structure requires computing two attention matrices instead of one, which is very inefficient. The marginal improvement does not justify this performance-efficiency trade-off.

---

confidence: 4
contribution: 3
initial_rating: 6
presentation: 3
questions: Q1. Empirical improvements seem quite marginal according to Table 1. Specifically, a roughly 1% improvement on PPL is not significant enough given that the proposed approach has approximately 1% more parameters (Line 450-451).

Q2. In Line 250, the range for PG should be [1 - \lambda^-, 1 + \lambda^+].
soundness: 3
strengths: This paper studies how to alleviate the rank-collapse and gradient vanishing problems in standard attention mechanism, which is an important problem of profound implication in practice. Authors provided a concrete analysis on the intrinsic trade-offs between avoiding rank-collapse and gradient vanishing in standard attention mechanism and showed that GPAM is able to mitigate both problems simultaneously. The theoretical analysis in this paper seems solid and the presentation is clear.
summary: Despite the success of Transformers, the standard attention mechanism is associated with two well-known issues: rank-collapse and gradient vanishing. This paper proposed generalized probabilistic attention mechanism (GPAM) to mitigate both the rank-collapse and gradient vanishing issues simultaneously. Evaluation results on real-world datasets demonstrate the effectiveness of GPAM.
weaknesses: Evaluation in this work can be significantly improved. Given the prevalent success of Large Language Models (LLMs) on various advanced tasks (e.g., solving math and coding problems), evaluation on only small language models (20M-200M) and classic NLP tasks (e.g., neural machine translation) seems insufficient. More evaluation results on open-sourced LLMs (e.g., Llama-3 or Phi-3 family) and widely used benchmarks (e.g., MMLU or GSM8K) will add great values to this paper.

Meta-review: This work introduces daGPAM, an architecture update addressing two problems in transformers : rank collapse and vanishing gradients. Reviewers enjoyed the theoretical contributions, but the empirical validation of the proposed approach is limited. The improvements observed on standard benchmarks are marginal, and the paper lacks a comprehensive comparison with other alternative architectures. Overall, the paper falls short of the acceptance threshold.

Decision: Reject