arXiv:2412.06590cs.CV2024-12NeurIPS被引 63

提出新理论解释线性注意力性能差的原因,并给出改进方法。

Bridging the Divide: Reconsidering Softmax and Linear Attention

  • 发现线性注意力缺乏单射性,易导致语义混淆
  • 证明局部建模能力是高效注意力的关键
  • 改进后线性注意力在多任务上超越Softmax且更高效

现代视觉变换器广泛采用Softmax注意力以捕捉长程视觉信息,但其在高分辨率输入下计算成本过高。相比之下,线性注意力天然具备线性复杂度,有潜力扩展至更高分辨率图像,但性能不佳限制了实际应用。本文通过新理论分析,揭示线性与Softmax注意力性能差异的核心原因:一是线性注意力不具备单射性,不同查询向量可能被赋予相同注意力权重,引发严重语义混淆;二是有效局部建模对Softmax注意力至关重要,而线性注意力在此方面表现不足。这两个根本差异经大量实证验证,进一步实验表明,只要赋予线性注意力上述两种特性,其可在多个任务中超越Softmax注意力,同时保持更低的计算复杂度。代码已公开于https://github.com/LeapLabTHU/InLine。

原文摘要 · Abstract (English)

Widely adopted in modern Vision Transformer designs, Softmax attention can effectively capture long-range visual information; however, it incurs excessive computational cost when dealing with high-resolution inputs. In contrast, linear attention naturally enjoys linear complexity and has great potential to scale up to higher-resolution images. Nonetheless, the unsatisfactory performance of linear attention greatly limits its practical application in various scenarios. In this paper, we take a step forward to close the gap between the linear and Softmax attention with novel theoretical analyses, which demystify the core factors behind the performance deviations. Specifically, we present two key perspectives to understand and alleviate the limitations of linear attention: the injective property and the local modeling ability. Firstly, we prove that linear attention is not injective, which is prone to assign identical attention weights to different query vectors, thus adding to severe semantic confusion since different queries correspond to the same outputs. Secondly, we confirm that effective local modeling is essential for the success of Softmax attention, in which linear attention falls short. The aforementioned two fundamental differences significantly contribute to the disparities between these two attention paradigms, which is demonstrated by our substantial empirical validation in the paper. In addition, more experiment results indicate that linear attention, as long as endowed with these two properties, can outperform Softmax attention across various tasks while maintaining lower computation complexity. Code is available at https://github.com/LeapLabTHU/InLine.

注意力机制视觉变换器线性注意力理论分析

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