EasyDeepLearn

How does ALiBi encode position?

hard

Answer

  • Attention with Linear Biases (Press et al., 2021): add a linear penalty proportional to distance to the attention logits: ai,ja_{i, j} -= mh    (i    j)m_{h}\; \cdot \;(i\; - \;j), where mhm_{h} is a fixed per-head slope.
  • No learned embeddings — just a static penalty.
  • Extrapolates naturally to longer sequences at inference than at training.
  • Simple, effective, used in BLOOM and some other LLMs; RoPE dominates elsewhere.
Check yourself — multiple choice
  • Learned embeddings
  • Static linear bias on attention scores by distance — no params, extrapolates naturally
  • Random
  • Same as sinusoidal

ALiBi: linear distance penalty in attention → no params + extrapolation.

#positional-encoding#transformers

Practise Deep Learning

214 interview questions in this topic.

Related questions