短训练,长测试:线性偏置注意力实现输入长度外推

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

奥菲尔·普雷斯 Ofir Press · Allen Institute for AI · 2021-08-27 · arXiv:2108.12409 ↗ · 被引 1281

打开互动全文版(逐段中英对照 + 图/公式 + 论文问答)→

摘要 · Abstract

自 Vaswani 等人(2017)引入 Transformer 模型以来,一个基本问题尚未得到解答:模型如何在推理时对训练期间未见过的更长序列实现外推?我们首先表明,只需改变位置表示方法即可实现外推,但我们发现当前方法无法实现高效外推。因此,我们引入了一种更简单、更高效的位置方法——线性偏置注意力(ALiBi)。ALiBi 不向词嵌入添加位置嵌入;相反,它通过一个与距离成比例的惩罚来偏置查询-键注意力分数。我们表明,该方法在长度为 1024 的输入序列上训练了一个 13 亿参数的模型,该模型可外推到长度为 2048 的输入序列,实现了与在长度为 2048 的输入上训练的正弦位置嵌入模型相同的困惑度,但训练速度提高了 11%,内存使用减少了 11%。ALiBi 对近因的归纳偏置也使其在 WikiText-103 基准测试中优于多种强位置方法。

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.

核心贡献 · Key contributions

局限 · Limitations

论文章节 · Sections(共 11)

阅读逐段中英对照全文 →