Transformer-XL:超越固定长度上下文的注意力语言模型

Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context

戴子航 Zihang Dai · Carnegie Mellon University / Google · 2019-01-09 · arXiv:1901.02860 ↗ · 被引 4393

打开互动全文版(逐段中英对照 + 图/公式 + 论文问答)→

摘要 · Abstract

Transformer 有学习长期依赖的潜力,但在语言建模中受限于固定长度的上下文。我们提出了一种新颖的神经网络架构 Transformer-XL,它能够在不破坏时间连贯性的情况下学习超越固定长度的依赖关系。该架构包含一个片段级循环机制和一种新颖的位置编码方案。我们的方法不仅能够捕捉更长期的依赖关系,还能解决上下文碎片化问题。因此,Transformer-XL 学习的依赖关系比 RNN 长 80%,比原始 Transformer 长 450%,在短序列和长序列上均取得了更好的性能,并且在评估时比原始 Transformer 快 1800 倍以上。值得注意的是,我们在 enwiki8 上实现了 0.99 bpc/困惑度,在 text8 上为 1.08,在 WikiText-103 上为 18.3,在 One Billion Word 上为 21.8,在 Penn Treebank 上为 54.5(无需微调),均改进了当前最优结果。当仅在 WikiText-103 上训练时,Transformer-XL 能够生成包含数千个标记的合理连贯、新颖的文本文章。我们的代码、预训练模型和超参数可在 TensorFlow 和 PyTorch 中获取。

Transformers have a potential of learning longer-term dependency, but are limited by a fixed-length context in the setting of language modeling. We propose a novel neural architecture Transformer-XL that enables learning dependency beyond a fixed length without disrupting temporal coherence. It consists of a segment-level recurrence mechanism and a novel positional encoding scheme. Our method not only enables capturing longer-term dependency, but also resolves the context fragmentation problem. As a result, Transformer-XL learns dependency that is 80% longer than RNNs and 450% longer than vanilla Transformers, achieves better performance on both short and long sequences, and is up to 1,800+ times faster than vanilla Transformers during evaluation. Notably, we improve the state-of-the-art results of bpc/perplexity to 0.99 on enwiki8, 1.08 on text8, 18.3 on WikiText-103, 21.8 on One Billion Word, and 54.5 on Penn Treebank (without finetuning). When trained only on WikiText-103, Transformer-XL manages to generate reasonably coherent, novel text articles with thousands of tokens. Our code, pretrained models, and hyperparameters are available in both Tensorflow and PyTorch.

核心贡献 · Key contributions

局限 · Limitations

论文章节 · Sections(共 13)

阅读逐段中英对照全文 →