Absolute PE makes the attention score depend on positions m and n separately; relative PE makes it depend only on the offset (m - n). The latter gives translation invariance and better length extrapolation.
Picture two people standing on a number line. Absolute thinking says 'one is at 7 and the other is at 12, the score depends on those numbers'. Relative thinking says 'they are 5 apart, that is all that matters'. If you slide both of them three steps to the right (now at 10 and 15), absolute thinking sees new numbers and recomputes; relative thinking shrugs because the gap is still 5. Modern long-context models all want the relative behavior because real language patterns care about how far apart tokens are, not where they sit in the absolute timeline.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Absolute versus relative positional encoding is one of the most consequential design splits in modern transformer architecture. The decision shapes whether a model can extrapolate to longer context than it was trained on, determines which long-context extension techniques (YaRN, LongRoPE, NTK scaling) apply, and indirectly drives the architectural convergence of 2024-2026 frontier LLMs onto a small family of RoPE-based designs.
This deep dive starts with the formal definition of what 'absolute' and 'relative' mean at the level of the attention score, walks through each major scheme (sinusoidal, learned, T5 bucket, RoPE, ALiBi), explains the translation-equivariance property that gives relative schemes their length-extrapolation power, and closes with why every frontier model in 2026 ships with RoPE-and-friends.
The goal is to understand the absolute vs relative split not as a list of named techniques but as a fundamental property of what the attention score is mathematically a function of.
The formal definition: function-of property
Strip away all the named schemes and ask the bare question: what is the attention score s_mn = (q_m . k_n) / sqrt(d_k) a function of?
Absolute property
s_mn = f(q_m, k_n, m, n) where m and n enter as separate arguments. Shifting the whole sequence by a constant t (so position m becomes m+t, position n becomes n+t) changes the score, because the function sees the new absolute positions.
Relative property
s_mn = f(q_m, k_n, m - n) where only the offset (m - n) enters. Shifting the sequence does NOT change scores: s_{m+t, n+t} = s_{mn}.
The relative property is translation-equivariance of attention. It is the right inductive bias for sequence modeling because language patterns generally depend on how far apart tokens are, not on their absolute location in the sequence. The verb 'bites' modifies the noun 5 tokens away whether that noun is at position 12 or at position 5012.
Why the formal definition matters
Named schemes can confuse the issue (sinusoidal involves sines, doesn't that make it 'relative'?). The function-of definition cuts through: sinusoidal PE is absolute because the score still ends up being a function of m and n separately. The use of trig functions in the encoding does not by itself confer the relative-property.
\text{Translation equivariance}: \quad s_{m+t,\, n+t} = s_{m,n} \text{ for all } tSituations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Llama 4 Maverick, Mistral, Qwen 3.5, and DeepSeek V4 all use RoPE because of its relative-position property and long-context extensibility.
- Original 2017 transformer used sinusoidal absolute PE; BERT and GPT-2 used learned absolute PE.
What an interviewer would ask next. Try answering before peeking at the approach.
QRoPE rotates Q and K. Show algebraically that the resulting dot product depends only on (m - n).
Represent each pair of adjacent Q dimensions as a complex number z_q. RoPE rotation is multiplication by e^{i theta m}. The dot product q_m . k_n becomes Re(z_q e^{i theta m} conj(z_k e^{i theta n})) = Re(z_q conj(z_k) e^{i theta (m - n)}). The exponent depends only on the offset.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Confusing where each scheme is APPLIED (input vs logits) with what each scheme is a FUNCTION OF (absolute positions vs offset). Those are independent axes.
60 second bullets to scan on the way to the call.
Define translation-equivariance of the attention score
Map each PE family (sinusoidal, learned, T5 bucket, RoPE, ALiBi) to absolute or relative
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.