Vision transformer (ViT)

A vision transformer is a neural network that applies the transformer architecture to images by cutting each image into small patches and treating the patches like words in a sentence.

Transformers were built for text, which arrives as a sequence of tokens. A vision transformer turns an image into a sequence too. It cuts the image into fixed-size square patches, 16 by 16 pixels in the original design, flattens each patch and projects it into an embedding vector. Position embeddings are added so the model knows where each patch came from, and a special classification token, borrowed from the BERT language model, is placed at the front. The sequence then passes through a standard transformer encoder, and the classification token's output is used to label the image.

The numbers are easy to work out. A 224 by 224 pixel image cut into 16 by 16 patches gives a 14 by 14 grid, or 196 patches, so the model sees a 196-token sentence. Through self-attention any patch can draw on any other, so a patch showing a dog's ear can be related directly to one showing its tail on the far side of the frame.

The architecture was introduced in An Image is Worth 16x16 Words by Alexey Dosovitskiy and colleagues, posted in October 2020 and presented at the ICLR conference. Its claim was that convolutional neural networks, the standard for image recognition for years, were not required: pretrained on large datasets and then transferred to benchmarks such as ImageNet and CIFAR-100, a plain transformer matched leading convolutional networks while needing substantially less computation to train.

The difference lies in built-in assumptions. Convolutional networks apply the same small filters across the whole image, a design that bakes in locality and makes them data-efficient. Vision transformers assume far less, so they need more training data, but they keep improving on larger datasets where convolutional networks level off. They are also more sensitive to training settings, and adding a few small convolutions before the transformer improves stability.

Vision transformers now sit inside much of modern computer vision. Descendants include the Swin Transformer, published in 2021, which set records on object detection benchmarks, and the DINO line of self-supervised models, with DINOv3 released in August 2025. Vision transformers are also used for segmentation, anomaly detection and autonomous driving, and the same backbone underpins diffusion transformers for image generation. One practical consequence: because an image becomes a sequence of patch tokens, higher-resolution images mean more tokens and more computation.

Common questions

What is a vision transformer?

A vision transformer, or ViT, is an image model built on the transformer architecture used for language. It splits an image into small patches, treats each patch as a token and uses self-attention to relate the patches to each other. It was introduced by researchers in October 2020.

What is the difference between a vision transformer and a CNN?

A convolutional neural network scans an image with small filters, which builds in the assumption that nearby pixels matter most and makes it efficient with limited data. A vision transformer lets every patch attend to every other from the first layer, which needs more training data but scales well to very large datasets. Many current systems combine ideas from both.

Why do vision transformers use 16x16 patches?

The original paper used 16 by 16 pixel patches, which turns a typical image into a few hundred tokens, a manageable sequence length for attention. Smaller patches capture finer detail but create many more tokens, and attention cost grows with the square of the token count.

Where are vision transformers used?

They are used for image classification, object detection, segmentation, anomaly detection and autonomous driving. Self-supervised vision transformers such as DINOv2 also supply image features to larger systems, including the OpenVLA robot model, and transformer backbones appear in image generation models.

Finding more

Search for "vision transformer", "ViT vs CNN", "Swin Transformer" or "DINOv2" to follow the main lines of work. The original paper on arXiv is readable, and model cards and documentation from developers explain specific versions. Benchmark comparisons between architectures depend heavily on training data and compute, so check whether a comparison is like for like.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.