Positional Embeddings in Modern LLMs: RoPE, Partial RoPE, and NoPE Explained
Sebastian Raschka's article 'Understanding Positional Embeddings in Modern LLMs' is a detailed technical walkthrough of how large language models encode token order, from GPT-2's learned absolute position vectors and the original Transformer's sinusoidal encodings to RoPE, partial RoPE, NoPE, and learned relative position bias. The main takeaway is that RoPE remains the dominant positional method in open-weight LLMs, but the article's 2026 architecture snapshot shows a measurable shift toward partial RoPE and mixed RoPE/NoPE designs.
Why LLMs need positional information
Positional information is required because token embeddings alone do not encode order. In the sentence 'The red fox jumps over the gray fox,' the two occurrences of 'fox' receive the same token ID and therefore the same token embedding. If attention has no positional signal and no causal mask, swapping 'red' and 'gray' produces the same embeddings and the same pairwise attention scores. A causal mask gives some implicit order information because a token can attend only to itself and earlier tokens, but the mask does not distinguish a gap of one position from a gap of ten. Explicit positional methods supply that missing distance signal.
GPT-2 uses learned absolute positional embeddings
GPT-2 learns a table of position vectors during training and adds each position vector to the corresponding token embedding before the first transformer block. The input to the first block is h_m = E_token(x_m) + P_m, where E_token is the token embedding layer, P_m is the position vector selected by position m, and h_m is the summed embedding. The method is absolute because P_m depends on the token's own position.
The original GPT-2 implementation has 1,024 learned position vectors, so it only supports inputs of 1,024 tokens or fewer. Extending the context requires extending the table, which is expensive because the table is trained along with the rest of the model. In GPT-2 Medium, the positional embedding weights make up only 0.30% of total weights at 1,024 positions, but at a 100k context they would make up more than 22% of total model weights. GPT-2 initialized token embeddings with standard deviation 0.02 and position embeddings with standard deviation 0.01, which kept the two roughly on the same scale without additional normalization.
The original Transformer uses fixed sinusoidal encodings
The 2017 'Attention Is All You Need' Transformer uses the same addition mechanism but computes position vectors with fixed sine and cosine functions instead of learning them. It also scales token embeddings by sqrt(d_model) before adding position vectors: h_m = sqrt(d_model) * E_token(x_m) + P_m. The position vector entries are P_m,2i = sin(m / 10000^(2i/d_model)) and P_m,2i+1 = cos(m / 10000^(2i/d_model)), where m is the position and i indexes a pair of features in the vector.
For an eight-feature example, the four feature pairs have frequencies 1, 0.1, 0.01, and 0.001 radians per position. At position 2, the first pair is approximately (sin 2, cos 2) = (0.909, -0.416), and the second pair is approximately (sin 0.2, cos 0.2) = (0.199, 0.980). The sinusoidal method is still absolute because each vector is computed from the token's own absolute position, but the sine and cosine functions stay fixed during training. The authors argued that fixed offsets produce fixed rotations, so attention can learn relative relationships. The paper states: "...easily learn to attend by relative positions, since for any fixed offset k, PE_pos + k can be represented as a linear function of PE_pos." The sinusoidal encodings can be evaluated beyond the training context length, but that alone does not guarantee good performance beyond the training range.
RoPE encodes relative position by rotating queries and keys
Rotary Position Embedding, introduced by Su et al. in the 2021 RoFormer paper, is a relative position method that operates inside attention. Each token's current representation is projected into query, key, and value vectors. RoPE rotates the query and key vectors according to token position before their dot product; value vectors bypass the rotation. For a query pair (a, b) at position m, RoPE computes a' = a * cos(m * theta) - b * sin(m * theta) and b' = a * sin(m * theta) + b * cos(m * theta). A key pair at position n uses the same equations with n * theta.
The frequency for each feature pair is theta_i = b^(-2i/d), where d is the head dimension, i ranges from 0 to d/2 - 1, and b is a chosen base value. The RoFormer paper uses b = 10,000. For a head dimension of d = 8 and base b = 10,000, the four frequencies are 1, 0.1, 0.01, and 0.001 radians per position.
A concrete example makes the relative property clear. Suppose the query comes from position 5 and the key comes from position 2, both starting from the feature pair (1, 5), and the rotation is 20 degrees per position. The key rotates by 40 degrees and the query rotates by 100 degrees. Before rotation, the pair's dot product is 1 * 1 + 5 * 5 = 26. After rotation, the dot product for that pair is approximately 13. Both vectors have length sqrt(26), and the angle between them is 60 degrees, so the exact dot product is 26 * cos(60 degrees) = 13. If both positions shift by three positions, the query moves to position 8 and the key moves to position 5. Each rotation gains 60 degrees, but the angle between the vectors stays the same, so the dot product remains 13. RoPE makes the query-key dot product depend on the offset between tokens for fixed pre-rotation features.
RoPE implementation and layout choices
A RoPE implementation precomputes cosine and sine tables. For a context size of 1,024 and a head dimension of 128, the tables each have shape (1024, 64), because a 128-feature head has 64 feature pairs. The tables have no batch or head dimension; they are broadcast across batch items and attention heads. The same table entries can be reused across queries, keys, and heads that share positions and frequencies. Only queries and keys pass through RoPE.
The split-half layout pairs each feature in the first half of a head with the corresponding feature in the second half. For an eight-feature vector [1, 2, 3, 4, 5, 6, 7, 8], the pairs are (1, 5), (2, 6), (3, 7), and (4, 8). The original RoPE paper and the original LLaMA implementation use the interleaved layout, which pairs adjacent features. The two layouts are mathematically equivalent when the feature order is rearranged consistently: rearranging [1, 2, 3, 4, 5, 6, 7, 8] to [1, 5, 2, 6, 3, 7, 4, 8] makes split-half pairs adjacent. Applying the same rearrangement to both queries and keys gives identical dot products, while applying different layouts to the original vector gives different scores. Most modern code implementations use the split-half layout because it allows all pairs to be rotated at once with element-wise sine and cosine operations.
Modern variants: partial RoPE, NoPE, and learned relative bias
Partial RoPE rotates only a subset of features
MiniMax-M3 uses 64 rotary dimensions within each 128-dimensional head: 32 rotated feature pairs and 64 unchanged dimensions. Partial RoPE reduces the size of the precomputed cosine and sine tables. For MiniMax-M3's 1M-token context, rotating 64 of 128 features halves the table size, saving 0.134 GB (128 MiB) in BF16 or 0.038 GB (36 MiB) in NVFP4 including block scales. Partial RoPE does not shrink the KV cache, which still stores full key and value vectors. The 'Fractional Rotation, Full Potential?' paper found that rotating around 10% of each head's features often gave similar training loss and benchmark accuracy to full RoPE in 1B to 8B models, although full RoPE did better on some evaluations. Raschka's assessment is that partial RoPE is hardly worth it.
NoPE relies on the causal mask for implicit position
NoPE means no explicit positional encoding. The idea is that a causal attention mask already gives implicit positional information because a query can attend only to itself and earlier tokens. In a toy example, suppose one feature of the value vectors is 1 for 'The' and 0 for the other tokens. If all visible keys receive equal attention weight, the output feature equals one over the prefix length: 1/3 at 'fox' in a three-token prefix, 1/4 at 'jumps' in a four-token prefix. A later layer can use that value as a position signal.
The NoPE paper trained a 107M-parameter decoder-only transformer from scratch on tasks such as copying, sorting, and addition. On examples longer than those seen during training, NoPE ranked first overall across ten tasks and ahead of RoPE on length generalization. A separate 1.3B-parameter model trained on code handled contexts beyond the training length, but its next-token predictions got worse at the longest lengths tested. SmolLM3, a 3B-parameter model, applies RoPE in three layers and skips it in the fourth, repeating that pattern through 36 layers. The SmolLM3 authors reported that this layer pattern improved long-context performance. Later layers that skip RoPE still receive inputs from preceding transformer blocks, so their queries and keys still carry position information inherited from earlier layers.
Learned relative position bias adds a score before softmax
Thinky's Inkling uses a learned relative position bias in both sliding-window and global attention layers. It computes the usual scaled query-key dot product and adds a learned number to that score before softmax. The number depends on the query token's hidden state and on how many positions back the key is. This is not an entirely new idea: Google's T5 used a simpler version of a relative position bias in 2019. xLSTM 7B has no softmax attention layers at all and falls into the 'Other' category in Raschka's gallery.
What 2026 open-weight architectures use
Raschka grouped entries in his LLM Architecture Gallery by release date to compare 2025 and 2026 open-weight models. RoPE in every softmax attention layer remains the most common choice, but its share fell from 2025 to 2026 and fell again in the latter half of 2026. A growing number of models mix RoPE and NoPE, although those groups remain small. Among models that use RoPE, partial RoPE became more common: it was a minority of RoPE models in 2025 and a majority in both 2026 groups. NoPE-only entries were all recurrent hybrids with softmax attention layers. The 'Other' category includes xLSTM 7B from 2025 and Inkling from 2026. Raschka expects RoPE to remain the predominant method into 2027, with a possibility that more Inkling-like designs appear in 2027.
The Hacker News discussion adds a group-theoretic framing
The Hacker News post drew 168 points and 13 comments. The main substantive comment, by programjames, argued that an implementation walkthrough is not the same as the theory of positional embeddings. The comment states: "Positional embeddings are group representations." It frames RoPE as a representation of the translation group: the n-dimensional translation group is abelian, so its irreducible representations are one-dimensional and specified by a momentum vector, and a multi-dimensional representation can be built by choosing several momentum vectors as learnable parameters. The comment also discusses representations of the special Euclidean group for embeddings that preserve rotation, and affine transformations for attention on quadtrees, where nodes are labeled by translation and depth and finite-dimensional representations involve momentum vectors, a modulus, and basis vectors. This theoretical framing complements Raschka's mechanical and architectural explanation rather than contradicting it: Raschka explains how positional methods are built and which models use them, while the comment explains where such constructions come from mathematically.
Practical implications
Positional embedding choices affect context length, memory use, and long-context generalization. Learned absolute embeddings tie the maximum context to the size of the learned table. Sinusoidal encodings are fixed and can be evaluated beyond the training range, but they remain absolute. RoPE encodes relative position directly in attention and remains the dominant method in open-weight LLMs. Partial RoPE reduces precomputed cosine and sine table memory but does not reduce the KV cache. NoPE exploits the causal mask for implicit position information and appears in mixed architectures such as SmolLM3. Learned relative position bias is another option, used by Inkling. For practitioners building from scratch, a GPT-2-style baseline is the simplest starting point; RoPE is the next major building block to add; and modern architecture galleries show how production models combine and adapt these choices.