All problems
RoPE Frequency Wavelength
Problem
Compute the wavelength of a RoPE frequency band: 2 * pi * theta_base^(2 * pair_index / dim). Long wavelengths rotate slowly and carry long-range position information.
The signature is rope_wavelength(dim, pair_index, theta_base=10000.0). Return a float.
Hint
Pair index 0 has wavelength 2 * pi regardless of the base or dimension.
Test cases
case 1
in: [4,0]
expected: 6.2831853072
case 2
in: [4,1]
expected: 628.318530718
case 3
in: [8,2,100]
expected: 62.8318530718
case 4
in: [64,31]
expected: 47117.2427801674
Starter codePython
import math
def rope_wavelength(dim, pair_index, theta_base=10000.0):
# Your code here
pass4 test cases · run your code against them in the editor