Understanding Positional Embeddings in Modern LLMs magazine.sebastianraschka.com...

@best30

Understanding Positional Embeddings in Modern LLMs magazine.sebastianraschka.com · 199 points · 27 comments · HN thread

TL;DR Sebastian Raschka's long tutorial explains how LLMs encode token position: from GPT-2's learned absolute position vectors and the original transformer's sinusoidal encodings, to RoPE, which rotates query and key vectors inside attention. It also surveys 2026 open-weight models, noting RoPE remains most common while partial RoPE, NoPE layers and learned relative biases (Inkling) are growing. The thread, with 27 comments, is mostly a debate about whether positional embeddings have a principled group-theory basis or are empirical trial and error.

  • GPT-2 adds a learned position vector to each token embedding; its 1,024-entry table limits context and grows costly at long contexts (positional weights would exceed 22% of GPT-2 Medium's weights at 100k).
  • The original transformer uses fixed sine and cosine position vectors, which the authors hypothesized make relative offsets easy to learn.
  • RoPE rotates each query and key feature pair by an angle proportional to token position, so the dot product depends only on the relative offset; the author verifies this with a PyTorch example.
  • NoPE relies on the causal mask alone for position signal; in a NoPE paper's experiments it generalized to longer lengths on some tasks, but got worse next-token predictions at the longest lengths on a 1.3B code model.
  • Partial RoPE (e.g., MiniMax-M3 rotating 64 of 128 head dimensions) became a majority among RoPE models in 2026 groups, though the author is skeptical it is worth it.
  • Inkling uses a learned relative position bias added to attention scores before softmax, an idea related to Google's T5; RoPE is still the most common choice in the gallery data.

Discussion The thread is largely a theoretical side debate rather than a discussion of the article's engineering content. Top comment argues that positional embeddings are best understood as group representations, with RoPE as a representation of the translation group, and extends the idea to rotations, quadtrees and Gaussian splats. Several commenters push back that this is post-hoc rationalization of empirical findings, and a few question the physics analogy (electrons and quarks from spacetime symmetries). The mood is argumentative but intellectually engaged, with some frustration that ML theory often lacks explanation of why methods work.

  • Group theory is the right lens for positional embeddings (some): Commenters argue RoPE is a representation of the translation group and that the theory tells you how to design and parameterize new position schemes, such as for trees or 3D data. They say the article skips the theory needed to understand why these methods make sense.
  • Positional embedding theory is post-hoc rationalization of what works (many): Many commenters argue that ML researchers try methods empirically and only later build theory, so group-theoretic framing is retrofitted. They view this as normal alchemy-style progress, citing Ali Rahimi's NIPS 2017 talk.
  • Frustration with ML papers that lack explanation (some): Some readers say they want papers to state what was tried, what seems to work, and a hedged hypothesis for why, instead of formal math presented as if it explained success.
  • Group-theory framing is overkill or misapplied for this audience (a few): Some commenters say the post is aimed at practitioners and that the abstract algebra is out of scope, or call the physics analogy (electrons from translation/rotation symmetry) misleading, since spacetime symmetries do not determine specific particles.
  • Structural solutions like NoPE may make explicit representations unnecessary (a few): One commenter suggests that solutions built into the architecture, as NoPE is, avoid needing explicit group representations altogether.
  • Point readers to a better explanation (some): Several commenters recommend external write-ups, including a Jane Street blog post on group theory and positional encodings and the original RoPE author's blog post explaining the motivation.

Links from the comments

#positionalEmbeddings #RoPE #transformers #attention #LLMArchitecture #groupTheory