arXiv:2505.16463cs.CVcs.LG2025-05被引 9

用可学习的锚点实现高效视觉注意力,加速模型推理。

AnchorFormer: Differentiable Anchor Attention for Efficient Vision Transformer

  • 引入可微锚点捕捉关键信息,将注意力复杂度从O(n²)降到O(mn)
  • 在ImageNet上准确率提升9.0%,或减少46.7%计算量
  • 适用于分类、检测、分割任务,适合追求高效推理的场景

近期视觉变换器(ViTs)通过图像块间的全局自注意力在视觉任务中取得优异表现。然而,当输入图像划分粒度较小时,其复杂度高达O(n²),推理耗时显著增加。同时,关键信息往往集中在少数区域,部分令牌对下游任务帮助有限。为此,本文提出基于锚点的高效视觉变换器(AnchorFormer),利用锚点令牌学习关键信息并加速推理。首先,通过估计锚点与令牌间的二分注意力,将复杂度从O(n²)降至O(mn),其中m为锚点数量且m < n。特别地,通过神经层中的神经元表示锚点,可实现锚点的可微学习,并借助马尔可夫过程近似全局自注意力,避免非可微操作带来的负担,进一步提升近似效率。此外,将所提模型扩展至分类、检测和分割三类下游任务。大量实验表明其有效性:例如在ImageNet分类任务中,准确率最高提升9.0%或减少46.7%的FLOPs;在COCO检测任务中,相同计算量下mAP提升81.3%,优于现有基线。

原文摘要 · Abstract (English)

Recently, vision transformers (ViTs) have achieved excellent performance on vision tasks by measuring the global self-attention among the image patches. Given $n$ patches, they will have quadratic complexity such as $\mathcal{O}(n^2)$ and the time cost is high when splitting the input image with a small granularity. Meanwhile, the pivotal information is often randomly gathered in a few regions of an input image, some tokens may not be helpful for the downstream tasks. To handle this problem, we introduce an anchor-based efficient vision transformer (AnchorFormer), which employs the anchor tokens to learn the pivotal information and accelerate the inference. Firstly, by estimating the bipartite attention between the anchors and tokens, the complexity will be reduced from $\mathcal{O}(n^2)$ to $\mathcal{O}(mn)$, where $m$ is an anchor number and $m < n$. Notably, by representing the anchors with the neurons in a neural layer, we can differentiably learn these anchors and approximate global self-attention through the Markov process. It avoids the burden caused by non-differentiable operations and further speeds up the approximate attention. Moreover, we extend the proposed model to three downstream tasks including classification, detection, and segmentation. Extensive experiments show the effectiveness of our AnchorFormer, e.g., achieving up to a 9.0% higher accuracy or 46.7% FLOPs reduction on ImageNet classification, 81.3% higher mAP on COCO detection under comparable FLOPs, as compared to the current baselines.

视觉变换器注意力机制高效模型可微学习

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