Long-context extension scales the effective context from 4K/8K to 128K/1M, via two main routes. Route one: positional-encoding surgery on RoPE — PI (Positional Interpolation) scales position m by 1/s for linear interpolation; NTK-aware scaling down-weights only low frequencies while preserving high ones; YaRN (Yet another RoPE extensioN) adds a temperature t on top of NTK, scaling attention logits by 1/t — the most widely used today. Route two: continued pretraining on long documents (books, code repos) packed in sequence at a small learning rate.
💡Use Cases
long-document QA, codebase understanding, long-horizon agent tasks; inference relies on KV-cache management (see the AI_Infra module).
⚡Key Problems Solved
naive extrapolation pushes RoPE positions beyond the training range, destabilizing attention scores and exploding perplexity. PI/NTK/YaRN extend 4K to 128K with no or minimal training (e.g., YaRN-LLaMA-2-128K) while perplexity stays on par with short contexts; the cost is KV-cache memory growing linearly with length: a 128K-context 70B model needs hundreds of GB of KV cache (about 2×2×L×H×d×s×b), requiring PagedAttention-style management.
🎯5 High-Frequency Exam Points
1
Why does naive RoPE extrapolation fail?
2
PI vs NTK-aware scaling: what differs fundamentally?
3
YaRN's mechanism and the role of the temperature t?
4
The two routes of context extension and their trade-offs?
5
Compute/memory cost of long context and KV-management techniques?