Skip to content

RoPE

Attention & memory · 2021

Attention is order-blind on its own; position has to be injected. RoPE does it by rotation.

PaperRoFormer: Enhanced Transformer with Rotary Position EmbeddingSu, Lu, Pan, Murtadha, Wen, Liu · Zhuiyi Technology · 2021arXiv:2104.09864 →

RoPE replaced the original Transformer’s fixed sinusoidal position encoding - added once, to the embedding, before any attention happened. RoPE instead rotates the query and key vectors inside attention, every layer, which is what lets the dot product see relative offset instead of absolute position.

Same bag of words, two readings. Rotate the query and the key by their seat — the dot product sees the offset, not the seat numbers.

RoPE — relative position by rotating Q and K · 22s, companion clip.
What it fixedRelative position falls out of the geometry - queries and keys are rotated by position, so the dot product sees the offset.
What it still costsStretch far past the trained context and the rotations land in territory the model never saw.

Worth having first: Queries, keys, values & heads