Why does ALiBi extrapolate to longer sequences better than absolute positional embeddings?

Last updated 22 November 2026

  • ALiBi adds no position vectors. It subtracts a fixed, head-specific linear distance penalty from each logit: q·k - m_h·(i - j).

  • Absolute embeddings fail because unseen positions are out of distribution. ALiBi's penalty depends only on distance, is defined for any length, and makes each head a soft local window.

  • Caveat: much of the stability comes from ignoring distant tokens, so true long-range retrieval is limited.

  • https://inamdaraditya.medium.com/alibi-the-positional-encoding-that-lets-transformers-extrapolate-to-sequences-they-were-never-6d9abfd5479b?source=rss-------1
  • https://mbrenndoerfer.com/writing/alibi-attention-linear-biases-position-encoding
  • https://huggingface.co/papers/2108.12409
All Transformers interview questions