Shortformer: Better Language Modeling using Shorter Inputs

Ofir Press, Noah A. Smith, Mike Lewis
12/31/2020
cs.CL
transformer-attention

Official code: ofirpress/shortformer (145 stars, Python, MIT, last commit 2021-07-26).

Abstract

Increasing the input length has been a driver of progress in language modeling with transformers. We identify conditions where shorter inputs are not harmful, and achieve perplexity and efficiency improvements through two new methods that decrease input length.

Show full abstract

First, we show that initially training a model on short subsequences before moving on to longer ones both reduces overall training time and, surprisingly, substantially improves perplexity. Second, we show how to improve the efficiency of recurrence methods in transformers, which let models condition on previously processed tokens when generating sequences that exceed the maximal length the transformer can handle at once. Existing methods require computationally expensive relative position embeddings; we introduce a simple alternative of adding absolute position embeddings to queries and keys instead of to word embeddings, which efficiently produces superior results. We show that these recurrent models also benefit from short input lengths. Combining these techniques speeds up training by a factor of 1.65, reduces memory usage, and substantially improves perplexity on WikiText-103, without adding any parameters.

View on arXivView PDF

Code Implementations(1)

MIT

Code for the Shortformer model, from the ACL 2021 paper by Ofir Press, Noah A. Smith and Mike Lewis.

1459Python, CudaDec 30, 20205 years agoMIT

Similar Papers

Cite this paper

@article{press2020shortformer,
  title  = {Shortformer: Better Language Modeling using Shorter Inputs},
  author = {Ofir Press and Noah A. Smith and Mike Lewis},
  year   = {2020},
  eprint = {2012.15832},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2012.15832}
}

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/2012.15832.svg)](https://codeofpaper.com/paper/2012.15832)

Discussion