def inv_freq.go
import bend-ml-llama@0.2.1.0/main.bend as BendMlLlamaimport Base
390# inv_freq[i] = 1 / (theta ^ (2i / head)), i = 0..half-1 (LlamaRotaryEmbedding, default rope)
391def inv_freq.go(n: Nat, +i: Nat, +theta: F32, +hd: F32) -> List<&2, F32>:
392 match n:
393 case 0n:
394 Nil{}
395 case 1n+p:
396 (1.0 / F32.pow(theta, (F32.from_nat(Nat.mul(2n, i)) / hd : F32)) : F32) <> inv_freq.go(p, 1n+i, theta, hd)