arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.04347cs.LGcs.CL
收藏

刺猬与豪猪:具有Softmax模仿能力的表达性线性注意力

The Hedgehog & the Porcupine: Expressive Linear Attentions with Softmax Mimicry

Stanford University(斯坦福大学)

Michael Zhang, Kush Bhatia, Hermann Kumbong, Christopher Ré

AI总结:

针对线性注意力质量不足问题,提出Hedgehog可学习线性注意力,保留Softmax尖峰与单调特性,实现线性复杂度,恢复99%以上Transformer质量,并支持预训练模型转换。

摘要:

线性注意力已展现出提升Transformer效率的潜力,将注意力机制对序列长度的二次方复杂度降至线性复杂度。这为以下方面带来了令人兴奋的前景:(1)从头训练线性Transformer;(2)将特定任务的Transformer“微调转换”为线性版本,以恢复任务性能;(3)将诸如大语言模型之类的Transformer“预训练转换”为可在下游任务上微调的线性版本。然而,线性注意力在质量上往往逊于标准Softmax注意力。为弥合这一性能差距,我们发现先前的线性注意力缺乏与良好性能相关的Softmax注意力的关键特性:低熵(或“尖峰”)权重和点积单调性。我们进一步观察到,一些令人惊讶的简单特征映射保留了这些特性并匹配Softmax性能,但在线性注意力中计算效率低下。因此,我们提出了Hedgehog,一种可学习的线性注意力,它在保持线性复杂度的同时,保留了Softmax注意力的尖峰和单调特性。Hedgehog使用简单的可训练MLP来生成模仿Softmax注意力的注意力权重。实验表明,在从头训练和微调转换设置中,Hedgehog恢复了标准Transformer质量的99%以上,在带有因果GPT的WikiText-103上,性能优于先前的线性注意力高达6个困惑度点,在微调的双向BERT上,GLUE分数高出高达8.7分。Hedgehog还实现了预训练转换。将预训练的GPT-2转换为线性注意力变体,在WikiText-103上达到了125M次二次方解码器模型的最先进16.7困惑度。最后,我们将预训练的Llama-2 7B转变为可行的线性注意力Llama。通过低秩适应,Hedgehog-Llama2 7B在基础标准注意力模型上ROUGE-1分数高出28.1分,而先前的线性注意力则导致16.5分的下降。

英文摘要:

Linear attentions have shown potential for improving Transformer efficiency, reducing attention's quadratic complexity to linear in sequence length. This holds exciting promise for (1) training linear Transformers from scratch, (2) "finetuned-conversion" of task-specific Transformers into linear versions that recover task performance, and (3) "pretrained-conversion" of Transformers such as large language models into linear versions finetunable on downstream tasks. However, linear attentions often underperform standard softmax attention in quality. To close this performance gap, we find prior linear attentions lack key properties of softmax attention tied to good performance: low-entropy (or "spiky") weights and dot-product monotonicity. We further observe surprisingly simple feature maps that retain these properties and match softmax performance, but are inefficient to compute in linear attention. We thus propose Hedgehog, a learnable linear attention that retains the spiky and monotonic properties of softmax attention while maintaining linear complexity. Hedgehog uses simple trainable MLPs to produce attention weights mimicking softmax attention. Experiments show Hedgehog recovers over 99% of standard Transformer quality in train-from-scratch and finetuned-conversion settings, outperforming prior linear attentions up to 6 perplexity points on WikiText-103 with causal GPTs, and up to 8.7 GLUE score points on finetuned bidirectional BERTs. Hedgehog also enables pretrained-conversion. Converting a pretrained GPT-2 into a linear attention variant achieves state-of-the-art 16.7 perplexity on WikiText-103 for 125M subquadratic decoder models. We finally turn a pretrained Llama-2 7B into a viable linear attention Llama. With low-rank adaptation, Hedgehog-Llama2 7B achieves 28.1 higher ROUGE-1 points over the base standard attention model, where prior linear attentions lead to 16.5 point drops.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑