Skip to main content
Interactive 3D/Context Extension - YaRN, ALiBi, LongRoPE Comparison
YaRN
NTK-aware interpolation with adaptive scaling
Context
33k
tokens
Extension ratio
8×
vs trained
Perplexity
5.12
lower=better
Perplexity vs Context Length (scaleFactor=4×)
trained limit1.024k4.096k16.384k65.536k262.144kPPL
YaRN
ALiBi
LongRoPE
RoPE-base
RoPE Base Frequency Extension
d1
d2
d3
d4
d5
d6
d7
d8
d9
d10
d11
d12
d13
d14
d15
d16
Indigo = original RoPE frequencies · Green = scaled frequencies. YaRN applies non-uniform scaling: high-freq dims get interpolated, low-freq dims get extrapolated.
Controls
Extension Method
YaRN
ALiBi
LongRoPE
RoPE-base
Scale Factor
Factor4×
Context Length
Tokens33k
4k1M
Perplexity cliff: Models see catastrophic perplexity degradation past their trained context window. Extension methods like YaRN rescale positional frequencies to push that cliff out further.

Context Extension - YaRN, ALiBi, LongRoPE Comparison - Interactive Visualization

Language models trained with RoPE (Rotary Position Embeddings) see catastrophic perplexity degradation when deployed beyond their trained context length - the perplexity cliff. Extension methods like YaRN (NTK-aware interpolation), ALiBi (linear attention biases), and LongRoPE (non-uniform scaling) push this cliff further out. YaRN applies different scaling factors to different frequency bands: high-frequency dimensions are interpolated, low-frequency dimensions are extrapolated.

  • RoPE encodes position via rotation in frequency space - frequencies from θ_i = base^(-2i/d)
  • At context > trained limit: rotation angles unseen during training → perplexity spikes
  • YaRN: NTK-aware - scales base frequency by factor s, enabling 4-32x context extension
  • ALiBi: no positional embeddings at all - adds linear bias to attention scores by distance
  • LongRoPE: non-uniform scaling - different scale factors per frequency dimension

Part of the EngineersOfAI Interactive 3D - free interactive visualizations covering every major concept in machine learning and AI engineering. Hover any element for a plain-English explanation. No code required.