arXiv:2507.23632cs.LG2025-07被引 7

从RNN视角揭示softmax注意力为何比线性注意力更强大

On the Expressiveness of Softmax Attention: A Recurrent Neural Network Perspective

  • 将softmax注意力重构成递归形式,用RNN语言描述其结构
  • 实验证明线性注意力是softmax注意力的近似,导致性能差距
  • 适合关注注意力机制原理与模型设计的读者

自引入以来,softmax注意力因其表达能力与可扩展性成为现代Transformer架构的核心。然而,其随序列长度呈二次增长的内存与计算开销是主要缺陷。为此,线性注意力等方法被提出以规避这一瓶颈。尽管这些线性注意力源自原始softmax公式,但在下游任务中通常表现较差。虽然直观上认为softmax非线性对查询与键内积具有优越性质,但这种性能差异的根源仍未阐明。本文通过推导softmax注意力的递归形式,将其重新表述为递归神经网络(RNN)结构,使注意力各组件可在RNN语言下被解析与消融。该框架揭示了softmax注意力中各部分的作用及其相互关系,从而解释了其相较于替代方法更强的表达能力。

原文摘要 · Abstract (English)

Since its introduction, softmax attention has become the backbone of modern transformer architectures due to its expressiveness and scalability across a wide range of tasks. However, the main drawback of softmax attention is the quadratic memory requirement and computational complexity with respect to the sequence length. By replacing the softmax nonlinearity, linear attention and similar methods have been introduced to avoid the quadratic bottleneck of softmax attention. Despite these linear forms of attention being derived from the original softmax formulation, they typically lag in terms of downstream accuracy. While strong intuition of the softmax nonlinearity on the query and key inner product suggests that it has desirable properties compared to other nonlinearities, the question of why this discrepancy exists still remains unanswered. This work demonstrates that linear attention is an approximation of softmax attention by deriving the recurrent form of softmax attention. Using this form, each part of softmax attention can be described in the language of recurrent neural networks (RNNs). Describing softmax attention as an RNN allows for the ablation of the components of softmax attention to understand the importance of each part and how they interact. In this way, our work helps explain why softmax attention is more expressive than its counterparts.

注意力机制TransformerRNN表达能力

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。