How does ALiBi encode position, and what's its claim to fame?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
ALiBi (Attention with Linear Biases) uses no positional embeddings at all. Instead, it adds a static penalty directly to attention scores proportional to the distance between query and key: score(i, j) += −slope · (i − j) for j ≤ i. Each head gets a different fixed (not learned) slope, drawn from a geometric sequence (e.g. 1/2, 1/4, ..., 1/2⁸ for 8 heads) - so some heads are strongly recency-biased, effectively local, while shallow-slope heads can still attend far back. Position is expressed purely as "farther = softly down-weighted," and the model learns everything else from content.
Full worked answer
ALiBi (Attention with Linear Biases) uses no positional embeddings at all. Instead, it adds a static penalty directly to attention scores proportional to the distance between query and key: score(i, j) += −slope · (i − j) for j ≤ i. Each head gets a different fixed (not learned) slope, drawn from a geometric sequence (e.g. 1/2, 1/4, ..., 1/2⁸ for 8 heads) - so some heads are strongly recency-biased, effectively local, while shallow-slope heads can still attend far back. Position is expressed purely as "farther = softly down-weighted," and the model learns everything else from content.
Its claim to fame is length extrapolation: train at 1k - 2k context and run inference at much longer lengths with far less degradation than sinusoidal, learned, or vanilla-RoPE models, whose behaviour collapses on out-of-distribution position values. ALiBi has no out-of-distribution positions - the bias formula is the same linear function at any distance - so nothing structurally breaks at unseen lengths. It's also simple (a few lines in the attention kernel), parameter-free, and adds negligible compute. MPT and BLOOM shipped with it.
Honest limitations, which explain why RoPE still dominates: the built-in recency bias is a strong inductive prior - helpful for perplexity, but it means genuinely long-range retrieval must fight the penalty, and empirically ALiBi models are weaker at long-range recall tasks than extended-RoPE models; "doesn't blow up at length" is not the same as "uses length well." It's also awkward to combine with some attention optimisations, and the ecosystem's tooling consolidated around RoPE - once position interpolation and YaRN made RoPE extensible cheaply, ALiBi's headline advantage mattered less.
Conceptually it remains an important data point: relative position can be expressed as a score-space bias rather than embedding-space content, and the sliding-window-like behaviour of steep-slope heads prefigured explicit local-attention designs.
What a good answer covers
- ALiBi (Attention with Linear Biases) uses no positional embeddings at all
- Instead, it adds a static penalty directly to attention scores proportional to the distance between…
- Each head gets a different fixed (not learned) slope, drawn from a geometric sequence (e.g
- Position is expressed purely as "farther = softly down-weighted," and the model learns everything else…
- Its claim to fame is length extrapolation
Key terms: no positional embeddings at all · length extrapolation
In the glossary: ALiBi · Attention · RoPE · Position interpolation · YaRN
Interviewer follow-ups to expect
Why does ALiBi extrapolate where RoPE doesn't?
What's the cost of a recency prior for retrieval-heavy tasks?
Compare ALiBi's bias to T5's learned relative-position buckets.
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep