
ViT Transformer: What a Vision Transformer Is and How It Reads an Image
A ViT transformer, or vision transformer, reads an image as a sequence of patches. Follow one dog photo from pixels to a label, and see what the model needs.
If you’ve used visual search in Google Lens or a multimodal chatbot that can “see” screenshots, there’s a good chance a Vision Transformer is doing the looking. Before 2020, almost every serious computer vision system was built on convolutional neural networks (CNNs) — architectures that scan images with small filters, much like a magnifying glass moved across a photograph. ViT threw that playbook out. Instead of scanning, it cuts the image into a grid of patches and lets every patch attend to every other patch through self-attention — the same mechanism that powers ChatGPT and Claude.
Take a 224×224 image and chop it into a 14×14 grid of 16×16-pixel patches. Flatten each patch into a vector, run it through a linear layer to get a patch embedding, and add a learned position embedding so the model knows which square came from where. According to Dosovitskiy et al., that’s the entire input preparation — an image becomes a sequence of tokens, and from that point the model is identical to a language Transformer.
Stacked on top of the patch embeddings is a standard Transformer encoder: alternating blocks of multi-head self-attention and feed-forward layers wrapped in residual connections and layer normalization. A special [CLS] token is prepended to the sequence, and its final representation is used for classification. With 16×16 patches, the setup produces 197 tokens (196 patches plus [CLS]) for a 224×224 image, and model sizes range from ViT-Base at around 86M parameters to ViT-Huge at around 630M. The original paper’s headline result: given enough pretraining data, this plain transformer matches or beats the best CNNs on image classification — no convolutions required.
Today, most people encounter ViT without knowing it. When you drag a screenshot into an open vision-language model such as Gemma 3 and ask what an error means, a ViT-style encoder (a 400M variant of SigLIP) processes the image before the language half generates an answer; GPT-4V, Claude 3 and Gemini do not name their vision encoder in their system card, model card or technical reports. The same is true when you search photos by description, auto-crop with a design tool, or let a photo app sort pictures by what they show.
The second place ViT shows up is as a pretrained feature extractor for teams building their own products. Instead of training from scratch — which demands millions of labeled images and weeks of GPU time — a team can download a ViT pretrained on a huge image collection with self-supervised learning and fine-tune it on their task. According to Meta AI Blog, DINOv3 scales self-supervised training to a 7-billion-parameter ViT trained on roughly 1.7 billion images, distilled into smaller ViT and ConvNeXt models.
If you need strong vision features but have a small labeled dataset, skip training from scratch. Start with a pretrained ViT like DINOv3 or SigLIP 2 as a frozen backbone and only fine-tune the task head — you’ll usually beat a from-scratch CNN with a fraction of the data.
Start with what a vision transformer is and how it reads an image — it establishes the patch-as-token substitution everything else here assumes. Patch embeddings, class tokens, and 2D positional encoding opens the hood on how those patches become a sequence a transformer can actually read, and ViT vs CNN is the counterweight: what a convolutional background does and doesn’t transfer, and why the architecture is data-hungry without it.
Once the mechanism is settled, the vision transformer PyTorch guide fine-tunes a small pretrained ViT on pet photos and checks it against a trivial baseline. For the market context behind backbone choice, the 2026 vision-backbone landscape shows that different backbones lead different tests rather than one winner taking all.
Three neighbours get folded into “vision transformer” in casual conversation, and each folding hides a different decision.
A vision transformer is not a convolutional network wearing a new name. A CNN slides a fixed filter across the image, so nearby pixels influence each other for free; a ViT patch carries no such assumption, which is exactly why the ViT vs CNN explainer treats data volume as a real cost, not a footnote. That the industry hasn’t abandoned convolution either — ConvNeXt, a pure convolutional network, still competes, and DINOv3 also ships ConvNeXt models — is the tell that neither design fully replaced the other.
Patch embedding is also not tokenization. Tokenizer architecture maps discrete text units to vocabulary IDs; a ViT patch embedding linearly projects continuous pixel values into a vector, with no vocabulary involved. Calling both “tokenizing” hides that a ViT has no fixed vocabulary to run out of — but it does have a fixed patch size that decides how much detail survives the cut.
And a vision transformer is usually just an encoder. Classification and dense-feature backbones stop at the encoder stack; generative tasks like image captioning bolt on a decoder, at which point the design becomes an instance of encoder-decoder architecture rather than a plain ViT. Confusing the two blames the vision backbone for failures that actually belong to the decoder generating the language.
| Scenario | Use | Avoid |
|---|---|---|
| Image classification with hundreds of millions of pretraining images | ✅ | |
| Tiny dataset with no pretrained backbone available | ❌ | |
| Multimodal model where text and images share one encoder stack | ✅ | |
| Real-time inference on older phone CPUs with tight latency budgets | ❌ | |
| Segmentation or depth estimation using pretrained ViT features | ✅ | |
| Ultra-low-latency video pipelines where convolution-friendly hardware still wins | ❌ |
Q: Which Vision Transformer article should I read first if I already know convolutional networks? A: Start with what a vision transformer is and how it reads an image — it maps the patch-as-token substitution onto what a CNN already taught you, so the components read next (class tokens, positional encoding) lands as elaboration, not a fresh start.
Q: Why does my fine-tuned Vision Transformer underperform the numbers on its model card? A: Often a mismatched recipe, not a bad backbone — normalisation numbers copied from another library shift every input value. The vision transformer PyTorch guide lists the mistakes that skew the score or crash the run.
Q: Do I need to understand class tokens and positional encoding just to use a pretrained Vision Transformer? A: Not to run inference — a checkpoint works behind one function call. The moment fine-tuning results look wrong, the components walkthrough is what tells you whether the class token, the positional encoding, or your own labels are the problem.
Part of the transformer and attention internals theme · closest neighbour: encoder-decoder architecture. New to this from a software background? Start with the story: Transformer Internals for Developers: What Maps, What Breaks.
These explainers show how a vision transformer cuts an image into small squares and lets them share information, what each part of its architecture does, and what a CNN assumes that a ViT has to learn from data.
Concepts covered

A ViT transformer, or vision transformer, reads an image as a sequence of patches. Follow one dog photo from pixels to a label, and see what the model needs.

The ViT architecture, part by part: patch embedding, class token, position embeddings, encoder blocks and head, followed through one dog photo, with the model sizes.

ViT vs CNN: what a CNN builds in and a ViT has to learn, why ViTs needed more data, how DeiT and ConvNeXt narrowed the gap, and how to choose.
The guide walks you through fine-tuning a small pretrained vision transformer in PyTorch on pet photos: train a new head first, then the whole model, and check both against a trivial baseline.

Fine-tune a vision transformer in PyTorch step by step: train a new head first, then the whole model, and check both against a trivial baseline.
New self-supervised and contrastive approaches are changing what multimodal systems can see. Track which architectures are winning benchmarks and why convolutional networks keep returning.
Models & benchmarks
Updated April 2026

Several open VLMs use SigLIP-family encoders; DINOv3 leads frozen dense probes.