Contrast absolute and relative positional encoding by what the score depends on
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.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Define the absolute vs relative split by what the score is a function of, map each PE family (sinusoidal, learned, T5, RoPE, ALiBi), explain translation-equivariance and length extrapolation, name 2026 production examples.
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.
- T5 introduced the learned relative-position bias bucket scheme that paired with its denoising pretraining.
- MPT-30B and BLOOM-176B used ALiBi for its length-extrapolation property; modern frontier LLMs have moved past it for RoPE+YaRN.
- Long-context extensions (YaRN at 128k, LongRoPE) all assume the RoPE relative-position structure as their starting point.
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).
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes 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.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.