arXiv:2507.00698cs.CV2025-07ICCV被引 36

解决线性注意力忽略查询幅度导致性能下降的问题

Rectifying Magnitude Neglect in Linear Attention

  • 提出感知查询幅度的线性注意力机制,修复原有缺陷
  • 在图像分类、目标检测等7项任务上达到强性能
  • 适合追求高效且精准注意力模型的研究者使用

作为Transformer的核心算子,Softmax注意力具有出色的全局建模能力,但其二次复杂度限制了在视觉任务中的应用。相比之下,线性注意力在保持与Softmax注意力相似结构的同时实现线性复杂度,从而支持高效的全局信息建模。然而,线性注意力相较于标准Softmax注意力存在显著性能下降。本文基于线性注意力的公式分析发现,与Softmax注意力不同,线性注意力完全忽略了查询(Query)的幅度信息,导致注意力分数分布无法随查询尺度动态调整。因此,尽管结构相似,线性注意力仍呈现出显著不同的注意力分布。针对此问题,我们提出幅度感知的线性注意力(MALA),通过修改计算方式以充分融合查询的幅度信息。该调整使MALA生成的注意力分布更接近Softmax注意力,且结构更均衡。我们在图像分类、目标检测、实例分割、语义分割、自然语言处理、语音识别和图像生成等多个任务上验证了MALA的有效性,结果表明其在所有任务上均取得优异表现。代码将开源于https://github.com/qhfan/MALA。

原文摘要 · Abstract (English)

As the core operator of Transformers, Softmax Attention exhibits excellent global modeling capabilities. However, its quadratic complexity limits its applicability to vision tasks. In contrast, Linear Attention shares a similar formulation with Softmax Attention while achieving linear complexity, enabling efficient global information modeling. Nevertheless, Linear Attention suffers from a significant performance degradation compared to standard Softmax Attention. In this paper, we analyze the underlying causes of this issue based on the formulation of Linear Attention. We find that, unlike Softmax Attention, Linear Attention entirely disregards the magnitude information of the Query. This prevents the attention score distribution from dynamically adapting as the Query scales. As a result, despite its structural similarity to Softmax Attention, Linear Attention exhibits a significantly different attention score distribution. Based on this observation, we propose Magnitude-Aware Linear Attention (MALA), which modifies the computation of Linear Attention to fully incorporate the Query's magnitude. This adjustment allows MALA to generate an attention score distribution that closely resembles Softmax Attention while exhibiting a more well-balanced structure. We evaluate the effectiveness of MALA on multiple tasks, including image classification, object detection, instance segmentation, semantic segmentation, natural language processing, speech recognition, and image generation. Our MALA achieves strong results on all of these tasks. Code will be available at https://github.com/qhfan/MALA

注意力机制线性注意力Transformer模型优化

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