A convolution kernel only ever looks at its immediate neighborhood — reaching a patch on the far side of an image takes as many stacked layers as it takes hops to get there. What if a single layer could look at every patch at once, the same way self-attention already looks at every word in a sentence?
A 3x3 grid of image patches, with a bright diagonal running through it. Pick a query patch and watch which other patches it attends to — not just its neighbors, but any patch anywhere in the grid, scored purely by how similar its content is.
A Vision Transformer (ViT) cuts an image into fixed-size patches, embeds each one, adds a position embedding, and feeds the resulting sequence into the exact same self-attention block from Part IV — no convolution anywhere:
- — the -th fixed-size image patch, treated like a token in a sequence.
- — the learned vector representation of patch .
- — a position embedding added to patch , since self-attention has no inherent sense of spatial order.
- A conv kernel's reach grows one hop at a time
A convolution kernel's receptive field grows by one step of Chebyshev distance per layer — reaching a patch steps away takes at least stacked layers.
- Self-attention reaches everywhere in one layer
Self-attention has no such restriction: every patch can attend to every other patch in a single layer, regardless of how far apart they sit in the image.
Top-left's attention lands overwhelmingly on the two other bright patches — including bottom-right, which sits on the opposite corner of the grid. A single 3x3 convolution centered on top-left couldn't reach bottom-right at all; self-attention reaches it in one hop, using nothing but content similarity.
A 3x3 grid, bright diagonal (top-left, center, bottom-right), query = top-left:
- Distance rules out a single conv layer entirely
Top-left and bottom-right sit at Chebyshev distance — outside a single kernel's reach, which only covers distance . Connecting them with convolutions alone would take at least two stacked layers.
- Self-attention connects them anyway
Query = top-left, embedding . Both top-left and bottom-right are "bright" patches, so their dot products with the query are identical: , scaled to — the same score top-left gets against itself. Softmax over all nine patches:
- Three "bright" scores of : each
- Six "dark" scores of : each
Summing to . Each bright patch's share is — bottom-right gets that same of top-left's attention, in a single layer, with no distance penalty of any kind.
- Content beats proximity
The adjacent top-middle and mid-left patches are "dark," so their dot product with the query is (e.g. ), giving in that same softmax. From the sum of above, each dark patch's share is — squarely inside a conv kernel's reach, but dark, they receive only each. Being close doesn't matter if the content doesn't match; being far away doesn't matter if it does.
Find the patch, between the two candidates, that receives more attention from top-left — despite being on the opposite corner of the grid.
ViT doesn't invent a new mechanism for images — it removes the assumption, baked into convolution since Part IV, that nearby pixels matter more than far ones by default. Patches become tokens, position becomes an embedding, and the same attention machinery that connects distant words in a sentence connects distant regions of an image just as directly. The next chapter asks a different question about that same idea: instead of building a new model from scratch, how much of what one already-trained network learned can be reused for something else entirely?