Log inStart free
LESSON 10.06 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

RoPE

Watch RoPE turn queries and keys so their scores see only the offset.


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/mo
EXPLAINER · 10.06 · ROTARY BAYQ “ON” AT 3 · K “SAT” AT 2 · Q·K −0.18
01
Stage 1 of 6 · Query and key
The query “on” and the key “sat” hold 8 numbers each. RoPE reads them as 4 pairs, one arrow per circle.
Explain it simply

The top row is the query of the word on: what it looks for. The row below is the key of the word sat: what it offers. RoPE groups the 8 numbers two by two. Each pair becomes an arrow in its own circle, like a clock hand.

Two rows of 8 numbers: the query of “on” and the key of “sat”. Below, 4 circles hold one query arrow and one key arrow each.

query, keyturnscell below 0cell above 0; parts, score
past position 7position0123456789101112131415satonq · onk · sat|q| 1.23|k| 0.94−0.78−0.06−0.080.080.340.810.080.32−0.020.48−0.41−0.400.38−0.410.090.09pair 0ω₀ = 1qkpair 1ω₁ = 0.1qkpair 2ω₂ = 0.01qkpair 3ω₃ = 0.001qkquery and key as pairsq · k = −0.18 (no position yet)past position 7position0123456789101112131415satonq · onk · sat|q| 1.23|k| 0.94−0.78−0.06−0.080.080.340.810.080.32−0.020.48−0.41−0.400.38−0.410.090.09pair 0ω₀ = 1qkpair 1ω₁ = 0.1qkpair 2ω₂ = 0.01qkpair 3ω₃ = 0.001qkquery and key as pairsq · k = −0.18 (no position yet)
Toy: 16 positions, width 8, seeded W_Q and W_K (not trained)
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
q=e(on) WQ,k=e(tn) WK\sy{q}{data}{q} = e(\text{on})\,W_Q,\qquad \sy{k}{data}{k} = e(t_n)\,W_K
∥q∥=1.23,∥k∥=0.94,q⋅k=−0.18\lVert q \rVert = 1.23,\quad \lVert k \rVert = 0.94,\quad q \cdot k = -0.18

The query and the key come from the token embeddings, with no position.

Common mix-ups

MYTHRoPE adds a position vector to each token.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01If both tokens move 9 positions later, does the RoPE score change?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

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.