# An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale

> Treats an image as a sequence of 16×16 patches and feeds it to a standard Transformer. Pretrained on 300M images, ViT-H/14 reaches 88.55% on ImageNet with about 4× less pretraining compute than BiT.

- arXiv: https://arxiv.org/abs/2010.11929
- Authors: Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, Neil Houlsby
- Published: 2020-10-22
- Topic: Vision
- Visual carousel: https://instaxiv.com/p/2010.11929
- Explanation by InstaXiv, a secondary educational summary. Cite the original paper for exact results. InstaXiv is not affiliated with or endorsed by arXiv or Cornell University.

## Cut an image into 16×16 patches and a plain Transformer beats CNNs

**88.55%** ImageNet top-1 with ViT-H/14

## Patches become tokens; the rest is a standard encoder

![Figure 1](https://cdn.instaxiv.com/figures/2010.11929/figure1.webp)

Split the image into fixed patches, flatten and project each, add position embeddings and a learnable class token, then feed the sequence to an unmodified Transformer encoder. (Figure 1)

## Vision had been built around convolutions

**CNNs:** Locality and translation equivariance are hard-coded into every layer. These priors help with little data but constrain what the model can learn.

**Vision Transformer:** Almost no image-specific bias: global attention from the first layer. With enough pretraining data, learned patterns beat the built-in priors.

Large-scale training trumps inductive bias.

## From pixels to a class label

1. **Patchify**: The image is cut into a grid of 16×16-pixel patches, each flattened and linearly projected to a vector.
2. **Add position and class token**: Learned position embeddings mark where each patch came from; a prepended class token gathers the summary.
3. **Encode and classify**: Standard Transformer layers process the sequence; an MLP head reads the final class token.

## Better accuracy for less pretraining compute

| Method | ImageNet top-1 | TPUv3-core-days |
| --- | --- | --- |
| BiT-L (ResNet) | 87.54 | 9.9k |
| Noisy Student | 88.4 | 12.3k |
| ViT-L/16 | 87.76 | 0.68k |
| **ViT-H/14 (4× less compute)** | **88.55** | **2.5k** |

_All pretrained on JFT-300M. Compute counts TPUv3 cores times days of pretraining._

## Data hungry by design

- **Weak on small datasets**: Pretrained only on ImageNet-1k, ViT trails comparable ResNets; it needs 14M to 300M images to shine.
- **Classification only**: Detection and segmentation were left for future work.
- **Self-supervision lagged**: Masked patch prediction pretraining trailed supervised pretraining by 4 points on ImageNet.

Best used when: You can pretrain on very large image datasets or start from public ViT checkpoints.

## Key takeaways

- A standard Transformer on image patches matches or beats top CNNs when pretrained at scale.
- With enough data, learned attention outperforms the hard-coded locality of convolutions.
- ViT is the image encoder inside CLIP, most VLMs and diffusion transformers.

## Links

- arXiv: https://arxiv.org/abs/2010.11929
- PDF: https://arxiv.org/pdf/2010.11929
- Code: https://github.com/google-research/vision_transformer

## Citation

```bibtex
@article{dosovitskiy2020an,
  title   = {An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale},
  author  = {Dosovitskiy, Alexey and Beyer, Lucas and Kolesnikov, Alexander and Weissenborn, Dirk and Zhai, Xiaohua and Unterthiner, Thomas and Dehghani, Mostafa and Minderer, Matthias and Heigold, Georg and Gelly, Sylvain and Uszkoreit, Jakob and Houlsby, Neil},
  journal = {arXiv preprint arXiv:2010.11929},
  year    = {2020},
  url     = {https://arxiv.org/abs/2010.11929}
}
```
