NLP Lineage

20 April 2021 · Language modelling

RoPE

RoFormer: Enhanced Transformer with Rotary Position Embedding

J. Su, Y. Lu, S. Pan, A. Murtadha, B. Wen, Y. Liu

Date
20 April 2021
What the date marks
arXiv submission
Kind
Architectural idea
Organisation
Zhuiyi Technology
Access
Apache 2.0
Other dates
Neurocomputing 2024
Threads
In the guided tour
Chapter 10. Reading more than you remember
Learning phases
1. Transformer architecture

A turning point: 4 later milestones descend directly from it, and its descendants reach 9 of the 10 threads. How levels are decided

Drafted with Claude from the paper on 15 October 2026; reviewed by Zeeshan Arif. Read from arxiv.org (arXiv version 5 (November 2023); the paper was later published in the journal Neurocomputing (2024)).

What it changed

It gave Transformers a new way to know the order of tokens: rotate each query and key vector by an angle that depends on the token’s position. When two tokens are compared, only the difference between their positions is left. This method, rotary position embedding (RoPE), was taken up by many later large language models, such as LLaMA.

The problem before it

Attention on its own has no sense of word order. So a Transformer must add position information in some way. There were two main families:

The authors point out that almost all of these methods add the position information to the token representation or to the attention score. They argue that this does not work with “linear attention”, a cheaper form of attention that never computes the full table of scores.

The idea

The mechanism. Instead of adding a position vector, multiply by a rotation.

The authors list three useful properties:

The notation. The position-encoded query is f_q(x_m, m) = R_(Θ,m) W_q x_m, and the key is the same with W_k and position n. R_(Θ,m) is a block-diagonal matrix of 2 × 2 rotations by angles m θ_i, with θ_i = 10000^(−2(i−1)/d). Then q_m^T k_n = x_m^T W_q^T R_(Θ,n−m) W_k x_n, which depends on position only through n − m. (Section 3.3 writes the frequencies as 10000^(−2i/d), a slightly different indexing.)

What it showed

Reported in the paper. We read version 5 of the arXiv paper. The experiments are small, and all were run on two cloud servers with 4 GPUs each.

Limits, and what came later

The limits come from the paper, and from its own results:

Even so, RoPE spread widely. LLaMA and Qwen2 use it. Position interpolation rescales its positions to extend the context length. DeepSeek-V2 adapted it for its own attention design. ALiBi, a different position method from the same year, compared against it on longer inputs.

What to know first

How to read it

The paper is 14 pages, with 12 pages of main text.

  1. Read section 2 for the existing position methods. Equations 3 to 10 can be skimmed.
  2. Read section 3.2 with Figure 1. The two-dimensional case in 3.2.1 is the whole idea.
  3. Read section 3.3 for the three properties.
  4. Look at Tables 1, 2 and 5 for the results, and read section 4.5.5 for the authors’ limits.

Section 3.4 has the full derivation and is optional. Expect about 1.5 hours for the steps above (an estimate).

In brief, from the research data

Before it

Position was added to embeddings, either with sinusoids or learned vectors.

The problem

Added position vectors extrapolate badly past the trained length and encode distance only indirectly.

What it introduced

Rotate query and key vectors by an angle proportional to position, so attention scores depend on relative distance by construction.

Why it matters

Adopted by Llama, Mistral, Qwen, DeepSeek and most others. It is the position encoding of the current era.

What modern models inherit

Relative position through rotation, in nearly every open model you will run.

What came next

Position interpolation and YaRN extend RoPE to longer contexts.

Before and after

The milestones it descends from, and the milestones that descend from it. Work developed alongside it is not counted. Weak links are left out unless you include them.

Before: where it came from

RoPE has 11 documented ancestors across 4 chapters, reaching back to Recurrent networks in 1990. Showing its direct parents and the 4 turning points among them.

RoPE has 11 documented ancestors across 4 chapters, reaching back to Recurrent networks in 1990. Showing all of them.

RoPE has 12 recorded ancestors, including indirect ones, across 4 chapters, reaching back to Recurrent networks in 1990. Showing its direct parents and the 4 turning points among them.

RoPE has 12 recorded ancestors, including indirect ones, across 4 chapters, reaching back to Recurrent networks in 1990. Showing all of them.

  1. 2021RoPEThis milestone.
  2. 2019Transformer-XLRoPE was influenced by thisChapter 4. Pretrain once, use everywhere
  3. 2017Transformer Turning pointRoPE built directly on thisChapter 3. Attention, then only attention
  4. 2016Layer normTransformer built directly on thisChapter 3. Attention, then only attention
  5. 2015Residual connectionsTransformer was influenced by thisChapter 3. Attention, then only attention
  6. 2015Luong attentionTransformer was influenced by thisChapter 3. Attention, then only attention
  7. 2014AdamTransformer was influenced by thisChapter 2. Words become vectors
  8. 2014Seq2seq Turning pointTransformer built directly on thisChapter 2. Words become vectors
  9. 2014Attention Turning pointTransformer built directly on thisChapter 3. Attention, then only attention
  10. 2014GRU / encoder-decoderAttention built directly on thisChapter 2. Words become vectors
  11. 1997LSTM Turning pointSeq2seq built directly on thisChapter 1. Language as probability
  12. 1990Recurrent networksLSTM was influenced by thisChapter 1. Language as probability
  1. 2021RoPEThis milestone.
  2. 2019Transformer-XLRoPE was influenced by thisChapter 4. Pretrain once, use everywhere
  3. 2017Transformer Turning pointRoPE built directly on thisChapter 3. Attention, then only attention
  4. 2017ConvS2STransformer was influenced by this (indirect influence)Chapter 3. Attention, then only attention
  5. 2016Layer normTransformer built directly on thisChapter 3. Attention, then only attention
  6. 2015Residual connectionsTransformer was influenced by thisChapter 3. Attention, then only attention
  7. 2015Luong attentionTransformer was influenced by thisChapter 3. Attention, then only attention
  8. 2014AdamTransformer was influenced by thisChapter 2. Words become vectors
  9. 2014Seq2seq Turning pointTransformer built directly on thisChapter 2. Words become vectors
  10. 2014Attention Turning pointTransformer built directly on thisChapter 3. Attention, then only attention
  11. 2014GRU / encoder-decoderAttention built directly on thisChapter 2. Words become vectors
  12. 1997LSTM Turning pointSeq2seq built directly on thisChapter 1. Language as probability
  13. 1990Recurrent networksLSTM was influenced by thisChapter 1. Language as probability

After: what it led to

RoPE has 26 documented descendants across 5 chapters, reaching forward to Qwen3.8 in 2026. Showing its direct descendants and the 2 turning points among them.

RoPE has 26 documented descendants across 5 chapters, reaching forward to Qwen3.8 in 2026. Showing all of them.

RoPE has 29 recorded descendants, including indirect ones, across 5 chapters, reaching forward to Qwen3.8 in 2026. Showing its direct descendants and the 2 turning points among them.

RoPE has 29 recorded descendants, including indirect ones, across 5 chapters, reaching forward to Qwen3.8 in 2026. Showing all of them.

  1. 2021RoPEThis milestone.
  2. 2023LLaMA Turning pointbuilt directly on RoPEChapter 8. The weights get out
  3. 2023llama.cppwas influenced by LLaMAChapter 9. Making it run anywhere
  4. 2023Alpacabuilt directly on LLaMAChapter 8. The weights get out
  5. 2023LLaVAbuilt directly on LLaMAChapter 11. Seeing and hearing
  6. 2023QLoRAbuilt directly on LLaMAChapter 9. Making it run anywhere
  7. 2023Position interpolationbuilt directly on RoPEChapter 10. Reading more than you remember
  8. 2023Llama 2 Turning pointbuilt directly on LLaMAChapter 8. The weights get out
  9. 2024DeepSeek LLMwas influenced by Llama 2Chapter 8. The weights get out
  10. 2024OLMowas influenced by Llama 2Chapter 8. The weights get out
  11. 2024GRPObuilt directly on DeepSeek LLMChapter 12. Thinking longer
  12. 2024Gemmawas influenced by Llama 2Chapter 8. The weights get out
  13. 2024Llama 3built directly on Llama 2Chapter 8. The weights get out
  14. 2024DeepSeek-V2 / MLAbuilt directly on RoPEChapter 9. Making it run anywhere
  15. 2024Qwen2built directly on RoPEChapter 8. The weights get out
  16. 2024Llama 3.1 405Bwas influenced by Position interpolationChapter 8. The weights get out
  17. 2024DeepSeek-V3built directly on DeepSeek-V2 / MLAChapter 8. The weights get out
  18. 2025DeepSeek-R1built directly on DeepSeek-V3Chapter 12. Thinking longer
  19. 2025Llama 4succeeded Llama 3.1 405BChapter 8. The weights get out
  20. 2025Qwen3built directly on Qwen2Chapter 8. The weights get out
  21. 2025Kimi K2was influenced by GRPOChapter 8. The weights get out
  22. 2025DeepSeek-V3.2was influenced by DeepSeek-V2 / MLAChapter 10. Reading more than you remember
  23. 2026Qwen3.5built directly on Qwen3Chapter 8. The weights get out
  24. 2026Muse Sparksucceeded Llama 4Chapter 8. The weights get out
  25. 2026DeepSeek-V4built directly on DeepSeek-V3.2
    was influenced by DeepSeek-V3
    Chapter 8. The weights get out
  26. 2026Kimi K3built directly on Kimi K2Chapter 8. The weights get out
  27. 2026Qwen3.8built directly on Qwen3.5Chapter 8. The weights get out
  1. 2021RoPEThis milestone.
  2. 2023LLaMA Turning pointbuilt directly on RoPEChapter 8. The weights get out
  3. 2023llama.cppwas influenced by LLaMAChapter 9. Making it run anywhere
  4. 2023Alpacabuilt directly on LLaMAChapter 8. The weights get out
  5. 2023LLaVAbuilt directly on LLaMAChapter 11. Seeing and hearing
  6. 2023QLoRAbuilt directly on LLaMAChapter 9. Making it run anywhere
  7. 2023Position interpolationbuilt directly on RoPEChapter 10. Reading more than you remember
  8. 2023Llama 2 Turning pointbuilt directly on LLaMAChapter 8. The weights get out
  9. 2024DeepSeek LLMwas influenced by Llama 2Chapter 8. The weights get out
  10. 2024OLMowas influenced by Llama 2Chapter 8. The weights get out
  11. 2024GRPObuilt directly on DeepSeek LLMChapter 12. Thinking longer
  12. 2024Gemmawas influenced by Llama 2Chapter 8. The weights get out
  13. 2024Llama 3built directly on Llama 2Chapter 8. The weights get out
  14. 2024DeepSeek-V2 / MLAbuilt directly on RoPEChapter 9. Making it run anywhere
  15. 2024Qwen2built directly on RoPEChapter 8. The weights get out
  16. 2024Llama 3.1 405Bwas influenced by Position interpolationChapter 8. The weights get out
  17. 2024DeepSeek-V3built directly on DeepSeek-V2 / MLAChapter 8. The weights get out
  18. 2025DeepSeek-R1built directly on DeepSeek-V3Chapter 12. Thinking longer
  19. 2025Llama 4succeeded Llama 3.1 405BChapter 8. The weights get out
  20. 2025Qwen3built directly on Qwen2Chapter 8. The weights get out
  21. 2025Kimi K2was influenced by DeepSeek-V3 (indirect influence)Chapter 8. The weights get out
  22. 2025gpt-osswas influenced by DeepSeek-R1 (indirect influence)Chapter 8. The weights get out
  23. 2025GLM-4.5was influenced by DeepSeek-R1 (indirect influence)Chapter 8. The weights get out
  24. 2025DeepSeek-V3.2was influenced by DeepSeek-V2 / MLAChapter 10. Reading more than you remember
  25. 2026Qwen3.5built directly on Qwen3Chapter 8. The weights get out
  26. 2026Muse Sparksucceeded Llama 4Chapter 8. The weights get out
  27. 2026DeepSeek-V4built directly on DeepSeek-V3.2
    was influenced by DeepSeek-V3
    Chapter 8. The weights get out
  28. 2026GLM-5.2built directly on GLM-4.5Chapter 8. The weights get out
  29. 2026Kimi K3built directly on Kimi K2Chapter 8. The weights get out
  30. 2026Qwen3.8built directly on Qwen3.5Chapter 8. The weights get out

Direct links and their sources

Where it came from

Built directly on

Influenced by

What it led to

Built on directly by

Developed alongside

Terms