Papers · 2021 · Reading: 22 min, plus 4 in closed details.
Paper · Neurocomputing 2024 (arXiv preprint 2021) · arXiv 2104.09864

RoFormer: Enhanced Transformer with Rotary Position Embedding (RoPE)

Jianlin Su, Yu Lu, Shengfeng Pan, Ahmed Murtadha, Bo Wen, Yunfeng Liu
Zhuiyi Technology, Shenzhen · April 2021 (arXiv v1 20 April 2021; v5 November 2023; journal version in Neurocomputing 2024)

In one line: Rotate each query/key 2D pair by a position-proportional angle (theta_i = 10000^(-2i/d)) so the QK dot product depends only on relative offset; became the default LLM positional encoding and the substrate for the main context-extension methods (PI, NTK, YaRN, iRoPE).

27.5 BLEU
WMT 2014 English to German, against 27.3 for Transformer-base
+0.2 BLEU, one run each · Table 1
3 of 6 GLUE tasks
where RoFormer beats BERT-base (MRPC, STS-B, QQP)
and loses the other 3 (SST-2, QNLI, MNLI) · Table 2
69.79% test accuracy
CAIL2019-SCM long legal documents, RoFormer at 1,024 tokens
against 68.10% for WoBERT capped at 512 · Table 5

How far to trust it: Believe the mathematics: the relative-offset property is exact and checkable in one line, and every major open LLM since 2023 has adopted it. Do not read the experiments as evidence that RoPE is better: they are single runs with gains of 0.2 BLEU and 1.5 to 1.7 points, the GLUE comparison sets RoFormer's validation scores against BERT's test-server scores, and the long-text result stays inside the length RoFormer was pretrained at. The evidence, point by point.

The idea in one sentence: rotate each two-dimensional pair of a token's query and key by an angle proportional to the token's position, so every attention score depends on the two tokens' content and only their relative offset, while each token is still encoded on its own, with no parameters and values untouched.

Slide two tokens 38 positions later: every arrow turns, the angle between query and key does not, so the score is unchanged. The stage beside is one 8-dimensional query and key as a tower of 4 rotation pairs, fastest at the top:

  1. Two vectors, eight numbers each. q = (0.96, 0.30, 0.36, 0.93, −0.42, 0.91, 0.88, −0.48) and k = (0.17, 0.99, 0.83, 0.17, 0.54, −0.84, −0.66, 0.61), as signed bars; unrotated, q⊤k = −0.951. The vectors are illustrative; every number after them is exact arithmetic.
  2. Split into four rotation pairs. Each two adjacent numbers become one arrow on its own dial. The dials are stacked by frequency θi = 10000−2i/8 = 1, 0.1, 0.01, 0.001 radians per token, the paper's spectrum at d = 8 (Eq. 15): fast pair 0 at the top, slow pair 3 at the bottom.
  3. Rotate to positions 5 and 2. The query of pair i turns by 5θi, the key by 2θi: the top arrows turn 5 and 2 radians, the bottom ones 0.005 and 0.002. The wedge between them is 3θi; each pair's share of q⊤k (the bar beside its dial) is |qi||ki| cos 3θi, and the four add to q⊤k = −1.963.
  4. Slide both 38 positions later, to 43 and 40. Every arrow turns further (the top pair more than six whole turns, the bottom one hardly at all), but each wedge is still 3θi, so every share and the sum, −1.963, are identical (Eq. 16).
  5. Change the offset instead: key at 33. Now each wedge is 10θi. The fast pairs' shares change most, the slow pair's hardly at all, and q⊤k becomes −3.090. The score follows the offset m − n, never where the two tokens sit.

The fast pair at the top moves most, the slow pair at the bottom hardly at all. The many-pair dials below let you move both positions yourself; the one-pair picture from zero is Fig. 4 on Positional Encodings.

You need: what an attention score is (q⊤k, then a softmax) and why a Transformer needs positions at all (Positional Encodings, sections 1 and 2, which also teaches every scheme RoPE is compared with and the context-extension methods built on it; this page is the 2021 paper). New terms:

  • rotation pair: two adjacent dimensions of a query or key, treated as one point in a plane and turned together; a head of size d has d/2 of them.
  • frequency θi: the angle pair i turns per token, 10000−2i/d; pair 0 is fastest, the last pair slowest.
  • relative offset m − n: how far apart the query's token (position m) and the key's token (position n) are.
  • additive encoding: any scheme that adds a position vector or bias (absolute tables, sinusoids, T5's bias); RoPE multiplies instead.

Problem

§2 Background, Eqs. 1 to 10

Self-attention is position-agnostic: permute the tokens and every output is permuted the same way, so position must be injected somewhere (§1). The paper writes every scheme as a choice of three functions, qm = fq(xm, m), kn = fk(xn, n) and vn = fv(xn, n), feeding the usual softmax of qm⊤kn/√d (Eqs. 1 and 2). Every prior choice is additive:

  • Absolute (§2.2, Eq. 3): add a position vector before the projections, W(xi + pi), with p either learned (one trainable row per position up to a maximum length L: BERT, GPT, ALBERT, ELECTRA) or the fixed sinusoids of Vaswani et al. (Eq. 4).
  • Relative (§2.3): expand qm⊤kn into four terms (content and position, crossed; Eq. 6) and surgically edit them, each scheme keeping or replacing different terms (Shaw et al., Transformer-XL, T5, TUPE, DeBERTa; each is listed in the closed block below, and how they work today is on Positional Encodings).
The five relative schemes as §2.3 writes them (Eqs. 5 to 10)

Shaw et al. add clipped trainable relative vectors to keys and values (Eq. 5); Transformer-XL swaps in a sinusoid of m − n plus two trainable vectors (Eq. 7); T5 keeps the content term and adds a trainable bias bi,j (Eq. 8); TUPE adds a separately projected position term (Eq. 9); DeBERTa keeps only the two middle, content-position terms with relative embeddings (Eq. 10).

The authors see two structural problems. First, position is entangled with content rather than stated as what attention should see, which they argue is only the relative offset. Second, the relative variants edit the expanded attention matrix, so they cannot be used with linear attention, which never materialises q⊤k for every pair (§1, §2.3).

The gap: a formulation where the query-key inner product provably depends on the two token embeddings and their offset m − n only, while each position is still encoded independently, an absolute operation per token. That last property is also what makes KV caching cheap: a key is encoded once, at its own position, and never needs recomputing.

Idea

§3.1 Formulation, Eq. 11

State the requirement as an equation and solve it (Eq. 11): find fq and fk such that

⟨ fq(xm, m), fk(xn, n) ⟩ = g(xm, xn, m − n)

Each token is encoded using only its own absolute position, yet the inner product sees only the relative offset. The answer, derived in two dimensions and then stacked, is a rotation.

Rotation

§3.2, §3.4.1, §3.4.2, Eqs. 12 to 16 and 34

The 2D case (§3.2.1, Eq. 12). Identify the plane with the complex numbers. Then

fq(xm, m) = (Wqxm) eimθ,   fk(xn, n) = (Wkxn) einθ,   ⟨qm, kn⟩ = Re[ (Wqxm)(Wkxn)* ei(m−n)θ ]

Rotate the projected query and key by an angle proportional to the position. The conjugation makes the phases subtract, so the absolute rotations by mθ and nθ leave only the relative angle (m − n)θ. As a matrix, it is a 2 × 2 rotation by mθ applied after W (Eq. 13). The one-pair picture from zero, where you shift both positions and watch the dot product stay put, is on Positional Encodings (section 3, RoPE from zero); this page goes on from there to the many pairs and the trained models.

Is rotation forced, or just one solution? (§3.4.1)

§3.4.1 writes fq, fk and g in polar form (Eq. 23), so the constraint splits into a radial equation and an angular one (Eq. 24). Setting m = n and using the initial condition at position 0 (Eq. 25, Eq. 26) shows the angle minus its value at 0 cannot depend on the token, only on the position, φ(m) (Eq. 28); putting n = m + 1 makes φ(m + 1) − φ(m) a constant, so φ is an arithmetic progression, φ(m) = mθ + γ (Eqs. 29 and 30): rotation at constant angular speed.

The radial part is not forced in the same way: the paper takes "a straightforward solution", a norm that does not depend on position (Eq. 27), then chooses f(x, 0) = Wx to match Equation 3 and sets γ = 0 (Eqs. 32 and 33). So the angle is forced; the rest are choices, and the paper itself calls the result "a solution". (Eq. 32 also has a typo, Wqxn for Wqxm.)

The general form (§3.2.2, Eqs. 14 and 15). For even d, split the vector into d/2 independent pairs and rotate pair i by its own frequency: f(x, m) = RdΘ,m W x, with R block-diagonal, 2 × 2 rotations by mθ1, …, mθd/2 and θi = 10000−2(i−1)/d, i = 1 … d/2. Since rotations are orthogonal and (RΘ,m)⊤RΘ,n = RΘ,n−m,

qm⊤kn = xm⊤ Wq⊤ RdΘ,n−m Wk xn

which satisfies the constraint exactly (Eq. 16). Position enters multiplicatively, into q and k only: values are untouched, norms are preserved (the paper notes orthogonality "ensures stability"), there are no parameters, and it is applied in every layer rather than once at the input.

Two slips in §3.2 and §3.3 (Eq. 16, the indexing of θ)

The printed Eq. 16 drops the transpose on Wq and the subscript on the first x. The paper's two indexings of θ differ by one: §3.2.2 counts i from 1 with −2(i−1)/d, §3.3 from 0 with −2i/d; they are the same spectrum.

No matrix multiply needed (§3.4.2, Eq. 34). The block structure makes R·x two elementwise products: x ⊗ cos(mθ) + (−x2, x1, −x4, x3, …) ⊗ sin(mθ), with each cos and sin repeated for the two members of its pair: a few fused elementwise operations per layer. The toy models on this page use exactly this form (train.py's rotate, the page's JavaScript rotate). Much later code instead pairs dimension i with i + d/2 (Hugging Face's Llama rotate_half); it is the same rotation on a permuted layout.

Try: each dial is one of the d/2 = 8 pairs of a 16-dimensional query (solid) and key (dashed), rotated by mθi and nθi. The bar under each dial is that pair's share of qm⊤kn. Press Shift both: every dial turns, every bar stays exactly where it was. Move only m: the fast pairs on the left spin through whole turns while the slow pairs on the right barely move, so the fast ones resolve nearby offsets and the slow ones carry coarse order. The vectors are random and illustrative; the frequencies are the paper's, θi = 10000−2i/16.

Shift both positions: every dial turns, every bar stays

The shift test, on trained models

Eq. 16, run on this page's toy models

The algebra says a RoPE layer's attention pattern for a stretch of text does not depend on where the stretch sits. An additive model can only learn to approximate that. Here are two real one-layer models from this page's Train short, test long tab, identical except for position (left, RoPE multiplied into q and k; right, sinusoids added to the input), both 100% correct on held-out sequences of the length they were trained on. The stage slides the same 12 digits four positions at a time and redraws the attention weights of one head of each, as bar fields: rows are the 12 queries, columns the keys they may see (the causal mask hides the upper triangle), height is weight, and each row sums to 1.

slide the same 12 digits from positions 0 to 11 to positions 20 to 31, all inside the trained length. How much do the RoPE model's attention weights change?
  1. Positions 0 to 11: where each head looks. The 12 digits 3 8 1 6 0 9 4 4 7 2 5 1 enter both models at the start of the 32 trained positions (the strip at the back). The gold bars are offsets 1 and 4, the two the task (xt−1 + xt−4) mod 10 needs: the RoPE model's head 1 of 4 puts 74% of each row's weight there, the sinusoidal model's head 2 puts 98%, found through position vectors added to the input. The other heads and the MLP do the rest.
  2. Slide 4 positions later. The same digits now sit at positions 4 to 15; the outlines mark each bar's height at step 1. RoPE's bars have not moved: the largest change is under 10−15, floating-point noise, because every score is a function of offsets only. The sinusoidal bars move (largest change 0.030): its absolute position vectors are different now.
  3. Slide on to positions 20 to 31, the end of the trained length. Through 8, 12 and 16 the RoPE field stays frozen (largest change about 10−15 at most); the sinusoidal one keeps drifting, by up to 0.171 (at positions 16 to 27) and 0.046 at 20 to 31, though it still answers 8 of 8 positions correctly.
  4. Closer: the sinusoidal head at 20 to 31. Bars against their step-1 outlines: the pattern is roughly kept but not exactly, because the model learned to work around absolute position rather than ignore it. The RoPE model never had to learn this; Equation 16 gives it for free, and the Train short, test long tab shows where that helps (a sliding window) and where it does not (offsets never seen in training).

The head shown in each model is the one whose weight falls most on offsets 1 and 4. Weights are computed live by the page's forward pass (checked against PyTorch), and the numbers in the steps are those weights.

The frequency spectrum

§3.2.2, §3.3

θi = 10000−2i/d is the same geometric spectrum as the original sinusoidal encoding, now used multiplicatively. Wavelengths run from 2π (pair 0 turns one radian per token) up to about 2π × 10000 (the slowest pair). Fast pairs resolve nearby offsets sharply; slow pairs change little over hundreds of tokens and carry coarse long-range order. This spectrum is the knob every later context-extension method turns; the Then and now tab steps through them.

It also explains the toy's main result. With 8-dimensional heads (4 pairs) trained at length 32, pair 0 turns about 5 times inside the training window, but pairs 1, 2 and 3 never complete a turn: their largest angle seen in training is 3.1, 0.31 and 0.031 radians (recompute.py). At an offset of 40 they show angles no training example ever produced. That is the mechanism behind the train short, test long failure.

Long-term decay

§3.3, §3.4.3, Figure 2, Eqs. 35 to 37

The paper's second argument for RoPE: the score between distant tokens is bounded by a quantity that falls with distance (§3.4.3, Figure 2), so distant pairs get systematically weaker interaction by construction, which matches the linguistic prior and is the paper's explanation for its long-text advantage. The stage shows why the bound falls, at the head size that reproduces Figure 2 (d = 128, 64 pairs, base 10,000); the chart after it is the bound itself, and the question is whether real scores follow it.

The bound, by Abel summation (Eqs. 35 to 37)

§3.4.3 writes the RoPE inner product as a sum of complex per-pair terms, Re[Σi hi ei(m−n)θi] with hi = q[2i:2i+1]k*[2i:2i+1] (Eq. 35), and bounds it by Abel summation: with partial sums Sj = Σi<j ei(m−n)θi, the magnitude is at most maxi|hi+1 − hi| · Σj|Sj| (Eqs. 36 and 37). The paper plots the average (1/(d/2)) Σj|Sj| against distance and it falls.

  1. Distance 0: every pair points the same way. At distance m − n = 0 each of the 64 unit arrows ei(m−n)θj points along the same line, so the walk that adds them head to tail is straight. Each post stands at a partial sum Sj and is as tall as |Sj|; their average is the bound, 32.50 = (d/2 + 1)/2.
  2. Distance 8: the fast pairs scatter. The 15 fastest pairs have turned more than a radian (orange) and point every which way, so their part of the walk tangles near the start; the slow pairs (blue) still line up. The posts shrink: average 19.82, Figure 2's value at 8.
  3. Distance 64: more of the walk is tangle. 29 pairs have turned past a radian; only the slow tail still adds up. Average 10.09.
  4. Distance 256: the end of Figure 2. 39 of the 64 pairs scatter and the average falls to 6.54. That is the whole mechanism of the decay: fast pairs cancel, slow pairs still add.
  5. A real score weights every arrow. A real score is the same walk with arrow j scaled and turned by hj, the product of the query's and key's pair j (Eq. 35): the score is the real part of where the walk ends. Here q and k are one Gaussian draw (illustrative; the first of the chart's 200). Even at distance 0 the arrows point every which way, because the hj do; the score is 11.52.
  6. Distance 256: still a tangle, no decay. The same draw at 256: the walk is just as tangled and the score is 12.10. Over all 200 draws the mean |score| is 9.63 at distance 0 and 8.89 at 256. Only aligned vectors (all-ones, the unit walk of steps 1 to 4) decay; that is why Figure 2 is a bound.

Figure 2, recomputed, against actual scores

take random query and key vectors (independent Gaussian entries). Averaged over many draws, does the RoPE score q⊤R k get smaller as the distance grows from 0 to 256?

Try: the blue line is Figure 2 recomputed from Equation 37. Defaults reproduce Figure 2 by matching: the paper does not state d; d = 128 gives the plotted start (19.8 at distance 8) and end (about 6.5 at 256), d = 64 or 256 give half or double. Tick "show actual scores" to put real scores beside the bound, each line divided by its value at distance 0 so they share an axis: the orange line is the score for all-ones q = k (pairs perfectly aligned), which does decay; the grey line is the mean |q⊤Rk| over 200 Gaussian pairs, which does not, and the dashed line their mean, which hugs 0. Raise the base to see why long-context models do: the bound decays far more slowly.

The bound falls with distance; actual scores need not

Linear attention

§3.3, Eqs. 17 to 19; §4.4

Write attention generally as Σn sim(qm, kn) vn / Σn sim(qm, kn) (Eq. 17). Linear attention (Katharopoulos et al.; taught on Beyond attention) replaces sim with φ(q)⊤φ(k) for a non-negative feature map such as elu(x) + 1, so the key-value products can be summed first and the O(N²) cost becomes O(N) (Eq. 18). Because RoPE is a norm-preserving rotation applied to q and k rather than an edit to the attention matrix, it composes: rotate the feature-mapped vectors in the numerator, RΘ,mφ(qm) and RΘ,nφ(kn), and leave the denominator unrotated to avoid dividing by zero (Eq. 19). The paper is candid that the weights are then no longer a probability distribution (the numerator can contain negative terms) and "kindly argue[s]" they still model importance. On this basis it presents RoPE as the relative encoding that works with O(N) attention, arguing that the earlier relative schemes cannot (§1).

The toy tests this too. The same task with linear attention: see the Train short, test long tab.

Results

§4 Experiments, Tables 1 to 5, Figure 3

All experiments ran on two cloud servers with 4 × V100 GPUs each (§4). Every number is one run. Each experiment is rebuilt in The paper's tables, rebuilt.

  • WMT 2014 English to German (§4.1, Table 1): 27.5 BLEU against 27.3 for Transformer-base, both trained by the authors in fairseq with the Vaswani recipe. A sanity check, not the headline.
  • BERT-style pretraining (§4.2, Figure 3 left): bert-base-uncased with its absolute positions replaced by RoPE, on BookCorpus plus Wikipedia. The training MLM loss falls faster than BERT's under the same settings. The paper calls BERT's encoding "sinusoidal"; BERT's is a learned table (google-research/bert, modeling.py).
  • GLUE (§4.3, Table 2): best of four learning rates on the validation set. RoFormer is ahead on MRPC (89.5 against 88.9), STS-B (87.0 against 85.8) and QQP (86.4 against 71.2), and behind on SST-2 (90.7 against 93.5), QNLI (88.0 against 90.5) and MNLI (80.2/79.8 against 84.6/83.4). The paper reports the three wins as "significantly" better; v2 of the same table called the overall result "comparable" (v2).
  • Performer with RoPE (§4.4, Figure 3 right): a 12-layer character-level Performer on Enwik8. With RoPE the loss falls faster and ends lower, the linear-attention claim in practice.
  • Chinese long text (§4.5, Tables 3 to 5): RoFormer is WoBERT (word-level Chinese BERT) with RoPE, pretrained in stages up to 1,536 tokens (Table 4). On CAIL2019-SCM (8,964 triplets of Supreme People's Court cases; is case B or C closer to A?) RoFormer at 1,024 tokens reaches 69.79% test accuracy against 68.10% for WoBERT capped at 512, the paper's main evidence for sequence-length flexibility. At 512, RoFormer (68.29%) is comparable to WoBERT and slightly ahead of BERT (67.77%).
  • The authors' own limitations (§4.5.5): they cannot explain why RoPE converges faster than other encodings, and although its decay property is shared with other relative schemes, they have no faithful explanation of why it does better on long texts. Both statements count in their favour.
The setups as §4 states them (recipes, batch sizes, learning rates)
  • WMT: 37k joint BPE vocabulary, Adam 0.9/0.98, linear warmup from 1e-7 to 5e-4 then inverse square root, label smoothing 0.1, average of the last 5 checkpoints, beam 4, length penalty 0.6.
  • BERT-style pretraining: batch 64, length 512, AdamW at 1e-5.
  • GLUE: 3 epochs, length 512, batch 32, best of learning rates 2, 3, 4 and 5e-5 on the validation set.
  • Chinese pretraining: about 34 GB of Chinese Wikipedia, news and forums, in six stages whose maximum length moves between 128 and 1,536 (Table 4).
  • Performer: 768 dimensions, 12 heads, lucidrains' performer-pytorch, learning rate 1e-4, batch 128, length 1024.
on how many of the six GLUE tasks in Table 2 is RoFormer behind BERT?

How much of this to believe

the paper's own evidence, judged

What holds up. The mathematics: the relative-offset property is exact, a one-line identity anyone can check (the shift test above does it on trained weights, to the last digit), and so are norm preservation, zero parameters and compatibility with KV caching. The practical claims were replicated independently and at larger scale on the day v1 appeared: EleutherAI found lower validation loss than learned absolute and T5 relative positions in GPT-NeoX on OpenWebText2 (2.759 against 2.809 and 2.801 at about 30B tokens) and at 1.5B parameters on the Pile (2.173 against 2.240 and 2.223 at about 8B tokens), about 30% faster convergence than learned absolute, a 1 to 3% overhead with fused kernels, and a large gain for Performer. Then the field adopted it (Why it matters).

What does not hold up as evidence:

  • GLUE compares validation against test. The BERT row of Table 2 (88.9, 93.5, 90.5, 85.8, 71.2, 84.6/83.4) is digit for digit BERT-Base in the BERT paper's Table 1, the GLUE evaluation-server test results; RoFormer's row is the best of four learning rates on the validation set (§4.3.2). QQP's 71.2 is test F1; on the validation set BERT-base scores about 87.5 F1 (Hugging Face's run_glue example, bert-base-cased, one seed), so the 15-point QQP win is an artefact of the split. Against that validation-set reference RoFormer is ahead only on MRPC (89.5 against 88.85) and behind on the other five (The paper's tables, rebuilt).
  • The pretraining budgets differ by 13 to 40 times. The GLUE RoFormer was pretrained for 100k steps of 64 × 512 tokens (3.3B tokens, §4.2.2); the BERT it is compared against trained for 1M steps of 256 sequences (43B tokens, since 90% of its steps used length 128; 131B if all were 512; BERT A.2). That alone could explain the three losses.
  • Single runs, no error bars, small margins. WMT's +0.2 BLEU comes from one run of each model with no significance test. On CAIL2019-SCM the gain over WoBERT is 1.69 points on test (2.0 on validation); with about 1,536 to 1,793 test triplets the standard error of that difference is about 1.6 points, so the gain is about one standard error (recompute.py; independent-samples bound, since per-example results are not released).
  • "Long text" is not extrapolation. RoFormer-1024 runs inside the 1,536 tokens it was pretrained at (Table 4, stages 2 and 5), while WoBERT is capped at 512 by its learned table. The result shows that a model which saw longer inputs uses them; it does not test running past the training length. When that was tested (ALiBi, Press et al., 2021), rotary degraded soon after the training length, like sinusoids, and so does this page's toy.
  • The decay is a bound. Figure 2 bounds the score; for generic queries and keys there is no decay (Barbero et al., 2024). The paper's own limitations section already concedes it cannot say why RoPE helps.
Four smaller problems: text against figure, the headline arithmetic, Table 4, the changed splits
  • The text and the figure disagree on the pretraining run. §4.2.2 says 100k steps; the x-axis of Figure 3 (left) runs to 250k. The plotted quantity is training loss, though §4.2.1 sets aside a 20% validation split.
  • The headline arithmetic. The paper says RoFormer-1024 "outperforms WoBERT by an absolute improvement of 1.5%"; Table 5 gives 69.79 − 68.10 = 1.69. The 1.5 is the gap to RoFormer-512 (69.79 − 68.29).
  • Table 4 is not evidence of generalisation. Accuracy rises with the stage's maximum length (correlation 0.96 with log length), but those are masked-token accuracies at each stage's own length: more context makes masked tokens easier to guess for any model, RoPE or not, and the stages are not a controlled comparison.
  • The splits changed between versions. v1 (April 2021, which had only the Chinese experiments) listed 5,102 / 1,500 / 1,536 triplets, 8,138 in all; v5 says 8,964 split 6:2:2, with the same accuracies.

Verdict: believe the mechanism, which is exact and was validated at scale by others and then by the whole field; treat the paper's tables as illustrations. Its evidence for "better than BERT" mixes test and validation splits and very different budgets, and its evidence for "long text" never leaves the trained length.

Why it matters (beyond the paper)

The paper's benchmark numbers were unremarkable; the formulation conquered the field anyway. Picked up first by the open-source side, in EleutherAI's codebases in April 2021 (blog) and GPT-J that year, then GPT-NeoX-20B ("based on our positive prior experiences", 2022), PaLM ("better performance on long sequence lengths", 2022) and LLaMA (2023), RoPE has been the default positional encoding of essentially every notable LLM since 2023. The properties that won: exact relative dependence with per-token absolute application (each cached key is rotated once, at cache time, so KV caching needs no recomputation), zero parameters, norm preservation, and applicability at every layer.

It also became the substrate of the whole long-context toolchain: larger bases, Position Interpolation, NTK-aware scaling, YaRN, partial and interleaved RoPE and M-RoPE each rewrite this paper's θi spectrum (or the positions it multiplies) in a model that already uses RoPE. Those methods are taught, measured and compared on Positional Encodings (sections 4 and 7); Then and now steps through them on this paper's spectrum.

Follow-ups in brief, as of October 2026 (who uses it, and the extension methods' headline facts)

Dated 2026-10-02, when this page was built; checked again 2026-10-25. The configs move; the owner page above keeps the current numbers.

  • Who uses it: Llama 1 to 3, Mistral and Mixtral, Qwen, DeepSeek, Gemma, gpt-oss (the LLM Architecture Gallery tracks the configs).
  • Base frequency scaling: train with a base larger than 10,000 for longer contexts, slowing the spectrum so it stays informative at long range. Llama 3 uses 500,000 (2024); 1,000,000 is common (Qwen3-8B, Qwen2.5, Mixtral 8x7B config.json files).
  • Position Interpolation (Meta, 2023): rescale positions m to m · Ltrain/Ltarget so every angle stays in the trained range; within 1,000 fine-tuning steps LLaMA reached 32,768 tokens with minimal degradation.
  • YaRN (2023): per-pair interpolation by wavelength ("NTK-by-parts") plus an attention temperature; DeepSeek-V3 extends by a factor of 40 from 4,096 (config) and gpt-oss by 32.
  • Decoupled RoPE: DeepSeek's MLA carries a small decoupled RoPE key (64 dimensions) beside the position-free compressed latent, because "RoPE is incompatible with low-rank KV compression" (DeepSeek-V2).
  • Interleaved and multimodal: Llama 4's iRoPE interleaves RoPE layers with layers that have no positional embedding, for length generalisation (Meta); Qwen2-VL's M-RoPE factors the rotation into time, height and width, reducing to 1D RoPE for text (2024).

Method aside, the 2D-pair rotation has become a standard reasoning tool: attention-sink analyses, length-generalisation theory and positional-encoding follow-ups are routinely phrased in RoPE's complex-exponential language (for example Barbero et al.).

Connections