Hacker News·First covered 15 Nov 2026HN front page
Understanding Positional Embeddings in Modern LLMs
Sebastian Raschka walks through how LLMs encode token order, from GPT-2's learned position vectors to RoPE, with PyTorch code and a survey of what 2026 open-weight models use.
Stats
(As of 17 Nov 2026)- Points
- 245
- Comments
- 27
- Submitted by
- vismit2000
- Posted
- 1d
- Attention with no position signal treats reordered words the same; a causal mask adds some implicit order but says nothing about distance.
- GPT-2 adds a learned position vector to each token embedding, which caps its context at the 1,024 positions in that table.
- Growing that table to around 100k positions would make it over 22% of GPT-2 Medium's weights, one reason newer models drop the approach.
- The original 2017 transformer used fixed sine and cosine encodings, an idea that returns as the basis for RoPE.
- Recent models such as MiniMax-M3 apply RoPE inside every attention layer rather than once at the input; the piece also covers NoPE.