# Rotary Positional Embedding (RoPE)

- **Canonical URL:** https://getaimath.com/dictionary/rotary-positional-embedding-rope/
- **Topics:** [Transformer Architecture](https://getaimath.com/dictionary/category/transformer-architecture/)
- **Last updated:** 2026-11-25

## What is Rotary Positional Embedding (RoPE)?

**In one sentence:** RoPE is a popular way to tell a model about word positions by rotating its query and key numbers by an angle based on position.

Imagine each token's numbers as arrows. RoPE turns each arrow by an amount that depends on where the token is. When two tokens are compared, the difference in their angles tells the model how far apart they are. This works well and can be stretched to longer texts.

![Transformers & Attention: The Smart Highlighter — Simple cartoon diagram showing how a Transformer reads a whole sentence at once and shines a bright highlighter beam from the word "IT" back to "trophy" so it knows what "IT" means.](https://getaimath.com/diagrams/transformer-architecture.png)
*Napkin Diagram (Transformer Architecture): Older AI read word-by-word and often lost track of earlier words; a Transformer highlights which words connect to which.*

## What is an example of Rotary Positional Embedding (RoPE)?

With RoPE, the model naturally knows that words 5 and 7 are close, while words 5 and 500 are far apart.

## Why does Rotary Positional Embedding (RoPE) matter?

RoPE is used in Llama, Qwen, Mistral and many other models, and it helps extend context length.

## Related Concepts

- [Positional Encoding](https://getaimath.com/dictionary/positional-encoding/): Positional encoding adds information about word order, so the model knows which word came first, second, and so on.
- [ALiBi](https://getaimath.com/dictionary/alibi/): ALiBi is a simple way of handling word position by adding a penalty to attention scores based on how far apart two words are.
- [Attention Mask](https://getaimath.com/dictionary/attention-mask/): An attention mask is a pattern that tells the model which positions it may or may not attend to.
- [Feed-Forward Network (FFN)](https://getaimath.com/dictionary/feed-forward-network-ffn/): A feed-forward network is the part of each Transformer block that processes each token on its own after attention.
- [FlashAttention](https://getaimath.com/dictionary/flashattention/): FlashAttention is a clever way to compute attention on GPUs that is much faster and uses much less memory, while giving the same results.
- [Multi-Layer Perceptron (MLP)](https://getaimath.com/dictionary/multi-layer-perceptron-mlp/): A multi-layer perceptron is a basic neural network made of layers of neurons where every neuron connects to every neuron in the next layer.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/rotary-positional-embedding-rope/)
