[论文解读] R-Transformer: Recurrent Neural Network Enhanced Transformer
R-Transformer 将本地RNN用于局部结构与多头注意力用于全局依赖相结合,在不使用位置嵌入的情况下实现强性能,并在若干序列建模任务上超越 Transformer 和 TCN。
Recurrent Neural Networks have long been the dominating choice for sequence modeling. However, it severely suffers from two issues: impotent in capturing very long-term dependencies and unable to parallelize the sequential computation procedure. Therefore, many non-recurrent sequence models that are built on convolution and attention operations have been proposed recently. Notably, models with multi-head attention such as Transformer have demonstrated extreme effectiveness in capturing long-term dependencies in a variety of sequence modeling tasks. Despite their success, however, these models lack necessary components to model local structures in sequences and heavily rely on position embeddings that have limited effects and require a considerable amount of design efforts. In this paper, we propose the R-Transformer which enjoys the advantages of both RNNs and the multi-head attention mechanism while avoids their respective drawbacks. The proposed model can effectively capture both local structures and global long-term dependencies in sequences without any use of position embeddings. We evaluate R-Transformer through extensive experiments with data from a wide range of domains and the empirical results show that R-Transformer outperforms the state-of-the-art methods by a large margin in most of the tasks. We have made the code publicly available at \url{https://github.com/DSE-MSU/R-transformer}.
研究动机与目标
- 通过在捕捉局部结构的同时保留长程依赖来推动序列建模的改进。
- 提出结合 LocalRNN 与多头注意力的混合架构。
- 证明该模型在没有位置嵌入的情况下仍然能够在不同领域中超越基线。
提出的方法
- 引入 LocalRNN 来处理在每个位置结束的局部窗口,产生编码局部序列信息的位置信息表示。
- 应用一个使用多头注意力的池化子层,在各个位置之间捕获全局的长期依赖。
- 在 LocalRNN、注意力和前馈子层之间遵循残差和层归一化方案,构成 R-Transformer 的每一层。
- 采用三层结构:LocalRNN(局部)、Multi-Head Attention(全局)和逐位置前馈,具有共享参数和可并行计算。
- 在多个数据集上将 R-Transformer 与 RNNs、TCN 和 Transformer 进行比较,以评估性能提升。
实验结果
研究问题
- RQ1LocalRNN 是否能够有效编码局部序列结构以增强基于全局注意力的模型?
- RQ2移除位置嵌入是否会降低性能,或 LocalRNN 与注意力能否弥补?
- RQ3在需要不同程度局部性与长程依赖平衡的任务上,R-Transformer 相对于 RNNs、TCN 和 Transformer 的表现如何?
- RQ4模型训练和推理是否像非循环结构那样高效并行化?
主要发现
- R-Transformer 在逐像素的 MNIST 测试准确率上超过 Transformer 和 TCN(99.1% 对比 Transformer 的 98.2% 与 TCN 的 99.0%)。
- 在多声部诺丁汉音乐建模中,R-Transformer 达到 NLL 为 2.37,优于 LSTM(3.29)、GRU(3.46)、TCN(3.07)和 Transformer(3.34)。
- 在 Penn Treebank 字符级语言建模中,R-Transformer 的 NLL 为 1.24,优于 Transformer(1.45),且与基于 RNN 的基线相比性能相当或更好。
- 在 PTB 单词级语言建模中,R-Transformer 的困惑度为 84.38,优于 Transformer(122.37)及其他基线(RNN/GRU/LSTM/TCN)。
- 在各项任务中,R-Transformer 始终优于 TCN 和 Transformer,利用 LocalRNN 处理局部性,利用多头注意力处理长程依赖。
- 该模型实现为实现对序列位置的全并行化,并不依赖位置嵌入。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。