AI Space

Remember ViT

Full name: Vision Transformer

Memory aid: Vision is processed by a Transformer.

Patch construction, pretraining, and evaluation affect visual performance.

Study area: AI & machine learning · Batch 9

Relevant study for: Azure AI Fundamentals AI-901 · Azure AI Apps and Agents Developer AI-103 · Azure AI Fundamentals (retired) AI-900 · Azure AI Engineer (retired) AI-102

Practice with exam flashcards →

Data / Knowledge library

Vision Transformer (ViT)

image patches processed with transformer attention

2020-10-22 · Original preprint; ICLR 2021

Why learn Vision Transformer (ViT)?

ViT embeds image patches as tokens, adds positional information, and processes them with Transformer blocks. Self-attention relates patches across the image. CNNs provide a useful comparison because their local filters encode different architectural assumptions. Neither approach is universally superior: compare accuracy, pretraining data, compute, and latency on the same task.

The problem it solves

Provides an attention-based way to learn image representations. Standard global self-attention models relationships between all patch tokens; its pairwise attention computation grows quadratically with sequence length. Smaller patches or larger images increase the token count.

Where it came from

Dosovitskiy and colleagues introduced ViT in an October 2020 preprint, subsequently published at ICLR 2021. The work applied a Transformer to sequences of image patches and demonstrated strong image-recognition results after large-scale pretraining. ViT is an architecture family, not a product with one current release.

Build your understanding

Work through these exercises in order. Try the task before opening a reference.

  1. Split a 224x224 image into non-overlapping 16x16 patches and count the tokens.
  2. Trace shapes from flattened RGB patches through a learned projection.
  3. Run a pretrained ViT using the preprocessing specified for its weights.
  4. Compare a CNN and ViT on the same held-out image split.
  5. Measure the accuracy, memory, and latency impact of changing image resolution.

More ways to practice

Level 1

Count patch tokens

Calculate tokens for 224x224 images using 16x16 patches. Explain whether your count includes a class token.

Level 2

Trace patch embeddings

Calculate flattened RGB patch dimensions and the output shape after projection to an embedding width of 192.

Level 3

Pretrained inference

Load a pretrained ViT, use its documented preprocessing, and record predictions on a small labeled image set.

Level 4

Compare architectures

Compare a CNN and ViT with the same data split; disclose different pretraining datasets and compute budgets.

Level 5

Resolution tradeoffs

Measure accuracy, peak memory, and latency at supported resolutions; document any positional-embedding adaptation.

Documentation and sources

Catalog research notes

Connect the ideas

Alternatives

CNN (Convolutional Neural Network)

Explore next

PythonPyTorchTensorFlowMultimodal ModelsHugging Face Transformers

Real World Example

Illustrative business scenario · AI-generated from linked documentation · Not a measured customer case study

Automated Quality Control for Precision Manufacturing

High-precision electronics manufacturers requiring automated visual inspection of circuit boards.

The business problem

Traditional convolutional neural networks struggle with long-range dependencies across complex board layouts, leading to high false-rejection rates for subtle defects.

How this topic solves it

Vision Transformer (ViT) processes the image as a sequence of patches, allowing the self-attention mechanism to model global relationships between distant components on the board, which improves defect detection accuracy.

  1. Divide high-resolution circuit board images into fixed-size square patches.
  2. Flatten patches into a sequence and prepend a learnable classification token.
  3. Apply positional embeddings to preserve spatial information of the patches.
  4. Pass the sequence through multiple transformer encoder layers to compute global attention.
  5. Use the final classification token to output the defect status of the board.
ViT Processing Pipeline · Process flow

The flow from raw image input to final classification output.

Input Image

Raw circuit board capture

Patching

Splitting image into 16x16 segments

Transformer Encoder

Self-attention processing

Classification

Defect vs Pass decision

  • Input Image → segmentation → Patching
  • Patching → sequence input → Transformer Encoder
  • Transformer Encoder → token output → Classification

Expected business outcome

Improved consistency in defect identification across diverse board designs without requiring manual feature engineering.

Limitations and checks

ViT models require large datasets for pre-training to achieve high performance; check for overfitting by monitoring validation loss on smaller, domain-specific datasets.

Sources

Generated 2026-10-18 with gemini-3.1-flash-lite. Your assessment includes two questions about this example.

Catalog source: technology-maxxing. This page reproduces the existing catalog’s learning material and source links.