Skip to main content
QUICK REVIEW

[Paper Review] When to Finish? Optimal Beam Search for Neural Text Generation (modulo beam size)

Liang Huang, Kai Zhao|arXiv (Cornell University)|Aug 31, 2018
Natural Language Processing TechniquesComputer Science5 citations
TL;DR

This paper proposes a provably optimal beam search algorithm for neural text generation that guarantees the highest-scoring complete hypothesis (modulo beam size) by dynamically determining when to terminate beam search, ensuring optimality without unnecessary computation. It further introduces a bounded length reward mechanism to counteract the tendency of neural models to generate overly short outputs, enabling optimal performance even with length regularization, and demonstrates consistent BLEU score improvements over existing methods on machine translation tasks.

ABSTRACT

In neural text generation such as neural machine translation, summarization, and image captioning, beam search is widely used to improve the output text quality. However, in the neural generation setting, hypotheses can finish in different steps, which makes it difficult to decide when to end beam search to ensure optimality. We propose a provably optimal beam search algorithm that will always return the optimal-score complete hypothesis (modulo beam size), and finish as soon as the optimality is established (finishing no later than the baseline). To counter neural generation's tendency for shorter hypotheses, we also introduce a bounded length reward mechanism which allows a modified version of our beam search algorithm to remain optimal. Experiments on neural machine translation demonstrate that our principled beam search algorithm leads to improvement in BLEU score over previously proposed alternatives.

Motivation & Objective

  • To address the lack of theoretical optimality in existing beam search strategies for neural text generation, where hypotheses can finish at different steps.
  • To develop a beam search algorithm that guarantees the optimal-score complete hypothesis is returned, regardless of when hypotheses terminate.
  • To resolve the conflict between optimality and the need for length normalization or length rewards, which typically invalidate optimal beam search.
  • To introduce a bounded length reward mechanism that preserves optimality while mitigating the generation of overly short hypotheses.
  • To empirically validate the proposed method on neural machine translation, showing consistent improvements in BLEU scores over strong baselines.

Proposed method

  • Proposes a beam search variant that maintains a beam of size b and dynamically tracks the best-scoring complete hypothesis across all steps, ensuring optimality by not terminating early.
  • Introduces a termination condition that checks whether the best-scoring complete hypothesis in the current beam is guaranteed to be optimal, based on the score of the highest-scoring incomplete hypothesis.
  • Uses a bounded length reward mechanism where the reward is applied only up to a maximum threshold, preserving the optimality of the beam search algorithm.
  • Modifies the hypothesis scoring function to include a length-based reward that is capped at a predefined value, preventing over-penalization of shorter sequences.
  • Employs a dynamic stopping rule: beam search terminates only when the best-scoring complete hypothesis in the beam cannot be surpassed by any extension of incomplete hypotheses.
  • Integrates the bounded length reward into the beam search scoring function while maintaining the theoretical optimality of the algorithm through careful score propagation and pruning.

Experimental results

Research questions

  • RQ1Can a beam search algorithm be designed to guarantee the optimal-score complete hypothesis is returned, even when hypotheses terminate at different steps?
  • RQ2How can beam search be made optimal while also addressing the common issue of overly short generated sequences in neural text generation?
  • RQ3Does the use of length normalization or length rewards in beam search inherently compromise optimality, and if so, how can this be resolved?
  • RQ4Can a bounded length reward mechanism be designed such that it preserves the optimality of beam search while improving fluency and length of generated outputs?
  • RQ5What is the empirical impact of the proposed optimal beam search with bounded length reward on standard evaluation metrics like BLEU in neural machine translation?

Key findings

  • The proposed optimal beam search algorithm achieves a +5.0 BLEU improvement over greedy search (beam size 1) at beam size 15, outperforming all baselines.
  • On the test set, the method achieves 30.61 BLEU with beam size 15 and length reward r=1.2, surpassing OpenNMT-py's default beam search (29.75 BLEU) and the shrinking beam method with length reward (30.37 BLEU).
  • The pure optimal beam search degrades beyond beam size 4 due to extremely short translations, highlighting the necessity of length regularization.
  • The bounded length reward mechanism with r=1.2 and b=15 yields the best performance, with a length ratio of 0.97, indicating improved fluency without sacrificing optimality.
  • The method outperforms even the strong Moses SMT system (29.41 BLEU) and the RNNsearch baseline (30.70 BLEU), demonstrating its superiority in neural generation.
  • An independent bug fix in OpenNMT-py’s baseline beam search code was discovered, improving BLEU by +0.7 across all settings, further validating the robustness of the proposed method.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.