<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>The curious case of neural text degeneration</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Ari Holtzman</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jan Buys</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Leo Du</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Maxwell Forbes</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yejin Choi</string-name>
          <email>yejing@cs.washington.edu</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Allen Institute for Arti cial Intelligence</institution>
          ,
          <addr-line>Seattle, WA</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Department of Computer Science, University of Cape Town</institution>
          ,
          <country country="ZA">South Africa</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Paul G. Allen School of Computer Science &amp; Engineering, University of Washington</institution>
          ,
          <addr-line>Seattle, WA</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Despite considerable advances in neural language modeling, it remains an open question what the best strategy is for generating text from a language model. Counter-intuitively, maximization-based decoding methods such as beam search lead to degeneration | output text that is bland, incoherent, or repetitive. We propose Nucleus Sampling, a simple but e ective method to draw high quality text out of neural language models by truncating the unreliable tail of the probability distribution, sampling words from the nucleus of tokens containing most probability mass. We compare generations from maximization-based and stochastic decoding methods to the distribution of human text along several axes including 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 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.</p>
      </abstract>
      <kwd-group>
        <kwd>Natural Language Generation</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        On February 14th 2019, OpenAI surprised the scienti c community by
releasing an impressively high-quality article about Ovid's Unicorn, written by
GPT-2, the largest neural language model reported to date [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. Notably, the
best generations obtained from the model relied on randomness in the decoding
method, in particular through top-k sampling that samples the next word from
the top k most probable choices [
        <xref ref-type="bibr" rid="ref1 ref3 ref4">1, 3, 4</xref>
        ], instead of aiming to decode text that
maximizes likelihood. In fact, decoding strategies that optimize output
probability, such as greedy or beam search, lead to text that is incredibly degenerate,
even when using state-of-the-art models such as GPT-2 (117M parameters), as
can be seen in Figure 1. This is counter-intuitive, as one would expect that good
models would assign higher probability to more human-like, grammatical text.
      </p>
      <p>We provide novel insights into the shortcomings of existing models and
decoding methods for open-ended text generation { generating a story or a plausible
continuation of a text passage { through novel metrics and analyses. To
overcome these shortcomings we introduce Nucleus Sampling : The key intuition is</p>
      <p>A. Holtzman et al.
that the vast majority of probability mass at each time step is concentrated in
the nucleus, a small subset of the vocabulary that contains most of the plausible
next words. Instead of relying on a xed top-k, or using a temperature
parameter to control the shape of the distribution without su ciently suppressing the
unreliable tail distribution (containing the large subset of implausible words),
we propose sampling from the top-p portion of the probability mass, expanding
and contracting the candidate pool dynamically.</p>
      <p>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.
The latter shows that text generated by maximization or top-k 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 signi cantly less likely than the human-written reference text, and generation
quality is correspondingly lower.</p>
      <p>
        Vocabulary usage and Self-BLEU [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] statistics indicate that high values of k
are needed to make top-k sampling match human statistics. Yet, generations in
this setting have high variance in likelihood, which is re ected in qualitatively
observable incoherencies. Nucleus Sampling can match reference perplexity through
a proper value of p. Qualitative analysis shows that text generated by Nucleus
Sampling is more coherent than generations from other the decoding strategies
(see Figure 1 for example outputs).
      </p>
      <p>
        Finally, we perform Human Uni ed with Statistical Evaluation (HUSE) [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]
to jointly assess the overall quality and diversity of the decoding strategies,
which cannot be captured using either human or automatics evaluation alone.
The HUSE evaluation demonstrates that Nucleus sampling is the best overall
decoding strategy.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Fan</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lewis</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dauphin</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          :
          <article-title>Hierarchical neural story generation</article-title>
          .
          <source>In: Proceedings of the Association for Computational Linguistics</source>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Hashimoto</surname>
            ,
            <given-names>T.B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zhang</surname>
          </string-name>
          , H.,
          <string-name>
            <surname>Liang</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Unifying human and statistical evaluation for natural language generation</article-title>
          .
          <source>In: Proceedings of the Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies</source>
          (
          <year>2019</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Holtzman</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Buys</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Forbes</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bosselut</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Golub</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Choi</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          :
          <article-title>Learning to write with cooperative discriminators</article-title>
          .
          <source>In: Proceedings of the Association for Computational Linguistics</source>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Radford</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wu</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Child</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Luan</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Amodei</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sutskever</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          :
          <article-title>Language models are unsupervised multitask learners</article-title>
          (
          <year>February 2019</year>
          ), Unpublished manuscript
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Zhu</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lu</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zheng</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Guo</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          , Zhang,
          <string-name>
            <given-names>W.</given-names>
            ,
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            ,
            <surname>Yu</surname>
          </string-name>
          ,
          <string-name>
            <surname>Y.</surname>
          </string-name>
          :
          <article-title>Texygen: A benchmarking platform for text generation models</article-title>
          .
          <source>In: ACM SIGIR Conference on Research and Development in Information Retrieval</source>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>