Abstract
With the rise of Transformers as the standard for language processing, and their advancements in computer vision, there has been a corresponding growth in parameter size and amounts of training data. Many have come to believe that because of this, transformers are not suitable for small sets of data. This trend leads to concerns such as: limited availability of data in certain scientific domains and the exclusion of those with limited resource from research in the field. In this paper, we aim to present an approach for small-scale learning by introducing Compact Transformers. We show for the first time that with the right size, convolutional tokenization, transformers can avoid overfitting and outperform state-of-the-art CNNs on small datasets. Our models are flexible in terms of model size, and can have as little as 0.28M parameters while achieving competitive results. Our best model can reach 98% accuracy when training from scratch on CIFAR-10 with only 3.7M parameters, which is a significant improvement in data-efficiency over previous Transformer based models being over 10x smaller than other transformers and is 15% the size of ResNet50 while achieving similar performance. CCT also outperforms many modern CNN based approaches, and even some recent NAS-based approaches. Additionally, we obtain a new SOTA result on Flowers-102 with 99.76% top-1 accuracy, and improve upon the existing baseline on ImageNet (82.71% accuracy with 29% as many parameters as ViT), as well as NLP tasks. Our simple and compact design for transformers makes them more feasible to study for those with limited computing resources and/or dealing with small datasets, while extending existing research efforts in data efficient transformers.
Introduction
Since the debut of the Vision Transformer (ViT), the prevailing wisdom has been that Transformers are inherently "data-hungry." Unlike Convolutional Neural Networks (CNNs), standard Transformers lack inductive biases—built-in assumptions like locality (pixels near each other are related) and translation invariance. To compensate for this, standard models typically require pre-training on massive datasets like ImageNet-21k or JFT-300M.
This "big data" requirement creates a significant barrier for researchers with limited computational resources or those working in specialized fields, such as medical imaging or rare-species botany, where large datasets simply do not exist. This paper challenges the notion that Transformers are unsuitable for small-scale data, presenting an architectural approach that allows Transformers to be both compact and highly effective without massive pre-training.
Methodology
The authors introduce three progressively more sophisticated models designed to bridge the gap between Transformers and small-scale datasets:
- ViT-Lite: A scaled-down version of the original ViT, optimized with smaller patch sizes and fewer layers/heads to better suit smaller images.
- Compact Vision Transformer (CVT): This model replaces the traditional
[class]token with a novel Sequence Pooling (SeqPool) strategy. - Compact Convolutional Transformer (CCT): The most advanced variant, which replaces the simple patch-and-embed step with a Convolutional Tokenizer.
Architectural Innovations
The success of Compact Transformers hinges on two primary innovations: Sequence Pooling and Convolutional Tokenization.
Sequence Pooling (SeqPool)
Standard Transformers rely on a single dummy [class] token to aggregate information for classification. The authors found this to be a bottleneck. Their SeqPool method instead applies a learnable linear layer to the entire sequence of tokens, weighting them by importance before pooling them into a single classification vector. This preserves more relevant information from across the image.
Convolutional Tokenization
Adding a small convolutional component for tokenization allows the Transformer to "see" local structures immediately. This effectively injects the spatial awareness (inductive bias) that standard ViTs must learn through massive amounts of data. By using a few convolutional layers at the start, the model can handle overlapping patches, making it much more robust and data-efficient.
Experimental Results
The models were evaluated across a diverse range of benchmarks, from low-resolution datasets like CIFAR-10 to high-resolution benchmarks like Oxford Flowers-102 and ImageNet-1k.
- CIFAR-10: CCT achieved 98.00% accuracy with only 3.7M parameters. This is 10x smaller than many other Transformer models and only 15% the size of a ResNet50, yet it achieves similar or better performance.
- Flowers-102: The authors set a new State-of-the-Art (SOTA) result of 99.76% top-1 accuracy.
- ImageNet: CCT reached 82.71% accuracy using only 29% of the parameters required by a standard ViT.
- Extreme Compactness: Their smallest model, with only 0.28M parameters, still achieved competitive results on CIFAR-10 (89.75%).
Conclusion
Compact Transformers demonstrate that the "data-hungry" nature of Transformers is not an inherent limitation but a consequence of specific architectural choices. By introducing convolutional tokenization and sequence pooling, CCT models can outperform state-of-the-art CNNs on small datasets while remaining highly parameter-efficient. This research democratizes Transformer research, making it accessible to those with limited computing resources and extending the utility of Transformers to data-scarce domains.
Summary updated