arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2303.08810cs.CV
收藏

BiFormer:具有双层布线注意力的视觉Transformer

BiFormer: Vision Transformer with Bi-Level Routing Attention

City University of Hong Kong(香港城市大学);SenseTime Research(商汤科技研究院)

Lei Zhu, Xinjiang Wang, Zhanghan Ke, Wayne Zhang, Rynson Lau

摘要:

作为视觉Transformer的核心组成部分,注意力是捕捉长距离依赖的有力工具。然而,这种能力是有代价的:它会带来巨大的计算负担和沉重的内存占用,因为要计算所有空间位置上的成对令牌交互。一系列的作品试图通过引入手工制作的和内容无关的稀疏性到注意力中来缓解这个问题,例如将注意力操作限制在局部窗口,轴向条纹或扩张窗口内。与这些方法相比,我们提出了一种新的动态稀疏注意力通过双层路由,使内容感知的计算更灵活的分配。具体而言,对于查询,首先在粗略区域级别过滤掉不相关的键值对,然后在剩余候选区域(\ie,路由区域)的并集中应用细粒度的标记到标记注意。我们提供了一个简单而有效的实现建议的双层路由注意,利用稀疏性,以节省计算和内存,同时只涉及GPU友好的密集矩阵乘法。在此基础上,提出了一种新的通用视觉Transformer BiFormer。由于BiFormer以\textbf{query adaptive}的方式关注相关令牌的一个小子集,而不受其他无关令牌的干扰,因此它具有良好的性能和高计算效率,特别是在密集预测任务中。在几个计算机视觉任务,如图像分类,目标检测,和语义分割的实证结果验证了我们的设计的有效性。代码可在\url{https://github.com/rayleizhu/BiFormer}获得。

英文摘要:

As the core building block of vision transformers, attention is a powerful tool to capture long-range dependency. However, such power comes at a cost: it incurs a huge computation burden and heavy memory footprint as pairwise token interaction across all spatial locations is computed. A series of works attempt to alleviate this problem by introducing handcrafted and content-agnostic sparsity into attention, such as restricting the attention operation to be inside local windows, axial stripes, or dilated windows. In contrast to these approaches, we propose a novel dynamic sparse attention via bi-level routing to enable a more flexible allocation of computations with content awareness. Specifically, for a query, irrelevant key-value pairs are first filtered out at a coarse region level, and then fine-grained token-to-token attention is applied in the union of remaining candidate regions (\ie, routed regions). We provide a simple yet effective implementation of the proposed bi-level routing attention, which utilizes the sparsity to save both computation and memory while involving only GPU-friendly dense matrix multiplications. Built with the proposed bi-level routing attention, a new general vision transformer, named BiFormer, is then presented. As BiFormer attends to a small subset of relevant tokens in a \textbf{query adaptive} manner without distraction from other irrelevant ones, it enjoys both good performance and high computational efficiency, especially in dense prediction tasks. Empirical results across several computer vision tasks such as image classification, object detection, and semantic segmentation verify the effectiveness of our design. Code is available at \url{https://github.com/rayleizhu/BiFormer}.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑