Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Round and Round We Go! What makes Rotary Positional Encodings useful?

About

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\v{c}kovi\'c• 2024

Related benchmarks

TaskDatasetResultRank
Commonsense ReasoningHellaSwag
Accuracy53.87
1891
Language UnderstandingMMLU
Accuracy62.35
825
ReasoningBBH
Accuracy64.48
672
Question AnsweringGPQA
Accuracy29.67
258
Commonsense ReasoningARC-C
Accuracy32.17
172
Language UnderstandingMMLU-Pro
Accuracy33.95
87
Common Sense ReasoningPIQA
Accuracy72.03
71
Long-context retrieval and synthetic reasoningRULER
Accuracy51.28
47
Long-context UnderstandingLongBench English
Accuracy19.42
30
Long-context language modelingHELMET
Summarization Score25.7
27
Showing 10 of 14 rows

Other info

Follow for update