[2108.12409] Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
Abstract:Since the introduction of the transformer model by Vaswani et al. (2017), a fundamental question has yet to be answered: how does a model achieve extrapolation at inference time for sequences that are longer than it saw during training? We first show that extrapolation can be enabled by simply changing the position representation method, though we find that current methods do not allow for efficient extrapolation. We therefore introduce a simpler and more efficient position method, Attention with Linear Biases (ALiBi). ALiBi does not add positional embeddings to word embeddings; instead, it biases query-key attention scores with a penalty that is proportional to their distance. We show that this method trains a 1.3 billion parameter model on input sequences of length 1024 that extrapolates to input sequences of length 2048, achieving the same perplexity as a sinusoidal position embedding model trained on inputs of length 2048 but training 11% faster and using 11% less memory. ALiBi's inductive bias towards recency also leads it to outperform multiple strong position methods on the WikiText-103 benchmark.
Published as a conference paper at ICLR 2022 T RAIN S HORT, T EST L ONG : ATTENTION WITH L INEAR B IASES E NABLES I NPUT L ENGTH E XTRAPOLATION Ofir Press1,2 Noah A. Smith1,3 Mike Lewis2 1 Paul G. Allen School of Computer Science & Engineering, University of Washington 2 Facebook AI…
saved by
related reading
- Extending Context is Hard | kaiokendevkaiokendev.github.io
- Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationarxiv.org
- A short note on some aspects of long context attention | nor's blognor-blog.pages.dev
- Transformer Explainer: LLM Transformer Model Visually Explainedpoloclub.github.io
- [2512.23675] End-to-End Test-Time Training for Long Contextarxiv.org
- Getting Caught Up to Modern LLM Research | Samarth Goeldev.samarthgoel.com
- 1706.03762arxiv.org
- Unlimiformer: Long-Range Transformers with Unlimited Length Inputarxiv.org
- The Annotated Transformernlp.seas.harvard.edu
- [2011.04006] Long Range Arena: A Benchmark for Efficient Transformersarxiv.org
- Seq2seq and Attentionlena-voita.github.io
- Linear Transformers Are Faster After All – Manifest AImanifestai.com