Attention with Linear Biases (ALiBi) removes positional embeddings from transformers entirely and adds a fixed distance penalty directly to query-key attention scores, letting a 1.3B-parameter language model trained on 1,024 tokens match a 2,048-token sinusoidal baseline at 2,048 tokens while training 11% faster with 11% less memory.

  • Drop-in extrapolation at 1.3B scale: Trained for 50k updates on 461 GB (CC100 + RoBERTa), an ALiBi model with L = 1,024 hits 8.92 validation perplexity at L_valid = 2,048 using 26.2 GB per GPU, beating a time-matched L = 2,048 sinusoidal model (9.01 perplexity, 29.3 GB) while saving 3.1 GB of memory.
  • No sinusoidal explosion: On WikiText-103 (L_train = 1,024), sinusoidal perplexity jumps from 19.34 at 1,024 tokens to 51.09 at 2,024 and 453.32 at 16,024; Rotary (RoPE) reaches 31.17 and 106.99; ALiBi drops to 18.05 and holds at 17.98.
  • Zero runtime tax vs. T5 bias: T5 relative position bias extrapolates up to ~2L (18.34 at 2,024 tokens) but slows GPU training by more than 2x (13.0k vs. 26.0k words/sec at L = 1,024) and runs out of 32 GB memory at 13,024 tokens; ALiBi stays within 1% of sinusoidal training speed and adds 0% to 0.7% memory.
  • Train short, beat long: On WikiText-103, ALiBi trained on L = 512 (1.84x faster than L = 3,072 sinusoidal) extrapolates to 3,072 tokens at 18.40 validation perplexity, outperforming the L = 3,072 sinusoidal model (18.67).
Extrapolation from L = 1,024 training length on WikiText-103
Validation perplexity at L_valid = 2,024 and 10,024 (lower is better; baseline at 1,024 is 18.66 to 19.34)
ALiBi (no runtime penalty)2,024: 18.05 · 10,024: 17.97
T5 Bias (2.0x slower training)2,024: 18.34 · 10,024: 29.54
Rotary / RoPE2,024: 31.17 · 10,024: 77.70
Sinusoidal (Vaswani et al.)2,024: 51.09 · 10,024: 337.48

Source: Press, Smith & Lewis (2022), Appendix Table 3. Bars scaled proportionally to 10,024-token degradation (capped at 100% for Sinusoidal 337.48 PPL).

How ALiBi Scores Distance Without Embeddings

In the original Transformer, sinusoidal vectors are added to token embeddings at layer 1. Press, Smith, and Lewis found that sinusoidal models cannot extrapolate even a few dozen tokens past training length L (degrading past k = 50 extra tokens), while learned position tables cannot represent any position past L at all.

ALiBi drops position embeddings from the input and injects recency directly into every attention head’s pre-softmax logits: softmax(q_i K^T + m * [-(i - 1), ..., -2, -1, 0]). A query at position i penalizes key j proportionally to their distance i - j, multiplied by a fixed, non-learned head slope m.

For n heads, slopes follow a geometric progression starting at 2^(-8/n) with the same ratio. In an 8-head model, slopes span from 1/2 (0.5 per token, enforcing tight local focus) down to 1/256 (0.0039, allowing long-range context). For 16 heads, ALiBi interpolates geometric midpoints from 2^(-0.5) to 2^(-8). Making m trainable hurt extrapolation and slowed training by 3%. Because the bias tensor simply folds into the existing causal attention mask (n x L x L instead of L x L), it adds zero matrix-multiply operations and at most ~100 MB of mask overhead while saving gigabytes by enabling shorter L_train.

1.3B-parameter CC100+RoBERTa scaling: train short, test 2x longer
Sinusoidal baseline (L = 2,048)
Memory: 29.3 GB per V100
Time-matched PPL (44.2k steps): 9.01
Full 50k steps (6.7k hrs): 8.83
Extrapolation past L: Fails at +1 token
ALiBi extrapolated (L = 1,024 -> 2,048)
Memory: 26.2 GB (-11% / -3.1 GB)
Time-matched PPL (50k steps): 8.92
Speed to match PPL: 11% faster (5.9k hrs)
Peak window: ~2L (stable to 10,000)

Source: Press, Smith & Lewis (2022), Section 4.2 and Appendix Tables 11 and 12.

Key Findings and Why Perplexity Drops Past L

Without changing slopes across datasets (WikiText-103, Toronto BookCorpus, and CC100+RoBERTa), ALiBi matched sinusoidal perplexity at 1.3B scale when L_valid = L (8.84 vs. 8.83 at L = 2,048) and beat it on smaller corpora (17.60 vs. 18.67 on WikiText-103 L = 3,072).

Crucially, Appendix B.2 explains why perplexity keeps falling up to 2L during standard nonoverlapping evaluation: it is mostly the early token curse, not long-range synthesis. In nonoverlapping windows of length 1,000, 10% of predictions have 100 or fewer tokens of left context; doubling the window to 2,000 halves that starved fraction to 5%. When the authors re-ran WikiText-103 with stride S = 1 sliding-window evaluation (so every token already had L tokens of context), ALiBi stayed flat past L rather than improving further, whereas sinusoidal perplexity still exploded.

Caveats and Builder Takeaway

Flat perplexity under ALiBi proves the model does not collapse on long inputs, not that it reliably retrieves or reasons over facts 10,000 tokens back. Because linear penalties grow monotonically with distance, distant keys suffer steep logit suppression unless a head has a tiny slope. Modern long-context stacks typically pair RoPE position interpolation or YaRN context extension with brief long-context fine-tuning when exact needle-in-a-haystack retrieval matters. ALiBi remains an attractive, zero-parameter baseline whenever training sequence length is memory-bound and recent-context recency matches the workload.