All models

BiFormer

A vision transformer whose bi-level routing attention attends to a small, content-dependent subset of tokens.

Image classification · 980 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (32 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
13.1M
Operations
980
Framework
PyTorch
Recurrent
No
Published
CVPR 2023
Cited by
1,259 (as of 27 October 2026)
Authors
Lei Zhu, Xinjiang Wang, Zhanghan Ke and others
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m14934
Graph hash
e50997ec1c3a1c55dad90d4173aaa8806ad215b2e3598b6382060f4fc3a85dc2
Skeleton hash
2a7e8beaa64cadbd2fe88a27ec72872e9b325e5aa198bccb65aa16d83b7e6e03
Architecture hash
8fc656d878749c83c5307d01f2790c192895e809b956d84c5ced0a928e1b8ae1
Diagram SHA-256
a661931d2c42d45119c54c0f9f23e03ecb9e30aa22242b5fe76866589c30491a
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

BiFormer is a general vision transformer built on bi-level routing attention. That attention is sparse and dynamic, so computation is allocated according to the content of the image instead of following a fixed pattern. The paper starts from the cost of ordinary attention, which computes pairwise token interaction across all spatial locations and so carries a heavy computation and memory load. Earlier work reduced that cost with handcrafted, content-agnostic sparsity, such as restricting attention to local windows, axial stripes or dilated windows.

Bi-level routing attention works in two steps: for each query, irrelevant key-value pairs are first filtered out at a coarse region level, and fine-grained token-to-token attention is then applied in the union of the regions that remain. The authors' implementation uses that sparsity to save computation and memory while involving only dense matrix multiplications that suit GPUs. The paper evaluates the design on image classification, object detection and semantic segmentation.

The authors' repository lists BiFormer-T, trained on ImageNet-1K at 224x224 resolution, at 81.4 top-1 accuracy. It also notes that the released object detection code achieves significantly better results than the paper reported, due to a bug fix. The repository keeps a legacy implementation of the attention so that previously released checkpoints remain compatible.

Key idea. The paper proposes bi-level routing attention, which filters out irrelevant key-value pairs at a coarse region level before applying token-to-token attention in the remaining regions.

  • BiFormer
  • bi-level routing attention
  • BRA
  • vision transformer
  • dynamic sparse attention
  • sparse attention
  • image classification
  • BiFormer-T

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{zhu2023biformervisiontransformerbilevel,
      title={BiFormer: Vision Transformer with Bi-Level Routing Attention}, 
      author={Lei Zhu and Xinjiang Wang and Zhanghan Ke and Wayne Zhang and Rynson Lau},
      year={2023},
      eprint={2303.08810},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2303.08810}, 
}