LESSON 9.C1 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW
Scaled dot-product attention end to end
Follow one token through scores, scale, mask, softmax and heads in one layer.
Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.
Go Pro · $8.25/moEXPLAINER · 9.C1 · ATTENTION BAYX 6 × 4 · 48 WEIGHTS MAKE Q, K, V
01
Stage 1 of 6 · Three projections
Three weight matrices turn each token into a query, a key and a value. The 4 columns split into 2 heads of 2.
Explain it simply
Each row on the left is one word, stored as 4 numbers. Three grids of weights turn each row into a query, a key and a value, as in 9.01. Each grey band is one head with its own share of the columns, as in 9.05.
X has 6 rows of 4 numbers. W Q, W K and W V turn it into Q, K and V. They split into 2 heads of 2 columns. The query of "sat" is 1.92, 0.39, −1.37, −0.83.
Weights are random, not trained.
x, Q, K, Vweight matrices, max mscores, weights, outputnegative scoresmaskedhead
Toy: 9.05's 6 tokens · width 4 · 1, 2 or 4 heads · random weights, not trained
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
Each token vector times three weight matrices gives its query, key and value.
PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
- 5 more stages and 3 live controls
- 2 mix-up cards and 3 predict-then-reveal checks
- Watch it as a narrated video, in three voices
- Every Pro lesson and capstone · 656 in total
$99 a year, or $15 a month. Cancel any time.