Language AI GUIDE

ALiBi Position Bias

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

On this page2 min read
  1. Overview
  2. Deep Dive
  3. Real-World Implementation
  4. The Future of ALiBi Position Bias
  5. Putting it into practice
  6. Keep Exploring
  7. Frequently asked questions

Overview

It lets a model trained on short text handle much longer inputs at inference time.

Deep Dive

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.

Real-World Implementation

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.

The Future of ALiBi Position Bias

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.

Putting it into practice

Why it matters

  • Speed and scale. Language workflows can move faster without sacrificing consistency.
  • Access and reach. It expands access across languages and communication styles.
  • Clearer decisions. Teams can spend more time on judgment while automation handles repetition.

Watch out for

  • Hallucinated facts can quietly enter reports, support flows, or research outputs.
  • Prompt sensitivity can create inconsistent results across similar requests.
  • Sensitive text data may be exposed if access controls are weak.

Next steps

  1. Define output format, tone, and quality standards before rollout.
  2. Ground responses with trusted sources whenever accuracy matters.
  3. Keep a human review checkpoint for high-stakes outputs.
  4. Track failure patterns and retrain prompts or workflows regularly.

Keep Exploring

Free newsletter

Get the daily AI briefing

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

Take the ALiBi Position Bias quiz

Instant feedback on every answer, and a shareable certificate with a verifiable ID once you pass a course.

Start quiz

Support free AI education. AI Understanding is a 501(c)(3) nonprofit — no ads, no paywall, ever. Make a donation

Frequently asked questions

What is ALiBi Position Bias?

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.

What does ALiBi stand for?

ALiBi is short for Attention with Linear Biases, named for the linear penalty it adds to attention scores.

How does ALiBi penalize distant tokens?

ALiBi subtracts a value proportional to the query-key distance from the attention score, so farther tokens get less weight.

What is ALiBi's most celebrated practical advantage?

Because the bias depends only on distance, models trained on short sequences can handle much longer ones at inference time.

What is different about the linear bias across attention heads?

ALiBi assigns each head a distinct, fixed slope (e.g., 1/2, 1/4, 1/8), so different heads attend at different ranges.

Compared to traditional positional embeddings, ALiBi adds how many learned parameters?

ALiBi introduces no new learned parameters; the per-head slopes are predetermined constants.

ALiBi Position Bias: Plain-English Guide | AI Understanding