RoPE encodes position by rotating query and key pairs — relative distance falls out of the dot product.
TOKEN POSITION (m)ANGLE θ · 114.6°
RoPE encodes relative position by rotating Query and Key vectors in complex 2D planes.
ARCHITECTURE & FORMULATIONModule 3: Modern Architectural Specifications (The Pre-Train Recipe)
Rotary Position Embeddings (RoPE)
RoPE (Su et al.) encodes relative positional information by multiplying 2D sub-vectors of Query and Key representations by rotation matrices proportional to sequence position.
Relative via Absolute Rotation
Instead of adding position embeddings to input tokens, RoPE rotates Q and K vectors in complex 2D planes. The dot product <R_m Q, R_n K> depends purely on relative distance (m - n).
No Extra Memory/Parameters
RoPE requires zero additional model parameters and is applied on-the-fly inside attention heads.
Length Extrapolation (RoPE Scaling)
By scaling the base theta frequency (e.g. from 10,000 to 500,000 or YaRN/linear scaling), models trained at 8k context can extrapolate to 128k+ tokens cleanly.