Best-First Beam Search

Clara Meister, Tim Vieira, Ryan Cotterell · OpenReview

Abstract

Decoding for many NLP tasks requires an effective heuristic algorithm for approximating exact search since the problem of searching the full output space is often intractable, or impractical in many settings. The default algorithm for this job is beam search -- a pruned version of breadth-first search. Quite surprisingly, beam search often returns better results than exact inference due to beneficial search bias for NLP tasks. In this work, we show that the standard implementation of beam search can be made up to 10x faster in practice. Our method assumes that the scoring function is monotonic in the sequence length, which allows us to safely prune hypotheses that cannot be in the final set of hypotheses early on. We devise effective monotonic approximations to popular nonmonontic scoring functions, including length normalization and mutual information decoding. Lastly, we propose a memory-reduced variant of Best-First Beam Search, which has a similar beneficial search bias in terms of downstream performance, but runs in a fraction of the time.

Introduction

In Natural Language Processing (NLP), decoding is the critical process of finding the most likely output sequence given an input. Due to the exponential growth of the search space, exact inference is often impossible. The industry standard for this task is Beam Search, a heuristic that maintains the top k most likely partial sequences at each time step. However, standard beam search is fundamentally a breadth-first algorithm, evaluating all possible next words for every hypothesis of length t before proceeding to length t+1. This approach is computationally wasteful, as it spends significant resources expanding mediocre short hypotheses even when superior, longer candidates are available.

Methodology: A Unified Search Framework

The authors propose Best-First Beam Search (BFBS), which reformulates decoding as an agenda-based algorithm similar to A* search. By utilizing a priority queue, BFBS always expands the hypothesis with the highest current score, regardless of its length.

Comparison of search algorithms within a unified framework.

A key contribution of this work is the unification of various search strategies. As shown in the table above, greedy search, beam search, and A* can be viewed as specific configurations of a single meta-algorithm, differing only in their priority functions, stopping criteria, and beam constraints.

The Role of Monotonicity

The efficiency of BFBS relies on the monotonicity of standard probabilistic models: the score of a sequence typically decreases as words are added. This allows for early termination: the first time a complete sentence (ending in an <EOS> token) is encountered, it is guaranteed to be the highest-scoring hypothesis. For non-monotonic scoring functions like length normalization, the authors introduce a bounding scheme to maintain "k-optimality," ensuring the results remain identical to standard beam search. To address the high memory usage typical of agenda-based searches, the authors also introduce a memory-reduced variant that prunes the worst-scoring active hypotheses from early time steps.

Experimental Results

The algorithm was evaluated on Neural Machine Translation (NMT) using the IWSLT’14 and WMT’17 De-En datasets, and on Abstractive Summarization (AS) using the CNN-DailyMail dataset.

  • Significant Speedups: BFBS achieved a 30% speedup for standard beam sizes ($k=5$) and up to a 10x speedup for larger beams ($k=500$).
  • Reduced Computational Cost: The primary bottleneck in decoding is the number of neural network calls required to score words. BFBS significantly reduces these calls; for instance, on the MTTT Fr-En task with $k=100$, it reduced model calls by 58%.
  • Performance Equivalence: Unlike other acceleration methods that sacrifice accuracy, BFBS is provably equivalent to standard beam search, yielding identical BLEU scores.

Discussion and Future Work

While BFBS offers substantial efficiency gains, it currently relies on scoring functions being monotonic or having tight upper bounds. Additionally, while it accelerates the search, it does not address the inherent search errors of the beam search heuristic itself. Future research may focus on developing better admissible heuristics to further bridge the gap between greedy search efficiency and large-beam search quality.

Summary updated

BibTeX
@article{meister2020best,
  author = {Clara Meister and Tim Vieira and Ryan Cotterell},
  title = {{Best-First Beam Search}},
  journal = {Trans. Assoc. Comput. Linguistics},
  year = {2020},
  url = {https://openreview.net/forum?id=Hb3AQRkMfb},
}
Figure