Understanding Positional Embeddings in Modern LLMs
TutorialPublished: Source: Hacker News (100+ points)
TL;DR:Sebastian Raschka publishes a technical walkthrough of how language models represent token positions, covering learned absolute embeddings, sinusoidal encodings, RoPE, and approaches that rely on implicit position information.

Sebastian Raschka publishes a technical walkthrough of how language models represent token positions, covering learned absolute embeddings, sinusoidal encodings, RoPE, and approaches that rely on implicit position information. The tutorial uses visual examples, mathematical explanations, and a small PyTorch implementation, and previews positional choices in open-weight models from 2026. It also explains the context-length cost of learned position tables, noting that for GPT-2 Medium they would exceed 22% of model weights at a 100,000-token context, compared with 0.30% at 1,024 positions.
Key points
- Explains learned absolute position embeddings, sinusoidal encodings, RoPE, and implicit positional information from causal attention.
- Shows how RoPE applies positional information within attention blocks, unlike GPT-2's addition of position vectors at the input.
- Estimates that GPT-2 Medium's learned position table would comprise over 22% of model weights at a 100,000-token context, versus 0.30% at 1,024.
Why it matters
Understanding positional methods helps model builders evaluate context-window design and interpret architecture choices in modern LLMs. The tutorial also provides a practical foundation for engineers studying attention internals and recent open-weight models.
Companies and models mentioned
- Sebastian Raschka
- RoPE
- GPT-2
- MiniMax-M3
- PyTorch