A Theoretical Understanding of Shallow Vision Transformers: Learning, Generalization, and Sample Complexity
Hongkang Li, Meng Wang, Sijia Liu, Pin-Yu Chen
摘要
Vision Transformers (ViTs) with self-attention modules have recently achieved great empirical success in many vision tasks. Due to non-convex interactions across layers, however, the theoretical learning and generalization analysis is mostly elusive. Based on a data model characterizing both label-relevant and label-irrelevant tokens, this paper provides the first theoretical analysis of training a shallow ViT, i.e., one self-attention layer followed by a two-layer perceptron, for a classification task. We characterize the sample complexity to achieve a zero generalization error. Our sample complexity bound is positively correlated with the inverse of the fraction of label-relevant tokens, the token noise level, and the initial model error. We also prove that a training process using stochastic gradient descent (SGD) leads to a sparse attention map, which is a formal verification of the general intuition about the success of attention. Moreover, this paper indicates that a proper token sparsification can improve the test performance by removing label-irrelevant and/or noisy tokens, including spurious correlations. Empirical experiments on synthetic data and CIFAR-10 dataset justify our theoretical results and generalize to deeper ViTs.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 67 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- In-context Convergence of Transformers 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- In-context Convergence of Transformers 引用了 Decision Transformer: Reinforcement Learning via Sequence Modeling
- In-context Convergence of Transformers 引用了 Language Models are Few-Shot Learners
- In-context Convergence of Transformers 引用了 Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformer
- On the Role of Attention in Prompt-tuning 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- On the Role of Attention in Prompt-tuning 引用了 Language Models are Few-Shot Learners
- An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale 引用了 Language Models are Few-Shot Learners
- Decision Transformer: Reinforcement Learning via Sequence Modeling 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Decision Transformer: Reinforcement Learning via Sequence Modeling 引用了 Language Models are Few-Shot Learners
- Swin Transformer: Hierarchical Vision Transformer using Shifted Windows 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- White-Box Transformers via Sparse Rate Reduction 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- White-Box Transformers via Sparse Rate Reduction 引用了 Language Models are Few-Shot Learners
- Twins: Revisiting the Design of Spatial Attention in Vision Transformers 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Twins: Revisiting the Design of Spatial Attention in Vision Transformers 引用了 Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Linear attention is (maybe) all you need (to understand Transformer optimization) 引用了 On the Role of Attention in Prompt-tuning
- Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformer 引用了 On the Role of Attention in Prompt-tuning
- Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformer 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformer 引用了 Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformer 引用了 Language Models are Few-Shot Learners
引用它的顶会 Paper67
- White-Box Transformers via Sparse Rate ReductionYaodong Yu, Sam Buchanan, Druv Pai, Tianzhe Chu 等NeurIPS 2023 · 149 次引用
- Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer TransformerYuandong Tian, Yiping Wang, Beidi Chen, Simon S. DuNeurIPS 2023 · 125 次引用
- In-context Convergence of TransformersYu Huang, Yuan Cheng, Yingbin LiangICML 2024 · 114 次引用
- Linear attention is (maybe) all you need (to understand Transformer optimization)Kwangjun Ahn, Xiang Cheng, Minhak Song, Chulhee Yun 等ICLR 2024 · 92 次引用
- On the Role of Attention in Prompt-tuningSamet Oymak, Ankit Singh Rawat, Mahdi Soltanolkotabi, Christos ThrampoulidisICML 2023 · 67 次引用
它引用的 Paper29
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah 等NeurIPS 2020 · 64,255 次引用
- Swin Transformer: Hierarchical Vision Transformer using Shifted WindowsZe Liu, Yutong Lin, Yue Cao, Han Hu 等ICCV 2021 · 31,683 次引用
- An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn 等ICLR 2021 · 21,477 次引用
- Decision Transformer: Reinforcement Learning via Sequence ModelingLili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee 等NeurIPS 2021 · 2,557 次引用
- Twins: Revisiting the Design of Spatial Attention in Vision TransformersXiangxiang Chu, Zhi Tian, Yuqing Wang, Bo Zhang 等NeurIPS 2021 · 1,388 次引用
相关 Paper
- Tokens-to-Token ViT: Training Vision Transformers from Scratch on ImageNetLi Yuan, Yunpeng Chen, Tao Wang, Weihao Yu 等ICCV 2021 · 2,462 次引用
- Always Skip AttentionYiping Ji, Hemanth Saratchandran, Peyman Moghadam, Simon LuceyICCV 2025
- SPOT: Sparsification with Attention Dynamics via Token Relevance in Vision TransformersOded Schlesinger, Amirhossein Farzam, J. Matias Di Martino, Guillermo SapiroCVPR Findings 2026
- You Only Need Less Attention at Each Stage in Vision TransformersShuoxi Zhang, Hanpeng Liu, Stephen Lin, Kun HeCVPR 2024 · 19 次引用
- Evo-ViT: Slow-Fast Token Evolution for Dynamic Vision TransformerYifan Xu, Zhijie Zhang, Mengdan Zhang, Kekai Sheng 等AAAI 2022 · 288 次引用
