Truncation Sampling as Language Model Desmoothing

John Hewitt, Christopher D. Manning, Percy Liang
10/27/2022
cs.CL

Official code: john-hewitt/truncation-sampling (13 stars, Jupyter Notebook, last commit 2022-12-06).

Abstract

Long samples of text from neural language models can be of poor quality. Truncation sampling algorithms--like top-$p$ or top-$k$ -- address this by setting some words' probabilities to zero at each step.

Show full abstract

This work provides framing for the aim of truncation, and an improved algorithm for that aim. We propose thinking of a neural language model as a mixture of a true distribution and a smoothing distribution that avoids infinite perplexity. In this light, truncation algorithms aim to perform desmoothing, estimating a subset of the support of the true distribution. Finding a good subset is crucial: we show that top-$p$ unnecessarily truncates high-probability words, for example causing it to truncate all words but Trump for a document that starts with Donald. We introduce $η$-sampling, which truncates words below an entropy-dependent probability threshold. Compared to previous algorithms, $η$-sampling generates more plausible long English documents according to humans, is better at breaking out of repetition, and behaves more reasonably on a battery of test distributions.

View on arXivView PDF

Code Implementations(1)

Codebase describing experiments in Truncation Sampling as Language Model Desmoothing

133Jupyter Notebook, PythonOct 25, 20223 years ago

Similar Papers

Cite this paper

@article{hewitt2022truncation,
  title  = {Truncation Sampling as Language Model Desmoothing},
  author = {John Hewitt and Christopher D. Manning and Percy Liang},
  year   = {2022},
  eprint = {2210.15191},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2210.15191}
}

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

Discussion