⏱️ Reading time: 8 min

Swap the order of two words in a sentence, and the meaning can flip entirely. “The red fox jumps over the gray fox” and “the gray fox jumps over the red fox” share the same words, but they change who jumps over whom. For a neural network that turns each word into a vector, that difference isn’t automatic: the model has to be told explicitly which position in the sequence each token occupies. That problem, representing position inside a language model, is solved by what’s known as positional embeddings, and the method that dominates open LLMs in 2026 is called RoPE, short for Rotary Position Embedding, originally described in the RoFormer paper (Su et al.).

📑 En este artículo
  1. How position enters a language model
  2. How RoPE rotates attention vectors
  3. What this means if you’re extending a model’s context
  4. RoPE versus other positional embedding methods
  5. Where RoPE falls short
  6. Frequently Asked Questions
    1. Did RoPE completely replace absolute embeddings?
    2. Can I convert a model already trained with absolute embeddings to RoPE without retraining?
    3. Why do some models skip explicit positional encoding altogether?
  7. References

How position enters a language model

A tokenizer turns text into numeric IDs, and an embedding layer maps each ID to a feature vector. Up to that point, the model knows nothing about order: the word “fox” gets the same vector whether it appears first or last. Position gets added later, and exactly when it gets added changes depending on the architecture, as Sebastian Raschka explains in his review of the positional methods used in modern LLMs (Understanding Positional Embeddings in Modern LLMs).

GPT-2, a classic model, adds a position vector to each token embedding before the sequence enters the first transformer block. Position is fixed once, at the start. MiniMax-M3, a recent open model, does something different: it injects positional information inside every transformer block, using RoPE directly in the attention mechanism (source). Position is no longer a fixed value that travels with the token; it gets recomputed at every layer, based on how far one token is from another.

The same article points out a detail few readers would notice: of MiniMax-M3’s 60 feedforward layers, the first three are dense rather than mixture-of-experts, or MoE (source). It’s a minor architectural detail, but a useful one for anyone comparing MoE models, since not even every layer within the same model uses the same strategy.

RoPE rotates attention vectors at every layer, not just once. Foto de Hitesh Choudhary en Unsplash

How RoPE rotates attention vectors

The idea behind RoPE is geometric. In the attention mechanism, each token produces a query vector and a key vector; the similarity between the two decides how much attention one token pays to another. RoPE takes those vectors and rotates them in pairs of dimensions, at an angle that depends on the token’s position in the sequence. A token at position 3 rotates its components by a different angle than a token at position 30.

What makes RoPE useful isn’t the rotation itself, but what happens when a rotated query and a rotated key are multiplied together. The result depends only on the distance between the two positions, not on where the sequence starts or ends. Two tokens five positions apart produce the same geometric relationship whether they sit at the beginning or the end of a 50,000-token document. That property, relative rather than absolute position, is what lets a model generalize better to sequences longer than those seen during training, at least up to a point.

This contrasts with GPT-2’s absolute embeddings, where every position has its own learned vector memorized during training. If the model never saw position 10,000 during training, that vector simply doesn’t exist, and the model has no way to represent it.

What this means if you’re extending a model’s context

If you fine-tune or adapt an open-weight model (Llama, Qwen, Mistral) to accept a longer context than it trained on, the positional method it uses decides which extension technique will actually work. A model built on RoPE supports techniques that rescale the rotation’s base frequency, such as NTK-aware scaling or YaRN, to stretch the context without retraining from scratch. A model using ALiBi or no explicit encoding doesn’t benefit from those techniques, because there’s no frequency to rescale.

The practical recommendation, before applying any context-extension recipe found in a repo or a paper, is to first confirm which positional mechanism the model in front of you actually uses. Applying a scaling method designed for RoPE to a model that doesn’t use RoPE won’t throw an immediate, visible error, but it degrades response quality on long contexts in ways that are hard to diagnose.

Concretely, the first place to check is the model’s configuration file. In models compatible with Hugging Face’s Transformers library, the rope_theta and max_position_embeddings fields indicate whether the model uses RoPE, what its base frequency is, and what the original training window was. If those fields don’t appear, that’s a sign the model uses a different mechanism, and RoPE-specific scaling recipes won’t apply.

If instead you’re evaluating which open model to adopt for a project that needs long documents (contracts, logs, an entire repository’s codebase), the positional method is an indirect signal of how well the model will behave outside its advertised context window. A well-tuned RoPE model tends to degrade more gradually as it approaches the advertised limit; a model with absolute embeddings simply has no representation for positions it never trained on.

RoPE versus other positional embedding methods

RoPE isn’t the only way to solve this problem. Over the recent history of LLMs, at least four approaches have coexisted, each injecting position differently.

MethodHow it worksWhere it’s appliedMain limitation
Learned absolute embeddings (GPT-2)A trained position vector for each sequence index, added to the token embeddingOnce, before the first transformer blockDoesn’t generalize beyond the maximum length seen in training
RoPE (rotary position embedding)Rotates query and key vectors in attention space based on the relative distance between tokensInside every attention layerDegrades on contexts much longer than training unless the base frequency is rescaled
ALiBi (attention with linear biases)Subtracts a penalty proportional to distance directly from attention scores, without position vectorsInside every attention layerThe linear bias oversimplifies positional relationships that aren’t always linear
No explicit encoding (NoPE)No separate position signal; the model infers order only from the causal maskNot applicable within the architectureDepends on the model learning order implicitly, something not every architecture does equally well

Absolute embeddings have one advantage: they’re simple to implement and understand. The model learns directly what it means to be at position 5. The cost shows up when you try to extend the context beyond what was trained, because there’s no position 50,000 the model ever learned to represent. RoPE changes the deal: instead of learning an absolute position, it encodes the relative distance between pairs of tokens, and that relationship can, up to a point, be extrapolated mathematically to new distances.

The choice isn’t just academic. Raschka’s own article contrasts GPT-2, which uses learned absolute embeddings, with MiniMax-M3, a recent open model that chose RoPE for every attention layer (source). ALiBi (Press et al.), by contrast, avoids position vectors entirely and subtracts a distance-proportional penalty directly from the attention scores.

ALiBi penalizes distance without using position vectors. Foto de Numan Ali en Unsplash

Where RoPE falls short

RoPE solves the relative-position problem, but it isn’t free. Applying the rotation at every attention layer costs more compute than adding a position vector once at the start, as GPT-2 does. In models with dozens of layers, that cost repeats at each one.

The other limit is extrapolation. A model trained with a context window of, say, 8,000 tokens doesn’t rotate well far beyond that range without help, because the base frequency that worked during training stops representing distances it never saw. That’s why rescaling techniques like YaRN emerged, adjusting that frequency to extend context without retraining the whole model. And the choice of base frequency itself isn’t universal: it varies from one model family to the next, so a value can’t be copied from one model and applied to another without checking first.

There’s a third, subtler limit. RoPE’s rotation frequencies are periodic. In theory, two positions far apart can end up with similar rotation angles, which can cause the model to confuse them. Rescaling techniques don’t just stretch the context; they also try to keep those repetitions from showing up within the range the model will actually use.

📬 Get new articles by email

We only email about big articles (1-2 a month).

Frequently Asked Questions

Did RoPE completely replace absolute embeddings?

Not in every model, but in most recent releases, yes. The contrast between GPT-2 (absolute embeddings) and MiniMax-M3 (RoPE) that Raschka shows reflects that trend (source), though architectures using ALiBi or no explicit encoding still coexist with it.

Can I convert a model already trained with absolute embeddings to RoPE without retraining?

Not directly. The positional mechanism is woven into every attention layer during training, so changing it requires retraining the model or a substantial fine-tune, not a simple architectural patch.

Why do some models skip explicit positional encoding altogether?

Because, in theory, the causal mask in attention, which prevents a token from seeing the ones that come after it, already carries some indirect information about order. Models without explicit positional encoding (NoPE) bet that this signal, combined with enough training, is enough for the model to infer order on its own. It’s a less production-tested approach than RoPE or absolute embeddings.

References

Featured image: Foto de Chris Ried en Unsplash

How each article is made (sources, testing and editorial criteria): How we work.

Did it work for you? Got a different error? Say so below: questions get answered and help the next reader.

Leave a comment

El Solitario Editorial

Article prepared by the El Solitario editorial team from cited sources, under the editorial responsibility of Luis Navarro. More details in "How we work".

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

You can include code inside <code>…</code> or, for several lines, <pre><code>…</code></pre>.

This site uses Akismet to reduce spam. Learn how your comment data is processed.