[论文解读] Explicit Sparse Transformer: Concentrated Attention Through Explicit Selection
本论文介绍 Explicit Sparse Transformer,通过选择前-k个贡献最大的位点来集中注意力,在NLP和计算机视觉任务中提升性能与效率。
Self-attention based Transformer has demonstrated the state-of-the-art performances in a number of natural language processing tasks. Self-attention is able to model long-term dependencies, but it may suffer from the extraction of irrelevant information in the context. To tackle the problem, we propose a novel model called extbf{Explicit Sparse Transformer}. Explicit Sparse Transformer is able to improve the concentration of attention on the global context through an explicit selection of the most relevant segments. Extensive experimental results on a series of natural language processing and computer vision tasks, including neural machine translation, image captioning, and language modeling, all demonstrate the advantages of Explicit Sparse Transformer in model performance. We also show that our proposed sparse attention method achieves comparable or better results than the previous sparse attention method, but significantly reduces training and testing time. For example, the inference speed is twice that of sparsemax in Transformer model. Code will be available at \url{https://github.com/lancopku/Explicit-Sparse-Transformer}
研究动机与目标
- 促进 Transformer 模型中对注意力的更集中需求,以减少对不相关上下文的干扰。
- 提出具有前-k 选择性注意力的 Explicit Sparse Transformer,以锐化全局上下文建模。
- 展示相对原生 Transformer 在神经机器翻译、图像描述和语言建模上的改进。
- 证明稀疏注意力相较于以往的稀疏注意力方法在保持或提高准确率的同时可以更快。
提出的方法
- 计算标准 QK^T 注意力分数,并对每个查询行应用前-k 掩码,仅保留最大的 k 个分数。
- 在 softmax 之前用 -infinity 掩蔽非前-k 分数,以获得集中的注意力分布。
- 对掩蔽分数进行 softmax 归一化,得到注意力权重。
- 使用稀疏注意力权重 A 和值 V 计算上下文 C = A V。
- 将稀疏机制扩展到上下文注意力,其中 Q 来自解码状态。
- 提供一种简单、易于实现的方法,兼容自注意力和上下文注意力。
实验结果
研究问题
- RQ1直接前-k 选择性注意力是否相较于原生 Transformer 提升了模型的聚焦与性能?
- RQ2如何在不同任务和数据集上选择超参数 k?
- RQ3相对于其他稀疏注意力方法,前-k 稀疏注意力在训练与推理效率上有哪些好处?
- RQ4稀疏注意力是否有助于模型对齐并减少对不相关上下文的干扰?
- RQ5使用显式稀疏注意力时,注意力分布中出现了哪些定性差异?
主要发现
- Explicit Sparse Transformer 在 En-De 的 BLEU 为 29.4 而 Transformer 为 28.4。
- 在 En-Vi 上,其 BLEU 为 31.1,Transformer 为 30.2。
- 在 De-En 上,达到 35.6 BLEU(顶行报道)。
- 在图像描述(COCO)中,相比 Transformer 基线,在 CIDEr 和 BLEU-4 有小幅提升。
- 在语言建模(enwiki8)中,优于 Transformer-XL,参数量相当。
- 与以往的稀疏注意力方法相比,前-k 稀疏注意力在某些设置下使训练/推理时间约快2倍。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。