flâneur — a map of the web's best reading

N-dimensional Rotary Positional Embeddings

jerryxio.ng · 4,001 words · saved by 1 readers

One of the simplest ways of encoding relative positional information in attention is to add a scalar to each of the attention logits, with a value somehow depending on the distance between the corresponding query and key (e.g. learned values in T5, fixed values decreasing with distance in ALiBi). However, this makes it difficult for a query to attend to any specific (key, relative position) pair. In particular, the query must have a component pointing in the direction of the desired key, but this increases the attention scores with all tokens with that key, regardless of their position. Rotary positional embeddings (RoPE) are an elegant solution to this problem. Essentially, the query and key vectors for every token are rotated by an angle proportional to the token's 1-d coordinate position. To be specific, each attention head has its 𝐷 channel dimensions divided into 𝐷 / 2 dimension pairs. For a given query or key input vector 𝑥 ∈ 𝑅 𝐷 located at position 𝑡 , the 𝑖 th di

On N-dimensional Rotary Positional Embeddings [back to home] On N-dimensional Rotary Positional Embeddings July 26th, 2025 · Jerry Xiong resolution min_freq max_freq n_freqs direction_spacing \(\pi / 2\) \(\pi / \varphi\) \(2\pi / \varphi\) axial Typical axial RoPE rotates half of each head's components based on distance along the x-axis, and the other half based on distance along the y-axis, which results in striped artifacts and poorly concentrated attention maps. Queries are unable to attend to tokens at specific positions without also attending to tokens with similar keys in the same row o

Explore this link on the map →

saved by

related reading