arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2104.07012cs.CLcs.LG
收藏

线性单元的稀疏注意

Sparse Attention with Linear Units

School of Informatics, University of Edinburgh(爱丁堡大学信息学院);ILLC, University of Amsterdam(阿姆斯特丹大学语言、逻辑与计算研究所);Department of Computational Linguistics, University of Zurich(苏黎世大学计算语言学系)

Biao Zhang, Ivan Titov, Rico Sennrich

摘要:

最近,有人认为,编码器-解码器模型可以通过将注意力中的softmax函数替换为其稀疏变量来变得更可解释。在这项工作中,我们介绍了一种新的,简单的方法来实现注意力的稀疏性:我们用ReLU代替softmax激活,并表明稀疏性自然地从这样的公式中出现。训练稳定性是通过层归一化来实现的,该层归一化具有专门的初始化或附加的门控功能。我们的模型,我们称之为矫正线性注意力(ReLA),是很容易实现的,比以前提出的稀疏注意力机制更有效。我们将ReLA应用于Transformer,并在五个机器翻译任务上进行实验。ReLA实现了与几个强基线相当的翻译性能,其训练和解码速度与vanilla attention相似。我们的分析表明,ReLA提供了高稀疏率和头部多样性,诱导的交叉注意实现了更好的准确性,相对于源-目标词对齐比最近的稀疏softmax为基础的模型。有趣的是,ReLA头也学会了对某些查询不做任何事情(即“关闭”),这是稀疏化的softmax替代方案所不可能的。

英文摘要:

Recently, it has been argued that encoder-decoder models can be made more interpretable by replacing the softmax function in the attention with its sparse variants. In this work, we introduce a novel, simple method for achieving sparsity in attention: we replace the softmax activation with a ReLU, and show that sparsity naturally emerges from such a formulation. Training stability is achieved with layer normalization with either a specialized initialization or an additional gating function. Our model, which we call Rectified Linear Attention (ReLA), is easy to implement and more efficient than previously proposed sparse attention mechanisms. We apply ReLA to the Transformer and conduct experiments on five machine translation tasks. ReLA achieves translation performance comparable to several strong baselines, with training and decoding speed similar to that of the vanilla attention. Our analysis shows that ReLA delivers high sparsity rate and head diversity, and the induced cross attention achieves better accuracy with respect to source-target word alignment than recent sparsified softmax-based models. Intriguingly, ReLA heads also learn to attend to nothing (i.e. 'switch off') for some queries, which is not possible with sparsified softmax alternatives.

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

↑