Skip to content
Computer Vision

Vision Transformer (ViT) Explained: How an Image Becomes Patches

AIblogly Team October 12, 2026
Vision Transformer (ViT) Explained: How an Image Becomes Patches

In short: the Vision Transformer (ViT) is an image-recognition model that uses the same transformer design as ChatGPT-style language models. It cuts a picture into small square patches (16 × 16 pixels in the standard version) and treats each patch like a word in a sentence. The 2020 Google paper that introduced it found it needed a lot of training data to work well, but once pre-trained on very large image collections it matched or beat the best convolutional networks while using substantially less compute to train.

What is a Vision Transformer, in simple words?

A Vision Transformer reads an image the way a language model reads text: as a sequence of pieces. A language model splits a sentence into tokens; ViT splits an image into a grid of patches, turns each patch into a list of numbers, and feeds the list to a standard transformer.

Before ViT, image recognition was dominated by convolutional neural networks (CNNs), which slide small filters across an image; see computer vision explained. ViT showed the transformer, the design behind large language models, could classify images without any convolutional layers.

Who created the Vision Transformer?

It was introduced by Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov and colleagues at Google Research, in the paper An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale, submitted to arXiv on 22 October 2020 and published at the ICLR 2021 conference.

How does ViT turn an image into tokens?

Four steps turn a picture into a sequence a transformer can read.

  1. Cut the image into patches. The image is split into a grid of fixed-size squares. In the ViT-B/16 configuration each patch is 16 × 16 pixels, which is where the paper's title comes from. A 224 × 224 image becomes a 14 × 14 grid: 196 patches.
  2. Turn each patch into numbers. Each patch is flattened into one long list of pixel values and passed through a learned projection, giving one embedding per patch, the image equivalent of a word embedding.
  3. Add position. A learned position embedding is added to each patch, because the transformer itself has no idea where in the image a patch came from.
  4. Add a class token. One extra learnable token is put at the start of the sequence. After the transformer runs, the output at that position is used to decide the image's label.

Everything after that is a standard transformer encoder: layers of multi-head self-attention and feed-forward blocks, as described in Attention Is All You Need explained.

Why did ViT need so much training data?

A transformer starts with fewer built-in assumptions about images than a CNN, so it has to learn them from data. Convolutional networks assume that nearby pixels are related (locality) and that a pattern means the same thing wherever it appears (translation equivariance). The ViT paper calls these inductive biases that a transformer lacks.

The paper's results show data volume decided the outcome:

  • Mid-sized data. Trained on ImageNet alone without strong regularisation, ViT models landed a few percentage points below comparable ResNets (a leading CNN design).
  • Large data. Pre-trained on ImageNet-21k (about 14 million images) or Google's internal JFT-300M (about 300 million), they matched or exceeded state-of-the-art CNNs when transferred to benchmarks including ImageNet, CIFAR-100 and the VTAB suite while, in the authors' words, "requiring substantially fewer computational resources to train".

What sizes does ViT come in?

The paper defined three sizes, borrowing the names Base, Large and Huge from the language model BERT.

VariantLayersHidden sizeAttention headsParameters
ViT-Base127681286M
ViT-Large241,02416307M
ViT-Huge321,28016632M

The number after the slash is the patch size: ViT-L/16 uses 16 × 16 patches and ViT-H/14 uses 14 × 14. Smaller patches mean more tokens per image and more compute, because the cost of self-attention grows with the square of the sequence length.

ViT vs CNN: what is the difference?

CNNVision Transformer
How it reads an imageSlides small filters across itSplits it into patches, compares every patch with every other
Built-in assumptionsLocality and translation equivarianceFew; learned from data
Data neededWorks well on mid-sized datasetsNeeded large pre-training data in the 2020 paper

Where are Vision Transformers used today?

The patch idea outlived the original image classifier. The image encoder in Meta's Segment Anything is a ViT, and the vision side of many multimodal language models also starts by turning an image into patch tokens. That is why vendors of models with image input describe image cost in tokens rather than pixels; see tokens and context windows explained. Each model's input types are listed on its page in our AI models directory.

Words to know

  • Vision Transformer (ViT): a transformer that reads an image as a sequence of patches.
  • Patch: a small square piece of an image, such as 16 × 16 pixels.
  • Embedding: a list of numbers representing a token or patch.
  • Position embedding: numbers added so the model knows where each patch sits.
  • Class token: an extra token whose output is used for the final label.
  • CNN: convolutional neural network, the earlier standard for vision.
  • Inductive bias: an assumption built into a model's design.
  • Pre-training: first training on a large dataset before adapting to specific tasks.

Frequently asked questions

What is a Vision Transformer?+

A Vision Transformer (ViT) is an image model that splits a picture into small square patches, turns each into a list of numbers and processes them with a standard transformer, the same design used by large language models. It was introduced by Google Research in 2020.

Why is the ViT paper called "An Image is Worth 16x16 Words"?+

Because ViT cuts an image into 16 × 16-pixel patches and treats each patch the way a language model treats a word. A 224 × 224 image becomes 196 such patches.

Is ViT better than a CNN?+

It depends on the data. In the 2020 paper, ViT trained only on ImageNet scored a few points below comparable ResNets, but pre-trained on 14 million to 300 million images it matched or exceeded state-of-the-art CNNs with substantially less training compute.

How many parameters does ViT have?+

The paper's three sizes are ViT-Base with 86 million parameters, ViT-Large with 307 million and ViT-Huge with 632 million.

What is the class token in ViT?+

The class token is an extra learnable token placed at the start of the patch sequence. After the transformer processes the image, the output at that position is passed to a classifier to produce the image's label.

Where is ViT used?+

Vision Transformers are used as image encoders in many systems, including Meta's Segment Anything model, and the vision parts of many multimodal language models also turn images into patch tokens in the same way.

Enjoyed this? Get more in your inbox.

Up to ten of the week's AI news stories, by email once a week.