トランスフォーマーは、長期的な依存関係を学習する可能性がありますが、言語モデリングの設定における固定長コンテキストによって制限されます。時間的コヒーレンスを乱すことなく、固定長を超える依存関係を学習できる新しいニューラルアーキテクチャTransformer-XLを提案します。これは、セグメントレベルの繰り返しメカニズムと新しい位置エンコードスキームで構成されています。この方法は、長期的な依存関係のキャプチャを可能にするだけでなく、コンテキストの断片化の問題も解決します。その結果、Transformer-XLは、RNNより80%長く、バニラトランスフォーマーより450%長い依存関係を学習し、短いシーケンスと長いシーケンスの両方でより良いパフォーマンスを達成し、評価中にバニラトランスフォーマーよりも最大1,800倍高速です。特に、bwiki / perplexityの最新の結果をenwiki8で0.99、text8で1.08、WikiText-103で18.3、10億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.