A Call for Clarity in Beam Search: How It Works and When It Stops

Jungo Kasai, Keisuke Sakaguchi, Ronan Le Bras, Dragomir Radev, Yejin Choi +1 more
4/11/2022
cs.CL

Official code: jungokasai/beam_with_patience (46 stars, Python, last commit 2022-04-13).

Abstract

Text generation with beam search has proven successful in a wide range of applications. We point out that, though largely overlooked in the literature, the commonly-used implementation of beam decoding (e.g., Hugging Face Transformers and fairseq) uses a first come, first served heuristic: it keeps a set of already completed sequences over time steps and stops when the size of this set reaches the beam size.

Show full abstract

Based on this finding, we introduce a patience factor, a simple modification to this beam decoding implementation, that generalizes the stopping criterion and provides flexibility to the depth of search. Empirical results demonstrate that adjusting this patience factor improves decoding performance of strong pretrained models on news text summarization and machine translation over diverse language pairs, with a negligible inference slowdown. Our approach only modifies one line of code and can be thus readily incorporated in any implementation. Further, we find that different versions of beam decoding result in large performance differences in summarization, demonstrating the need for clarity in specifying the beam search implementation in research work. Our code will be available upon publication.

View on arXivView PDF

Code Implementations(1)

462Python, PerlMar 23, 20224 years ago

Similar Papers

Cite this paper

@article{kasai2022call,
  title  = {A Call for Clarity in Beam Search: How It Works and When It Stops},
  author = {Jungo Kasai and Keisuke Sakaguchi and Ronan Le Bras and Dragomir Radev and Yejin Choi and Noah A. Smith},
  year   = {2022},
  eprint = {2204.05424},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2204.05424}
}

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

Discussion