Up nextNext guide
Position Interpolation for Context Extension
Language AI
Language AI GUIDE
ALiBi (Attention with Linear Biases) is a clever way to give transformers a sense of word order without traditional position embeddings.
Listen to this guideAI-narrated · ~2 min
It lets a model trained on short text handle much longer inputs at inference time.
Transformers have no built-in notion of word order, so they need a way to encode position. The classic approach adds positional embeddings to token vectors. ALiBi, introduced by Press, Smith, and Lewis in 2021, throws those out entirely. Instead, it nudges the attention scores directly: when a query token looks at a key token, ALiBi subtracts a penalty proportional to the distance between them. Tokens that are far apart get a bigger penalty, so the model naturally prefers nearby context. Each attention head gets its own fixed penalty slope, so some heads look locally while others see farther. Because the bias is just a function of distance, ALiBi extrapolates gracefully to sequences far longer than those seen in training.
Training a chatbot on 1,024-token examples but deploying it on 4,096-token documents without retraining, relying on ALiBi's extrapolation.
The BLOOM 176B multilingual model, which adopted ALiBi for its position handling.
MosaicML's MPT models, which used ALiBi to advertise effectively unlimited context length at inference.
Summarizing long legal contracts that exceed the model's original training length, where nearby-context bias keeps attention coherent.
ALiBi proved that relative, distance-based biases beat absolute position embeddings for length generalization, and that idea now permeates modern long-context design. Some recent models favor rotary embeddings (RoPE) instead, but ALiBi remains popular where extreme extrapolation matters and was used in models like BLOOM and MPT. Expect continued hybrid experimentation, combining distance biases with RoPE scaling, as labs push context windows toward millions of tokens without retraining from scratch.
Free newsletter
Three verified AI stories every weekday morning, written in plain English. Free forever, no ads.
One email each weekday. Unsubscribe in one click. We never sell or share your address.
Test yourself
Instant feedback on every answer, and a shareable certificate with a verifiable ID once you pass a course.
Support free AI education. AI Understanding is a 501(c)(3) nonprofit — no ads, no paywall, ever. Make a donation
ALiBi (Attention with Linear Biases) is a clever way to give transformers a sense of word order without traditional position embeddings. It lets a model trained on short text handle much longer inputs at inference time.
ALiBi is short for Attention with Linear Biases, named for the linear penalty it adds to attention scores.
ALiBi subtracts a value proportional to the query-key distance from the attention score, so farther tokens get less weight.
Because the bias depends only on distance, models trained on short sequences can handle much longer ones at inference time.
ALiBi assigns each head a distinct, fixed slope (e.g., 1/2, 1/4, 1/8), so different heads attend at different ranges.
ALiBi introduces no new learned parameters; the per-head slopes are predetermined constants.
Keep learning
More guides picked for this topic
Up nextNext guide
Position Interpolation for Context Extension
Language AI