Skip to main content
QUICK REVIEW

[论文解读] Making Vision Transformers Efficient from A Token Sparsification View

Shuning Chang, Pichao Wang|arXiv (Cornell University)|Mar 15, 2023
Advanced Neural Network ApplicationsComputer Science被引用 3
一句话总结

本文提出语义标记ViT(STViT),一种标记稀疏化方法,通过使用少量可学习的语义标记作为聚类中心,替代冗余的图像标记。利用多头注意力动态聚合并恢复这些高层语义表征,STViT在DeiT模型上实现了高达60%的FLOPs减少和超过100%的加速,同时精度下降极小,并通过可恢复主干设计实现了对下游任务的高效适应。

ABSTRACT

The quadratic computational complexity to the number of tokens limits the practical applications of Vision Transformers (ViTs). Several works propose to prune redundant tokens to achieve efficient ViTs. However, these methods generally suffer from (i) dramatic accuracy drops, (ii) application difficulty in the local vision transformer, and (iii) non-general-purpose networks for downstream tasks. In this work, we propose a novel Semantic Token ViT (STViT), for efficient global and local vision transformers, which can also be revised to serve as backbone for downstream tasks. The semantic tokens represent cluster centers, and they are initialized by pooling image tokens in space and recovered by attention, which can adaptively represent global or local semantic information. Due to the cluster properties, a few semantic tokens can attain the same effect as vast image tokens, for both global and local vision transformers. For instance, only 16 semantic tokens on DeiT-(Tiny,Small,Base) can achieve the same accuracy with more than 100% inference speed improvement and nearly 60% FLOPs reduction; on Swin-(Tiny,Small,Base), we can employ 16 semantic tokens in each window to further speed it up by around 20% with slight accuracy increase. Besides great success in image classification, we also extend our method to video recognition. In addition, we design a STViT-R(ecover) network to restore the detailed spatial information based on the STViT, making it work for downstream tasks, which is powerless for previous token sparsification methods. Experiments demonstrate that our method can achieve competitive results compared to the original networks in object detection and instance segmentation, with over 30% FLOPs reduction for backbone. Code is available at http://github.com/changsn/STViT-R

研究动机与目标

  • 为解决视觉Transformer(ViTs)因标记数量过高而导致的二次方计算成本问题。
  • 克服现有标记剪枝方法的局限性,包括精度下降、空间分布不佳以及与下游任务不兼容的问题。
  • 开发一种通用、高效的ViT架构,适用于全局注意力(如DeiT)和局部注意力(如Swin)模型。
  • 通过可恢复主干设计,实现对下游任务(如目标检测和实例分割)的有效微调与适应。
  • 证明少量语义标记可有效表征全局与局部语义信息,且不损失性能。

提出的方法

  • 通过空间和跨窗口池化初始化语义标记,以确保均匀、空间感知的分布及局部语义整合。
  • 采用两层Transformer结构的语义标记生成模块(STGM),以这些标记作为查询,关注图像标记(键/值),通过自注意力机制恢复聚类中心。
  • 第一层注意力使用空间初始化的语义标记聚合局部特征,第二层注意力实现全局语义聚类。
  • STGM完成后,图像标记被丢弃,仅在后续层中使用语义标记,显著降低FLOPs和推理时间。
  • 针对下游任务,引入STViT-R,采用“哑铃单元”重用语义标记,并通过恢复模块恢复空间细节。
  • 该方法即插即用,兼容全局(DeiT)和局部(Swin)注意力机制。

实验结果

研究问题

  • RQ1少量可学习的语义标记是否能在不造成显著精度下降的前提下,有效替代ViTs中的冗余图像标记?
  • RQ2如何使标记稀疏化在不同ViT架构(包括全局与局部注意力变体)中具备鲁棒性和通用性?
  • RQ3稀疏化的ViT主干能否有效微调以应用于目标检测和实例分割等下游任务?
  • RQ4何种初始化方式与注意力机制最有助于语义标记同时捕捉局部与全局图像表征?
  • RQ5STViT-R中集成的恢复模块如何有效恢复空间细节以支持密集预测任务?

主要发现

  • 在DeiT-Tiny、Small和Base模型上,仅使用16个语义标记即可实现与完整模型相当的精度,同时推理速度提升超过100%,FLOPs减少近60%。
  • 在Swin-Tiny和Swin-Small模型上,每窗口使用16个语义标记可使速度提升约20%,并略微提高精度,证明了方法的效率与鲁棒性。
  • STViT-R在目标检测和实例分割任务上实现了51.8的COCO APb和44.7的APm,主干FLOPs减少超过30%。
  • 消融实验表明,结合空间与全局初始化优于单一初始化方式,且哑铃单元对恢复性能至关重要。
  • 在哑铃单元间重用语义标记仅导致性能轻微下降(如APb下降0.2),证实了方法的稳定性。
  • 全局初始化与学习的位置编码不同,若以学习的位置编码替代全局初始化,精度下降0.1%,验证了其独特作用。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。