Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation

About

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.

Ofir Press, Noah A. Smith, Mike Lewis• 2021

Related benchmarks

TaskDatasetResultRank
Language ModelingFineWeb (val)--
156
Language ModelingWikiText-103
PPL17.64
146
Language ModelingarXiv (test)
PPL4.87
137
Language ModelingGitHub (test)
Perplexity2.57
113
Language ModelingOpenWebText2 (test)
Perplexity16.4
104
Language ModelingWikiText (held-out)
Perplexity (PPL)18.5452
25
Language Modeling and Question AnsweringShort-context task suite (WikiText, LAMBADA, TriviaQA, PIQA, HellaSwag, WinoGrande, ARC-Easy, GPQA, Social IQA, OpenBookQA, SciQ) (test)
WikiText PPL15.2
18
Text ClassificationAG-News
Accuracy93.1
13
Algorithmic ReasoningAlgorithmic Reasoning Suite Unseen Length (test)
Even Pairs67.3
11
Text ClassificationEmotion
Accuracy89
8
Showing 10 of 14 rows

Other info

Follow for update