When encoding the position information with RoPE, the dimension of our vector is split into pairs, and each pair is going to rotate with a different frequency. For the pair index , the associated frequency is
We usually take a base of 10,000.
If we note the sequence length , this gives a total angle of . This is the total angle by which this pair is going to rotate over the sequence length.
Now say that you want to find the specific pair whose RoPE frequency rotates by N rotations over the sequence length. How do you compute that?
Since one rotation is then the number of rotations N for the pair index over the sequence length is
Thus, we get the following
This is the pair whose RoPE frequency makes rotations over the sequence length. But why would we compute this at all?
This can be useful to identify the dimension pairs performing many or few rotations and thus use methods like YaRN accordingly. But that’s another blog post :)