an image is a grid of patches — nothing else changes
image (224x224x3)
sliced into a 14 × 14 grid of 16-pixel patches
flatten each patch → embed
CLS
p_1
p_2
p_3
p_4
...
p_196
sequence of 197 d-dim tokens (CLS + 196 patches)
transformer encoder (same as BERT)
block 1: self-attn + MLP
block 2: self-attn + MLP
× 12 for ViT-Base, × 24 for ViT-Large
197 × d_model hidden states
take CLS → Linear(d, num_classes)
softmax → class
variants
DeiT (2021): distill from CNN
Swin: shifted-window local attn
DINOv2: self-supervised
SigLIP: + text encoder
SAM 3: + mask decoder
scale table
ViT-B/16 86M
ViT-L/16 304M
ViT-H/14 632M
ViT-22B 22,000M
data hunger: ≥ImageNet-21k
needed to beat ResNet
one architecture, many modalities — patchify the input and attention does the rest.