Multimodal / Vision
verifiedPatch Embedding
Attention needs a sequence, and an image is a grid. Patch embedding cuts the image into fixed squares, flattens each one, and projects it to a vector — so a picture becomes a short sequence of tokens the same machinery can read. A 224-pixel image at 16-pixel patches is 196 tokens, which is an ordinary sentence length.
A single linear projection applied to each flattened patch, equivalent to a strided convolution with kernel and stride both equal to the patch size. Patch size is the whole trade: halving it quadruples the sequence, and attention costs the square of that — sixteen times the work for one halving — in exchange for finer detail. Position information has to be added separately, because flattening throws away the grid.
An H×W image at patch size P yields N = HW/P² tokens, each projected from ℝ super P²·C to ℝ super d sub model . At 224×224 and P = 16 that is 196 tokens; at P = 8 it is 784, and attention cost rises as N² — sixteen times for one halving.
tokens holds 10% of the budget; rest holds the remaining 90%.
Sequence length one image produces, against the rest of an attention budget. Drag the token count to watch a smaller patch crowd out everything else.
Reviewed by opendroid · 2026-08-04
- arXiv:2010.11929 — An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale