Title: Response to Reviewer QNSJ (2/2): Response to the Questions Part
**Questions Part:**
> 1\. Do both attention calculations in differential attention use RoPE positional encoding?
Yes.
> 2\. Similar to multi-query attention, can $K_1$, $K_2$, or $Q_1$, $Q_2$ share parameters?
Yes. We conduct experiments on models with 300M parameters. The validation loss of Transformer is 4.406. For a full-parameter DIFF Transformer, the loss is 4.343. For a DIFF Transformer with $Q_1=Q_2$, the loss is 4.347. For a DIFF Transformer with $K_1=K_2$, the loss is 4.346. The performance indicates it is possible to share $K_1$, $K_2$, or $Q_1$, $Q_2$ in DIFF Transformer.
> 3\. Is there a significant difference in sparsity between DiffAttn and regular attention? Does the first term of DiffAttn resemble the pattern of standard attention (implying that the second negative attention term serves to cancel out noise)?
Yes. We demonstrate the sparse pattern in Figure 1 and Table 3. We further explain it in the response to the first question in the Weaknesses Part above.
We visualized two attention maps. The sum of the second attention term equals to $\lambda$. For most layers, $\lambda < 1$. Under this circumstance, we find on noise context, the second term allocates almost same scores as the first term, while on key information, the second term allocates less scores than the first term. Therefore after subtraction, the noise is canceled out, and the key information is kept. For a few layers with $\lambda > 1$, the role of the two terms exchanges, and the conclusion is the same.
> 4\. What is the calculation formula for Table 3?
Firstly, we define the token set that contains all key information tokens as $A$, set contains all noise context tokens as $N$, and set contains the generated tokens as $G$.
For conventional attention, we define attention score, i.e. the output of $\operatorname{softmax}$ function, as $a_{ij}$, which means the score that the $i$-th token allocates to the $j$-th token, $1 \le j \le i$.
"Attention to Answer" is calculated with:
$$
\\text{Score} _ {\\text{ans}} = \\cfrac{1}{|G|} \\sum _ {i \\in G} \\cfrac{\\sum _ {j \\in A} \\ a_{ij}}{\\sum _ {j=1}^i \\ a_{ij}} = \\cfrac{1}{|G|} \\sum _ {i \\in G} \\cfrac{\\sum _ {j \\in A} \\ a_{ij}}{1}
$$
"Attention Noise" is calculated with:
$$
\\text{Score} _ {\\text{noise}} = \\cfrac{1}{|G|} \\sum _ {i \\in G} \\cfrac{\\sum _ {j \\in N} \\ a _ {ij}}{\\sum _ {j=1}^i \\ a _ {ij}} = \\cfrac{1}{|G|} \\sum _ {i \\in G} \\cfrac{\\sum _ {j \\in N} \\ a _ {ij}}{1}
$$
For differential attention, we define attention scores of the first term as $a_{ij}^{(1)}$ and scores of the second term as $a_{ij}^{(2)}$.
"Attention to Answer" is calculated with:
$$
\\text{Score} _ {\\text{ans}} = \\cfrac{1}{|G|} \\sum _ {i \\in G} \\cfrac{\\sum _ {j \\in A} \\ a _ {ij}^{(1)} - \\lambda a _ {ij}^{(2)}}{\\sum _ {j=1}^i \\ a _ {ij}^{(1)} - \\lambda a _ {ij}^{(2)}} = \\cfrac{1}{|G|} \\sum _ {i \\in G} \\cfrac{\\sum _ {j \\in A} \\ a _ {ij}^{(1)} - \\lambda a _ {ij}^{(2)}}{1-\\lambda}
$$
"Attention Noise" is calculated with:
$$
\\text{Score} _ {\\text{noise}} = \\cfrac{1}{|G|} \\sum _ {i \\in G} \\cfrac{\\sum _ {j \\in N} \\ a _ {ij}^{(1)} - \\lambda a _ {ij}^{(2)}}{\\sum _ {j=1}^i \\ a _ {ij}^{(1)} - \\lambda a _ {ij}^{(2)}} = \\cfrac{1}{|G|} \\sum _ {i \\in G} \\cfrac{\\sum _ {j \\in N} \\ a _ {ij}^{(1)} - \\lambda a _ {ij}^{(2)}}{1-\\lambda}
$$
In the DIFF Transformer model we report, $\lambda \in (0,1)$ stands for all layers, so $1-\lambda$ is always positive.
The scores are then averaged across all layers and heads to obtain the final scores in Table 3. The calculation formula ensures all reported scores are within range $[0,1]$.
> 5\. Please discuss the relationship between differential attention and sparse attention.
The mentioned works are both influential paper. Routing Transformer [1] assigns queries and keys to clusters and performs attention only within each cluster. The complexity of attention is reduced to $\mathcal{O}(n^{1.5})$ with the proposed method. Sparse Transformer [2] uses sparse factorizations of the attention matrix to reduce the complexity of attention to $\mathcal{O}(n^{1.5})$. Both works create sparsity by restricting attention to a subset of tokens to accelerate attention. The performance of such methods is usually worse than their full attention counterparts due to the discarded tokens. It is also difficult for them to perform well in tasks such as key information retrieval.
In comparison, DIFF Transformer aims to natively create sparsity in full attention. DIFF Transformer can attend to important context accurately and sparsely without discarding any tokens, enabling it to outperm full attention Transformer in language modeling and tasks such as key information retrieval.
We will add this to discussion section when there are extra pages available.
[1] Efficient Content-Based Sparse Attention with Routing Transformers. Roy et al. 2021.
[2] Generating Long Sequences with Sparse Transformers. Child et al. 2019.