# Rotary Position Embedding

> Rotary position embedding (RoPE) is a way of encoding token positions in a transformer by rotating the query and key vectors by angles proportional to each token's position, so that attention scores depend on the relative distance between tokens.

- Identifier: PTL-0251
- Category: Foundations
- Canonical URL: https://protologue.com/t/rotary-position-embedding/
- Also known as: RoPE, rotary embeddings, rotary positional encoding, RoFormer
- Introduced: 2021

## Description

Su et al. proposed it with the RoFormer model in 2021. It encodes absolute position with a rotation matrix while building relative position into self-attention, works with variable sequence lengths, and makes the dependency between tokens decay as their distance grows. It became a common position encoding in later large language models, and the length of context a model handles well is closely tied to how its rotary embeddings were trained.

## Related terms

- [Context Window](https://protologue.com/t/context-window/)
- [Large Language Model](https://protologue.com/t/large-language-model/)
- [Token](https://protologue.com/t/token/)

## Sources

- Su et al. (2021). RoFormer: Enhanced Transformer with Rotary Position Embedding. https://arxiv.org/abs/2104.09864

## Cite this entry

Protologue. (2026). Rotary Position Embedding. In Protologue: A Taxonomy of Prompting and LLM Techniques (v1.7.0, PTL-0251). https://protologue.com/t/rotary-position-embedding/

License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
