Raising the RoPE base lowers per-dimension rotation frequencies, so a pair of tokens 60k apart produces in-distribution rotation angles instead of aliasing to garbage the model never trained on.
Imagine a clock where each hand moves at a different speed: the second hand spins fast, the minute hand spins slower, the hour hand barely moves. RoPE is the same idea; different dimensions of the query and key vectors are like different hands on a clock that get rotated by amounts based on token position. The base theta sets how fast each hand spins per token. With a small base, the fastest hand makes a full rotation in just a few hundred tokens. By the time the conversation reaches 60,000 tokens, that fast hand has made hundreds of full rotations and the model cannot tell where it actually is. With a larger base, the hands spin much slower, so even 60,000 tokens in, the hand positions look like what the model trained on at shorter distances.
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.
RoPE is the positional scheme that won. Every frontier dense LLM in 2026 (Llama, Mistral, Qwen, DeepSeek, Gemma) uses RoPE. The reason is structural: RoPE gives the attention dot product an exact relative-position property without any lookup table, which lets the model generalize beyond training length when paired with the right base frequency choice.
The specific trick that turns a 4k-trained base model into a 128k server is theta rescaling. Llama 2 used a base of 10,000 and trained at 4k tokens. Llama 3 raised the base to 500,000 and trained or continued-pretrained at long context. The 50x base increase is what makes the model behave sensibly at 60k tokens apart instead of producing aliased Q-K dot products that look like noise.
This walkthrough explains the rotation formula, why each dimension has its own frequency, what breaks at long context with the original base, and how raising theta restores in-distribution geometry. It also covers the relationship between raw theta rescaling, NTK-aware scaling, and YaRN as the three points on the same spectrum of extension recipes.
The RoPE formula and the frequency series
RoPE treats each consecutive pair of dimensions in Q and K as a 2D vector and rotates that vector by an angle determined by the token's position. For dimension pair i (i = 0, 1, ..., d/2 - 1) and position m, the rotation angle is:
The frequencies form a geometric series from omega_0 = 1 (fastest, dimension pair 0) down to omega_{d/2-1} = base^(-(d-2)/d) (slowest, last pair). With base 10,000 and d=128, the slowest frequency is about 10000^(-1) = 10^-4.
The rotation matrix is:
Applied separately to each dimension pair of Q and K before the attention dot product. The dot product between rotated Q at position m and rotated K at position n becomes:
which depends only on (m - n), not on m and n separately. This is the relative-position property: the attention score for a query-key pair depends on their offset, not their absolute positions. RoPE achieves this through pure rotation, no embedding table, no learned parameters in the position computation.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Llama 2 shipped with base 10,000 and 4k context; Llama 3 raised base to 500,000 to support 128k context.
- Llama 3.1 went further and uses NTK-style scaling on top of the base 500k to support 128k natively.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does YaRN consistently outperform naive theta rescaling on long-context evals?
YaRN selectively interpolates positions for fast-frequency dimensions while leaving slow-frequency ones alone, plus an attention temperature correction. The selective treatment preserves fine-grained discrimination at short distances that pure theta rescaling damages.
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.
Thinking RoPE has a lookup table that gets extended, or that raising theta disables positional information past the training length. RoPE has no table; theta just controls rotation frequency.
60 second bullets to scan on the way to the call.
The RoPE rotation formula and the role of base theta
Why each dimension pair has a different frequency (geometric series)
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.