
摘要
Transformer 是现代自然语言处理(NLP)模型的核心架构。本文提出 RealFormer,一种简单且通用的技术,用于构建残差注意力层(Residual Attention Layer)的 Transformer 网络。在包括掩码语言建模(Masked Language Modeling)、GLUE、SQuAD、神经机器翻译(Neural Machine Translation)、WikiHop、HotpotQA、Natural Questions 和 OpenKP 在内的广泛任务上,RealFormer 显著优于标准 Transformer 及其各类变体(如 BERT 等)。我们还通过实验观察到,RealFormer 能够稳定训练过程,并生成注意力分布更稀疏的模型。RealFormer 的源代码及预训练模型检查点可于以下地址获取:https://github.com/google-research/google-research/tree/master/realformer。
代码仓库
JunnYu/x-transformers-paddle
jax
GitHub 中提及
aivolcano/BERT_MRC_CLS
pytorch
GitHub 中提及
cloneofsimo/RealFormer-pytorch
pytorch
GitHub 中提及
jaketae/realformer
pytorch
GitHub 中提及
基准测试
| 基准 | 方法 | 指标 |
|---|---|---|
| linguistic-acceptability-on-cola | RealFormer | Accuracy: 59.83% |
| natural-language-inference-on-multinli | RealFormer | Matched: 86.28 Mismatched: 86.34 |
| natural-language-inference-on-qnli | RealFormer | Accuracy: 91.89% |
| natural-language-inference-on-rte | RealFormer | Accuracy: 73.7% |
| paraphrase-identification-on-quora-question | RealFormer | Accuracy: 91.34 F1: 88.28 |
| semantic-textual-similarity-on-mrpc | RealFormer | Accuracy: 87.01% F1: 90.91% |
| semantic-textual-similarity-on-sts-benchmark | RealFormer | Pearson Correlation: 0.9011 Spearman Correlation: 0.8988 |
| sentiment-analysis-on-sst-2-binary | RealFormer | Accuracy: 94.04 |