Extend Context with RoPE Scaling

hard
Unit 29 · Safety0/0 to milestone

A model trained with RoPE on 4K tokens breaks at 16K, because it has never seen such large rotation angles. Two popular fixes:

  • Position interpolation (linear): divide positions by a scale factor s, so 16K positions map into the trained 0–4K range.
  • NTK-aware scaling: leave positions alone and raise the RoPE base to b′=b⋅sd/(d−2)b' = b \cdot s^{d/(d-2)}. The highest frequency stays the same (local detail is kept) while the lowest frequency slows down by exactly s.
Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Extend Context with RoPE Scaling · TechGradify