passdrill
AI & LLM Engineering · How LLMs Work: Transformers & Training · Card 016/024 medium

Press, Smith and Lewis (2021), "Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation," introduce ALiBi as a way to let a model trained on short sequences generalize to much longer ones at inference. How does ALiBi represent position, and how does this differ from adding sinusoidal or learned positional embeddings to the input?

  1. It adds a learned positional embedding to each token exactly as the original Transformer does, but recomputes those embeddings after every training step so they extrapolate to unseen lengths
  2. It removes positional information entirely, relying only on the order in which tokens are fed into the model during training to implicitly teach it sequence order
  3. It replaces the query and key projections with position-specific weight matrices, so each position in the sequence uses a completely separate set of learned parameters
  4. It adds no positional embeddings to the word embeddings at all; instead, it subtracts a static, non-learned penalty from each attention score that grows in proportion to the distance between the query and key positions, with the penalty's steepness set differently per attention head
Next card → Shuffle