arXiv(opens in a new tab)cs.CLApr 2019Cited by 43 papers on PaperVantageClassic Paper

Manuscript Offprint

arXiv:1904.09751

The Curious Case of Neural Text Degeneration

Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, Yejin Choi

Abstract

Despite considerable advances in neural language modeling, it remains an open question what the best decoding strategy is for text generation from a language model (e.g. to generate a story). The counter-intuitive empirical observation is that even though the use of likelihood as training objective leads to high quality models for a broad range of language understanding tasks, maximization-based decoding methods such as beam search lead to degeneration — output text that is bland, incoherent, or gets stuck in repetitive loops.

To address this we propose Nucleus Sampling, a simple but effective method to draw considerably higher quality text out of neural language models than previous decoding strategies. Our approach avoids text degeneration by truncating the unreliable tail of the probability distribution, sampling from the dynamic nucleus of tokens containing the vast majority of the probability mass.

To properly examine current maximization-based and stochastic decoding methods, we compare generations from each of these methods to the distribution of human text along several axes such as likelihood, diversity, and repetition. Our results show that (1) maximization is an inappropriate decoding objective for open-ended text generation, (2) the probability distributions of the best current language models have an unreliable tail which needs to be truncated during generation and (3) Nucleus Sampling is currently the best available decoding strategy for generating long-form text that is both high-quality — as measured by human evaluation — and as diverse as human-written text.

Figure 1: Even with substantial human context and the powerful GPT-2 Large language model, Beam Search (size 32) leads to degenerate repetition (highlighted in blue) while pure sampling leads to incoherent gibberish (highlighted in red). When b≥64b\geq 64, both GPT-2 Large and XL (774M and 1542M parameters, respectively) prefer to stop generating immediately after the given context.

1 Introduction

On February 14th 2019, OpenAI surprised the scientific community with an impressively high-quality article about Ovid’s Unicorn, written by GPT-2. Notably, the top-quality generations obtained from the model rely on randomness in the decoding method, in particular through top-kk sampling that samples the next word from the top kk most probable choices (Fan et al., 2018; Holtzman et al., 2018; Radford et al., 2019), instead of aiming to decode text that maximizes likelihood.

In fact, decoding strategies that optimize for output with high probability, such as beam search, lead to text that is incredibly degenerate, even when using state-of-the-art models such as GPT-2 Large, as shown in Figure 1. This may seem counter-intuitive, as one would expect that good models would assign higher probability to more human-like, grammatical text. Indeed, language models do generally assign high scores to well-formed text, yet the highest scores for longer texts are often generic, repetitive, and awkward. Figure 2 exposes how different the distribution of probabilities assigned to beam search decoded text and naturally occurring text really are.

Perhaps equally surprising is the right side of Figure 1, which shows that pure sampling — sampling directly from the probabilities predicted by the model — results in text that is incoherent and almost unrelated to the context. Why is text produced by pure sampling so degenerate? In this work we show that the “unreliable tail” is to blame. This unreliable tail is composed of tens of thousands of candidate tokens with relatively low probability that are over-represented in the aggregate.

To overcome these issues we introduce Nucleus Sampling (§3.1). The key intuition of Nucleus Sampling is that the vast majority of probability mass at each time step is concentrated in the nucleus, a small subset of the vocabulary that tends to range between one and a thousand candidates. Instead of relying on a fixed top-kk, or using a temperature parameter to control the shape of the distribution without sufficiently suppressing the unreliable tail, we propose sampling from the top-pp portion of the probability mass, expanding and contracting the candidate pool dynamically.

In order to compare current methods to Nucleus Sampling, we compare various distributional properties of generated text to the reference distribution, such as the likelihood of veering into repetition and the perplexity of generated text.

Figure 2: The probability assigned to tokens generated by Beam Search and humans, given the same context. Note the increased variance that characterizes human text, in contrast with the endless repetition of text decoded by Beam Search.

The latter reveals that text generated by maximization or top-kk sampling is too probable, indicating a lack of diversity and divergence in vocabulary usage from the human distribution. On the other hand, pure sampling produces text that is significantly less likely than the gold, corresponding to lower generation quality.

Vocabulary usage and Self-BLEU (Zhu et al., 2018) statistics reveal that high values of kk are needed to make top-kk sampling match human statistics. Yet, generations based on high values of kk often have high variance in likelihood, hinting at qualitatively observable incoherency issues. Nucleus Sampling can easily match reference perplexity through tuning the value of pp, avoiding the incoherence caused by setting kk high enough to match distributional statistics.

Finally, we perform Human Unified with Statistical Evaluation (Hashimoto et al., 2019, HUSE;) to jointly assess the overall quality and diversity of the decoding strategies, which cannot be captured using either human or automatic evaluation alone. The HUSE evaluation demonstrates that Nucleus Sampling is the best overall decoding strategy. We include generated examples for qualitative analysis – see Figure 3 for a representative example, and further examples in the appendix.

References (32)

  • A learning algorithm for boltzmann machines
  • Neural machine translation by jointly learning to align and translate
  • Language gans falling short (opens arXiv in a new tab)
  • Recurrent neural networks as weighted language recognizers
  • Neural text generation in stories using entity representations as context
  • Language modeling with gated convolutional networks
  • Hierarchical neural story generation
  • Controlling linguistic style aspects in neural language generation
  • Unifying human and statistical evaluation for natural language generation
  • Learning to write with cooperative discriminators
  • Six challenges for neural machine translation
  • Importance of search and evaluation strategies in neural dialogue modeling
  • A simple, fast diverse decoding algorithm for neural generation (opens arXiv in a new tab)
  • Deep reinforcement learning for dialogue generation
  • Effective approaches to attention-based neural machine translation
  • Abstractive text summarization using sequence-to-sequence rnns and beyond
  • Sparse forward-backward using minimum divergence beams for fast training of conditional random fields
  • Towards controllable story generation (opens the publisher in a new tab)
  • Improving language understanding by generative pre-training, 2018
  • Language models are unsupervised multitask learners, February 2019
  • On accurate evaluation of gans for language generation (opens arXiv in a new tab)
  • Style transfer from non-parallel text by cross-alignment
  • On nmt search errors and model errors: Cat got your tongue? In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 3347–3353, 2019
  • Lstm neural networks for language modeling
  • Evaluating text gans as language models
  • Attention is all you need
  • Diverse beam search for improved description of complex scenes
  • Neural text generation with unlikelihood training
  • Challenges in data-to-document generation
  • Diversity-promoting gan: A cross-entropy based generative adversarial network for diversified text generation
  • Seqgan: Sequence generative adversarial nets with policy gradient
  • Texygen: A benchmarking platform for text generation models

Cited by (43)