[Paper Review] BiFormer: Vision Transformer with Bi-Level Routing Attention
BiFormer introduces bi-level routing attention (BRA), a dynamic, query-aware sparse attention mechanism that filters region-level relevance before performing token-level attention, yielding improved accuracy and efficiency across vision tasks. It achieves strong ImageNet results with lower FLOPs and transfers well to detection and segmentation.
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 extbf{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}.
Motivation & Objective
- Motivate the need for efficient, long-range modeling in vision transformers without sacrificing accuracy.
- Propose a dynamic, query-aware sparsity mechanism (BRA) to selectively attend to relevant regions and tokens.
- Develop BiFormer, a backbone built with BRA for image classification, detection, and segmentation.
- Provide complexity analysis showing BRA achieves lower-than-vanilla attention complexity under proper region partitioning.
- Demonstrate state-of-the-art or competitive performance on ImageNet-1K, COCO, and ADE20K under comparable FLOPs.
Proposed method
- Introduce Bi-Level Routing Attention (BRA) that first builds a region-level affinity graph and retains top-k connections per region.
- Compute region-level queries/keys by averaging per-region token representations.
- Gather corresponding key/value tokens from the routed regions and perform token-to-token attention on this sparse-but-gathered set.
- Add a local context enhancement term via depthwise convolution.
Experimental results
Research questions
- RQ1Can region-level routing combined with token-level attention yield comparable or better accuracy with fewer computations than vanilla or static sparse attention?
- RQ2How does BRA scale with input resolution and region partitioning, and what is the resulting FLOPs/accuracy trade-off?
- RQ3Does BiFormer improve performance on classification, detection, and segmentation tasks under similar computational budgets?
- RQ4What qualitative evidence shows that BRA attends to semantically related regions for different queries?
Key findings
- BRA achieves O((HW)^(4/3)) complexity with proper region partitioning, reducing computations relative to vanilla attention.
- BiFormer with BRA attains 81.4% top-1 on ImageNet-1K with ~2.2 GFLOPs (BiFormer-T), and 83.8% with ~4.5 GFLOPs (BiFormer-S), outperforming several baselines at similar budgets.
- On COCO, BiFormer-S/BIFormer-B provide competitive mAP and notably better small-object performance in RetinaNet/Mask R-CNN pipelines.
- On ADE20K, BiFormer-S/B outperform several sparse-attention baselines under Semantic FPN and UperNet, with mIoU gains.
- Ablation confirms BRA outperforms other sparse attention mechanisms in both classification and segmentation tasks.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.