This page assumes you know nothing. We build every symbol the parent note (see the Hinglish version too) leans on, one brick at a time, each brick resting on the one before.
The two numbers are called components. x1 is how far right, x2 is how far up. That is the whole picture — and Figure s01 draws exactly this arrow so you can attach the words to the geometry.
In Figure s01 the blue arrow ends at (3,2); the yellow dashed line is its x1=3 (rightness) and the red dashed line is its x2=2 (upness). Whenever this note says "vector," picture that arrow.
Why does RoPE need this? Because a token's meaning is stored as a longer such list (dimension d, e.g. 64 numbers). Everything RoPE does is geometry on these arrows.
An angle measures turning. We could use degrees (a full turn = 360°), but maths and code prefer radians.
Key fact we will reuse: angles wrap. Turning by 1500 radians lands you in the same spot as turning by 1500mod2π≈4.60 radians, because every extra 2π is one full circle back home.
Put a point on a circle of radius 1 (the unit circle). Sweep an angle θ counter-clockwise from the positive x-axis. Where did the point land?
Figure s02 draws this: the green arc is the swept angle θ=3π/4, the yellow segment is cosθ (here pointing left, so negative) and the red segment is sinθ (pointing up, positive).
Why does RoPE need cos and sin? Because "spinning a vector" means computing where its tip goes on a circle — and cos/sin are exactly the machine that reports those new coordinates. Every quadrant is covered by the same two functions:
Quadrant
angle range
cosθ
sinθ
I
0 to 2π
+
+
II
2π to π
−
+
III
π to 23π
−
−
IV
23π to 2π
+
−
Notice θ=3π/4 (which we will use in the worked check at the end, and which Figure s02 draws) sits in Quadrant II: cos negative, sin positive. We will confirm the exact numbers below.
We have an arrow [x1,x2] and want a new arrow that is the old one turned by angle θ, same length, new direction.
Figure s03 shows this in action: the blue arrow is the original x, the yellow arrow is R(θ)x, and the green arc is the turn θ between them — same length, new direction.
Sanity check the four cases:
θ=0: R=[1001], the identity — no turn (this is why a token at position 0 comes out unchanged).
Now the identity we need:
R(α)TR(β)=R(−α)R(β)=R(β−α)
WHAT we did: took (R(α)q)T(R(β)k)=qTR(α)TR(β)k=qTR(β−α)k. WHY: because R(α)T=R(−α) undoes part of R(β)'s turn, leaving the net turn β−α. WHAT IT LOOKS LIKE: two arrows each spun on their own dials, but the angle between them only knows the difference of the dial readings.
Set α=mθ and β=nθ and you get β−α=(n−m)θ — the relative position drops out. That single line is RoPE.
Real vectors have d numbers, not 2. RoPE chops them into d/2pairs and spins each pair by its own angle-per-step θi.
Figure s04 plots θi against pair index i on a log axis: early pairs (small i) sit high — fast dials; later pairs (large i) sink toward zero — slow dials.
Each foundation on the left feeds the box to its right; all roads end at RoPE, which then powers Multi-Head Attention and rivals ALiBi (Attention with Linear Biases) and Relative Position Bias (T5).
Let us run the machinery on the smallest possible case so every symbol earns its keep. Take a query q=[1,0] at position m=0 and a key k=[0,1] at position n=3, with per-step angle θ=π/4.
Step A — spin the query. At position m=0 the angle is mθ=0, so R(0)=I leaves it alone: q′=[1,0]. (Recall from §1b that the prime just means "after rotation.")
Step B — spin the key. At position n=3 the angle is nθ=3π/4:
k′=R(3π/4)[01]=[cos43π⋅0−sin43π⋅1sin43π⋅0+cos43π⋅1]=[−21−21]
Here cos43π=−21 and sin43π=+21 (Quadrant II, as the table in §3 predicts), so the first entry is −sin43π=−21 and the second is cos43π=−21.
Step C — dot them. The attention score is
q′Tk′=[1,0][−21−21]=1⋅(−21)+0⋅(−21)=−21≈−0.707.
By §6, this equals qTR((n−m)θ)k=qTR(3π/4)k — the score depends only on the gap n−m=3, exactly as promised.
The wrap-around fact from §2 in numbers: 1500mod2π≈4.60 radians, confirming that a huge position angle folds back into a familiar small one inside [0,2π).