ALiBi (Attention with Linear Biases) injects position information by adding a negative value (a penalty) proportional to the queryβkey distance to the attention scores. It was proposed by Press, Smith, and Lewis in 2021 (ICLR 2022). No position embedding is added anywhere in the network, and there are no learned parameters.
The goal of ALiBi is that accuracy does not collapse when inference runs on sequences longer than those seen in training. Language models predict better the longer the context they see, but training on long sequences costs time and memory. The paper shows that models with sinusoidal positional encoding start to degrade once the input is only a few dozen tokens longer than in training, and that RoPE and the T5 relative position bias are not sufficient either (the T5 scheme extrapolates but trains slowly), before proposing ALiBi.
The penalty grows with the distance of the key. The mechanism gives the model a built-in tendency to "weight nearby words more," and because the same rule computes the penalty however far the distance extends, it applies directly to lengths never seen in training.
The left side of the figure at the top of the article shows where position information is injected. It uses the same layout as the figures in the learned positional embedding, relative position representations, and RoPE articles, so the injection points can be compared side by side. The right side shows the matrix of penalty values (the bias) and the per-head slopes.

