Skip to content
nonconvexcard

Rotary embeddings encode relative position exactly

ProofAdvanced⏱ 30 minDeep Learningroperelative positionrotationextrapolation

Problem

Prove that ⟨Rpq,Rp′k⟩=⟨q,Rp′−pk⟩\langle R_pq, R_{p'}k\rangle = \langle q, R_{p'-p}k\rangle for the block-diagonal rotation RpR_p of RoPE, and contrast with additive sinusoidal encodings, where relative position is only linearly recoverable.

Write a complete argument. Every inequality you use should be one you could state precisely.

Solution

Opening this before you have a real attempt on paper is the fastest way to feel like you understand something you cannot reproduce.

Related problems

All problems
SolvedProblemFieldTypeDifficultyTime
When does attention dominate the MLP?Deep LearningNumericalBeginner30 min
Attention is permutation equivariantDeep LearningProofIntermediate30 min
Implement multi-head attention from scratch runDeep LearningCodingIntermediate3 hours
The softmax Jacobian as a variance, and saturationDeep LearningProofIntermediate30 min
Why attention divides by the square root of d_kDeep LearningProofIntermediate30 min