Generating Long Sequences with Sparse Transformers

Rewon Child, Scott Gray, Alec Radford, Ilya Sutskever
4/23/2019
cs.LGstat.ML

Official code: openai/sparse_attention (1,612 stars, last commit 2020-08-12).

Abstract

Transformers are powerful sequence models, but require time and memory that grows quadratically with the sequence length. In this paper we introduce sparse factorizations of the attention matrix which reduce this to $O(n \sqrt{n})$. We also introduce a) a variation on architecture and initialization to train deeper networks, b) the recomputation of attention matrices to save memory, and c) fast attention kernels for training. We call networks with these changes Sparse Transformers, and show they can model sequences tens of thousands of timesteps long using hundreds of layers. We use the same architecture to model images, audio, and text from raw bytes, setting a new state of the art for density modeling of Enwik8, CIFAR-10, and ImageNet-64. We generate unconditional samples that demonstrate global coherence and great diversity, and show it is possible in principle to use self-attention to model sequences of length one million or more.

View on arXivView PDF

Code Implementations(1)

Examples of using sparse attention, as in "Generating Long Sequences with Sparse Transformers"

1,612192PythonApr 12, 20196 years ago

Similar Papers

Cite this paper

@article{child2019generating,
  title  = {Generating Long Sequences with Sparse Transformers},
  author = {Rewon Child and Scott Gray and Alec Radford and Ilya Sutskever},
  year   = {2019},
  eprint = {1904.10509},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1904.10509}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/1904.10509.svg)](https://codeofpaper.com/paper/1904.10509)

Discussion