ModelRefs / RoPE (Rotary Positional Embedding) — AI Glossary

RoPE (Rotary Positional Embedding) — AI Glossary

A relative positional encoding that rotates query/key vectors in the complex plane, enabling strong long-context extrapolation.

Overview

RoPE (Su et al. 2021) encodes position by rotating Q and K matrices at each head. Because it represents relative rather than absolute position, it generalizes beyond training length when combined with techniques like YaRN or LongRoPE. Used in LLaMA, Mistral, Qwen, and most frontier open-weights models.

Reference details

Topicarchitecture
Also known asrotary embedding, rotary position embedding
Last reviewed2026-06-24

Example: Why relative position is the useful property

RoPE rotates the query and key vectors by an angle proportional to their position. Because the dot product of two rotated vectors depends only on the difference of the two angles, the attention score between positions 100 and 105 has the same geometry as between 1,000 and 1,005 — the model sees “five apart”, not “at 1,000”. That is what makes context extension tractable: methods that rescale or interpolate the rotation frequencies stretch the same learned relative structure over a longer window, instead of asking the model to handle absolute positions it never saw in training.

Commonly confused with

RoPE encodes relative position by rotation inside attention; learned absolute embeddings add a per-position vector at the input; ALiBi adds a distance-proportional penalty to attention scores. All three are “positional encoding”, and only the latter two are added to anything — RoPE modifies the vectors in place, which is why it composes with attention kernels so cleanly.

When to use it

Reach for it when:

  • Designing or fine-tuning a decoder that may need to run beyond its training length
  • Reasoning about why a context-extension technique works and what it costs
  • Interpreting a model card that lists a base frequency — it governs the extension headroom

Reach for something else when:

  • Assuming extension is free: stretching the window degrades quality without adaptation or continued training
  • Comparing context lengths across models as if the mechanism were identical
  • As an explanation for retrieval failures inside the window, which are an attention problem

Primary source

Continue your research

Use these connected ModelRefs sections to compare alternatives, inspect implementation paths, and review the evidence and governance boundaries relevant to RoPE (Rotary Positional Embedding) — AI Glossary.

Frequently asked questions

What is RoPE (Rotary Positional Embedding)?

A relative positional encoding that rotates query/key vectors in the complex plane, enabling strong long-context extrapolation.

Is RoPE (Rotary Positional Embedding) the same as rotary embedding?

Yes — rotary embedding, rotary position embedding are common aliases for RoPE (Rotary Positional Embedding).

What concepts are related to RoPE (Rotary Positional Embedding)?

Closely related concepts include positional encoding, alibi, long context.