How Do Vision Transformers Work?
Abstract
The success of multi-head self-attentions (MSAs) for computer vision is now indisputable. However, little is known about how MSAs work. We present fundamental explanations to help better understand the nature of MSAs. In particular, we demonstrate the following properties of MSAs and Vision Transformers (ViTs): (1) MSAs improve not only accuracy but also generalization by flattening the loss landscapes. Such improvement is primarily attributable to their data specificity, not long-range dependency. On the other hand, ViTs suffer from non-convex losses. Large datasets and loss landscape smoothing methods alleviate this problem; (2) MSAs and Convs exhibit opposite behaviors. For example, MSAs are low-pass filters, but Convs are high-pass filters. Therefore, MSAs and Convs are complementary; (3) Multi-stage neural networks behave like a series connection of small individual models. In addition, MSAs at the end of a stage play a key role in prediction. Based on these insights, we propose AlterNet, a model in which Conv blocks at the end of a stage are replaced with MSA blocks. AlterNet outperforms CNNs not only in large data regimes but also in small data regimes. The code is available at https://github.com/xxxnell/how-do-vits-work.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
152 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Vision Transformer Adapter for Dense Predictions cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Vision Transformer Adapter for Dense Predictions cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Vision Transformer Adapter for Dense Predictions cites Training data-efficient image transformers & distillation through attention
- MetaFormer is Actually What You Need for Vision cites CutMix: Regularization Strategy to Train Strong Classifiers With Localizable Features
- MetaFormer is Actually What You Need for Vision cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- MetaFormer is Actually What You Need for Vision cites RandAugment: Practical Automated Data Augmentation with a Reduced Search Space
- MetaFormer is Actually What You Need for Vision cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- MetaFormer is Actually What You Need for Vision cites Training data-efficient image transformers & distillation through attention
- Swin Transformer: Hierarchical Vision Transformer using Shifted Windows cites CutMix: Regularization Strategy to Train Strong Classifiers With Localizable Features
- Swin Transformer: Hierarchical Vision Transformer using Shifted Windows cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Swin Transformer: Hierarchical Vision Transformer using Shifted Windows cites RandAugment: Practical Automated Data Augmentation with a Reduced Search Space
- Swin Transformer: Hierarchical Vision Transformer using Shifted Windows cites Training data-efficient image transformers & distillation through attention
- Graph Inductive Biases in Transformers without Message Passing cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Graph Inductive Biases in Transformers without Message Passing cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- MB-TaylorFormer: Multi-branch Efficient Transformer Expanded by Taylor Formula for Image Dehazing cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- MB-TaylorFormer: Multi-branch Efficient Transformer Expanded by Taylor Formula for Image Dehazing cites Training data-efficient image transformers & distillation through attention
- Training data-efficient image transformers & distillation through attention cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Fast Vision Transformers with HiLo Attention cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Fast Vision Transformers with HiLo Attention cites Training data-efficient image transformers & distillation through attention
Cited by top-tier papers152
- MetaFormer is Actually What You Need for VisionWeihao Yu, Mi Luo, Pan Zhou, Chenyang Si et al.CVPR 2022 · 1,114 citations
- Fast Vision Transformers with HiLo AttentionZizheng Pan, Jianfei Cai, Bohan ZhuangNeurIPS 2022 · 321 citations
- MB-TaylorFormer: Multi-branch Efficient Transformer Expanded by Taylor Formula for Image DehazingYuwei Qiu, Kaihao Zhang, Chenxi Wang, Wenhan Luo et al.ICCV 2023 · 224 citations
- Vision Transformer Adapter for Dense PredictionsZhe Chen, Yuchen Duan, Wenhai Wang, Junjun He et al.ICLR 2023 · 204 citations
- Graph Inductive Biases in Transformers without Message PassingLiheng Ma, Chen Lin, Derek Lim, Adriana Romero-Soriano et al.ICML 2023 · 185 citations
Builds on36
- Swin Transformer: Hierarchical Vision Transformer using Shifted WindowsZe Liu, Yutong Lin, Yue Cao, Han Hu et al.ICCV 2021 · 31,683 citations
- An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn et al.ICLR 2021 · 21,477 citations
- Training data-efficient image transformers & distillation through attentionHugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa et al.ICML 2021 · 8,974 citations
- CutMix: Regularization Strategy to Train Strong Classifiers With Localizable FeaturesSangdoo Yun, Dongyoon Han, Sanghyuk Chun, Seong Joon Oh et al.ICCV 2019 · 5,843 citations
- RandAugment: Practical Automated Data Augmentation with a Reduced Search SpaceEkin Dogus Cubuk, Barret Zoph, Jonathon Shlens, Quoc LeNeurIPS 2020 · 4,453 citations
Related papers
- Revisiting Vision Transformer from the View of Path EnsembleShuning Chang, Pichao Wang, Hao Luo, Fan Wang et al.ICCV 2023 · 8 citations
- Do Vision Transformers See Like Convolutional Neural Networks?Maithra Raghu, Thomas Unterthiner, Simon Kornblith, Chiyuan Zhang et al.NeurIPS 2021 · 1,553 citations
- Rethinking Spatial Dimensions of Vision TransformersByeongho Heo, Sangdoo Yun, Dongyoon Han, Sanghyuk Chun et al.ICCV 2021 · 733 citations
- Scratching Visual Transformer's Back with Uniform AttentionNam Hyeon-Woo, Kim Yu-Ji, Byeongho Heo, Dongyoon Han et al.ICCV 2023 · 39 citations
- Model Editing for Vision TransformersXinyi Huang, Kangfei Zhao, Long-Kai HuangNeurIPS 2025 · 1 citation
