How can you extend a RoPE-based model's context window beyond the length it was trained on?
Last updated
RoPE (rotary position embedding) encodes positions as rotations, so long inputs produce unseen angles. Extension rescales positions or frequencies to map them back into the trained range.
Main methods: Position Interpolation (scale positions by L_train/L_target, blurs local detail), NTK-aware base increase (stretches low frequencies, keeps high ones), and YaRN (per-frequency interpolation plus an attention temperature fix).
Set the scaling in config (e.g.
rope_scaling), fine-tune briefly on long documents, then evaluate with long-context retrieval tests (needle-in-a-haystack, RULER) and check short-context quality.