CvT: Introducing Convolutions to Vision Transformers
Haiping WuBin XiaoNoel CodellaMengchen LiuXiyang DaiLu YuanLei Zhang
Presents CvT, a hybrid architecture that incorporates convolutional token embeddings and projections into Vision Transformers to achieve superior ImageNet accuracy with fewer parameters and FLOPs while eliminating the need for positional encodings.
Vision transformers have shown strong results on image classification when trained on massive datasets, but they lag behind convolutional neural networks on smaller datasets because they lack built-in properties such as shift and scale invariance. This gap matters now because many practical vision applications still rely on datasets of moderate size, and models that combine high accuracy with low computational cost are needed for deployment.
The article set out to test whether strategically adding convolutions to the vision transformer architecture could deliver the accuracy and efficiency advantages of both designs. Researchers created the Convolutional vision Transformer (CvT) and evaluated it through large-scale image classification experiments on ImageNet-1k and ImageNet-22k, plus transfer to several downstream datasets.
The approach uses a multi-stage hierarchical structure. Each stage begins with a convolutional token embedding that overlaps patches and reduces spatial resolution while increasing feature depth, followed by convolutional transformer blocks that replace the standard linear projections for attention with depth-wise separable convolutions. Experiments compared multiple CvT variants against ResNets, prior vision transformers, and concurrent transformer models, measuring top-1 accuracy, parameter count, and FLOPs.
CvT-13 reached 81.6 percent top-1 accuracy on ImageNet-1k with 20 million parameters and 4.5 gigaFLOPs, outperforming larger ResNet-152 and several recent transformer models while using fewer resources. CvT-21 improved this to 82.5 percent. When pretrained on ImageNet-22k and fine-tuned, the wider CvT-W24 model achieved 87.7 percent top-1 accuracy. Removing positional encodings caused no accuracy drop, and the models transferred strongly to CIFAR, Oxford Pets, and Flowers datasets.
These results show that the hybrid design closes much of the performance gap between transformers and convolutional networks while remaining lightweight and simpler to adapt to variable image resolutions. The efficiency gains and removal of positional encodings reduce both training and inference costs and broaden applicability to tasks that require flexible input sizes.
Further gains appear possible by applying neural architecture search to stride and expansion ratios, and by testing the architecture on dense prediction tasks such as detection and segmentation. Additional validation on even larger or more diverse datasets would strengthen before widespread deployment.
The main limitation is that all primary results come from ImageNet-scale classification; behavior on very different domains or extremely high-resolution inputs remains untested. Confidence in the reported accuracy and efficiency improvements is high because the experiments include extensive ablations, multiple model scales, and direct comparisons on public benchmarks.
- Paper: An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale, Alexey Dosovitskiy et al. (2021). This foundational paper introduced the Vision Transformer architecture, establishing the patch-based self-attention paradigm and highlighting the inductive bias limitations that CvT resolves with convolutions.
- Paper: Training data-efficient image transformers & distillation through attention, Hugo Touvron et al. (2021). This work developed data-efficient training recipes and distillation baselines for Vision Transformers on ImageNet-1k, serving as the benchmark and training foundation upon which CvT builds.
- Paper: On the Relationship between Self-Attention and Convolutional Layers, Jean-Baptiste Cordonnier et al. (2020). This paper analyzes the mathematical and functional relationship between self-attention and convolutional layers, providing key theoretical motivation for integrating convolutional operations into transformer blocks.
- Paper: MobileNetV2: Inverted Residuals and Linear Bottlenecks, Mark Sandler et al. (2018). This work pioneered the efficient depth-wise separable convolution designs that CvT adopts to replace standard linear projections in self-attention.
- Paper: A ConvNet for the 2020s, Zhuang Liu et al. (2022). This work explores the reverse trajectory of hybrid transformer-convolution designs by modernizing pure ConvNets with architectural principles drawn from Vision Transformers.
- Paper: MobileViT: Light-weight, General-purpose, and Mobile-friendly Vision Transformer, Sachin Mehta et al. (2021). This paper builds on the synergy between convolutions and transformers to create lightweight, mobile-friendly hybrid vision backbones.
- Paper: Swin Transformer V2: Scaling Up Capacity and Resolution, Ze Liu et al. (2022). This work extends hierarchical vision transformer architectures to extreme parameter scales and ultra-high input resolutions.
- Paper: Visual Prompt Tuning, Menglin Jia et al. (2022). This paper introduces parameter-efficient visual prompt tuning for vision transformer architectures, eliminating the need for expensive full fine-tuning across downstream vision tasks.
