In plain words: Rotary encodings spin the vectors a model compares by how far apart words are; tracing a trained Gemma model shows they are not mainly for fading distant words. Fastest spins build position patterns while slowest carry meaning; fixing the slow ones improves performance.
Abstract · Round and Round We Go! What makes Rotary Positional Encodings useful?
Positional Encodings (PEs) are a critical component of Transformer-based Large Language Models (LLMs), providing the attention mechanism with important sequence-position information. One of the most popular types of encoding used today in LLMs are Rotary Positional Encodings (RoPE), that rotate the queries and keys based on their relative distance. A common belief is that RoPE is useful because it helps to decay token dependency as relative distance increases. In this work, we argue that this is unlikely to be the core reason. We study the internals of a trained Gemma 7B model to understand how RoPE is being used at a mechanical level. We find that Gemma learns to use RoPE to construct robust "positional" attention patterns by exploiting the highest frequencies. We also find that, in general, Gemma greatly prefers to use the lowest frequencies of RoPE, which we suspect are used to carry semantic information. We mathematically prove interesting behaviours of RoPE and conduct experiments to verify our findings, proposing a modification of RoPE that fixes some highlighted issues and improves performance. We believe that this work represents an interesting step in better understanding PEs in LLMs, which we believe holds crucial value for scaling LLMs to large sizes and context lengths.
Federico Barbero, Alex Vitvitskyi, Christos Perivolaropoulos, Razvan Pascanu, Petar Veličković
arXiv:2410.06205 · cs.CL, cs.LG · submitted Oct 8, 2024 · updated May 13, 2025
abstract · pdf · html
In electronics, rotary positional encoders are often used to replace traditional analog potentiometers (variable resistors) for things like audio volume controls or frequency equalizers.
Like the title says "Round and Round We Go!" this encoder type of physical control knob has no maximum stopping point, unlike the potentiometer where you have the tactile feedback and you can easily feel when the old-school control is all the way up.
Once you reach maximum volume or gain with an encoder knob, you can keep turning it clockwise another 360 degrees forever, it gives the impression that you're "cranking it up to 11" but nothing ever changes beyond that point.
Maybe some of the same differences apply when it comes to the virtual rotary position encoders used in the LLMs.