Visual walkthrough — The original - Attention is All You Need - architecture
Before line one, the only thing you must accept: a word can be turned into a list of numbers — an arrow in space. That's it. Everything else we construct.
Step 1 — A word is an arrow
WHAT. Take three words: "The", "cat", "sat". A machine cannot add letters, so we hand each word a short list of numbers — say 2 numbers so we can draw it on paper. That list is a point, and the arrow from the origin to that point is the word's vector (its "embedding").
WHY. We need something we can do arithmetic on. Arrows can be measured, compared, and pointed in similar or different directions. "Similar meaning" will become "arrows pointing the same way" — a geometric idea we can compute.
PICTURE. Three arrows leaving the origin. "cat" and "sat" lean close together (they often appear together); "The" points off elsewhere. The angle between arrows is the whole game.

Step 2 — How "aligned" are two arrows? The dot product
WHAT. To measure whether two arrows point the same way, multiply them coordinate-by-coordinate and add up the results. For arrows and :
WHY this tool and not another? We want ONE number that grows when two arrows agree and shrinks (even goes negative) when they disagree. The dot product is exactly that: , where is the angle between them. Same direction () → → big. Perpendicular () → → zero. Opposite → negative. No other simple operation packs "alignment" into a single number this cleanly.
PICTURE. Two arrows with the angle marked; a dial reads high when they overlap, drops to zero at a right angle, goes negative when they oppose.

Step 3 — Every word scores every word: the matrix
WHAT. For now pretend every word plays three roles with itself, so let queries , keys , and values all equal our stacked word matrix (we split them apart in Step 6). Compute the dot product of every row of with every row of . Collect them in a grid .
- = the words asking ("who is relevant to me?").
- = the words offering an identity to be matched against.
- = how much word (the asker) aligns with word (the offerer).
WHY. Attention is "every token looks at every token." That is exactly an table of pairwise alignment scores. Matrix multiply computes all dot products in one shot — this is why the Transformer parallelizes: no loops, just one big multiply.
PICTURE. A heat grid. Row = the asking word, column = the offered word. The diagonal glows (a word aligns with itself); "cat"–"sat" is warm; "The" is cool everywhere.

Step 4 — Why we shrink the scores: dividing by
WHAT. Before doing anything else, divide every score by , where is the number of coordinates in each key vector:
WHY this exact number? A dot product adds up little products. If each coordinate is random with spread , the sum of of them has spread (variances add; standard deviation grows like the square root). So with , raw scores swing around just from noise. Feed those into the next step (softmax) and it saturates — one score wins everything, gradients die. Dividing by cancels exactly that growth, keeping scores at a healthy spread of about regardless of dimension. That's why the square root and not the number itself: we're undoing a standard-deviation growth, and standard deviation grows like .
PICTURE. Two histograms of scores: the raw one is wide and spiky (spread ); after dividing, it's a tidy narrow bell of spread .

Step 5 — Turning scores into weights: softmax
WHAT. Each row of is a list of raw scores for one asking word. We want those to become positive weights that add to 1 — a recipe of "how much of each other word to mix in." That is the job of softmax. For a row of scores :
WHY the exponential? Three demands: (1) weights must be positive — is always positive; (2) bigger score → bigger weight, sharply — the exponential amplifies leads; (3) weights must sum to 1 — dividing by the total of all guarantees it. No plain "score / total" would do, because raw scores can be negative. The exponential is the natural tool that satisfies all three at once.
PICTURE. A row of three bars (raw scores) feeding into a machine that outputs three shorter bars summing to a full unit height — a probability recipe.

Step 6 — Mix the values: the final output
WHAT. Now use the recipe. Each word carries a value vector (the content it contributes). The output for asking-word is the weighted blend: Stacked for all rows, this is just .
WHY split , , apart now? In real Transformers each word is multiplied by three learned matrices before any of this: . The asking-identity (), the matchable-identity (), and the delivered-content () are then free to be different — a word can advertise one thing to be found by, and deliver another thing once chosen. Learning lets the model decide what each role should be. (See Scaled Dot-Product Attention and Multi-Head Self-Attention.)
PICTURE. The recipe row for "cat" pouring three value arrows into a mixing bowl; out comes one blended arrow — "cat" now carries a pinch of "The", a big scoop of itself, a scoop of "sat".

Step 7 — The edge cases we must not skip
Every input the reader could hit, drawn out:
Case A — a word attends only to itself. If one score dominates (say after training a word's query aligns almost perfectly with just its own key), softmax pushes that weight to and the rest to . Output : the word passes through nearly unchanged.
Case B — total indifference (all scores equal). If every is the same, softmax gives every weight . The output is the plain average of all values — attention "gives up" and blends everyone equally. This is the degenerate, no-information case.
Case C — the mask (used in the decoder). To stop a word from peeking at future words, we add to forbidden scores before softmax. Since , those weights become exactly — future words contribute nothing. Word can only blend words . This gives the staircase pattern of Attention Masking.
Case D — zero-length value. If some , it contributes nothing to any blend no matter how much attention it receives — a word can be attended to yet deliver empty content. The score and the content are independent knobs.
PICTURE. Four mini attention grids side by side: sharp diagonal (A), flat gray uniform (B), lower-triangular staircase (C), and one with a zeroed value column (D).

The one-picture summary
One diagram, left to right: three word-arrows → the score grid → shrink by → softmax into recipe rows → multiply by → three refreshed output arrows, each a blend.

Recall Feynman retelling — say it to a 12-year-old
Every word becomes an arrow. To decide who a word should listen to, we measure how much its arrow lines up with every other word's arrow — that lining-up number is the dot product. We stack all those numbers in a grid. The numbers get bigger just because the arrows are long lists, so we shrink them by to keep things calm. Then softmax turns each row of numbers into a recipe — positive amounts that add up to one — saying "mix 31% of this word, 37% of that one, 32% of the other." Finally we pour each word's content arrow into the bowl in those amounts, and out comes a new arrow for each word that now knows about its neighbours. If one number is huge, a word just listens to itself; if all numbers are equal, it hears everyone equally; and in the decoder we drop onto future words so nobody can peek ahead.
Reveal-yourself checks: