Abstract
Neural machine translation models rely on the beam search algorithm for decoding. In practice, we found that the quality of hypotheses in the search space is negatively affected owing to the fixed beam size. To mitigate this problem, we store all hypotheses in a single priority queue and use a universal score function for hypothesis selection. The proposed algorithm is more flexible as the discarded hypotheses can be revisited in a later step. We further design a penalty function to punish the hypotheses that tend to produce a final translation that is much longer or shorter than expected. Despite its simplicity, we show that the proposed decoding algorithm is able to select hypotheses with better qualities and improve the translation performance.
Introduction
In Neural Machine Translation (NMT), the decoding process typically employs beam search to find the most likely translation. Beam search maintains a fixed number of candidates (the "beam size") at each step. However, this approach has a fundamental limitation: it only compares hypotheses of the same length at any given time.
If a promising translation path appears slightly less probable at an early step, it is discarded permanently to make room for paths that look better in the immediate short term. This creates an exploration-exploitation dilemma where once a path is gone, it cannot be recovered, even if it would have led to a superior global optimum. This rigidity often results in a narrow and brittle search space.
Single-Queue Decoding (SQD)
To address these limitations, we propose Single-Queue Decoding (SQD). Instead of a step-by-step beam, SQD utilizes a global priority queue to manage the search process.
The Priority Queue and "Regret"
SQD stores all generated hypotheses in a single priority queue. In each decoding step, the algorithm selects the best $B$ unfinished hypotheses from the queue—regardless of their current length—to expand them. This introduces a "regret" mechanism: if a leading long hypothesis begins to receive lower scores, the algorithm can revisit shorter hypotheses that were previously set aside.
Universal Score Function
To facilitate fair comparison between hypotheses of different lengths, we employ a universal score function comprising:
- Length-normalized log-probability: The standard likelihood adjusted for sentence length.
- Progress Penalty (PG): A mechanism that rewards the model for progressing toward the end of the sentence, preventing the search from stalling on short fragments.
- Length Matching Penalty (LMP): A novel penalty where a small auxiliary neural network predicts the target translation length. Hypotheses that deviate significantly from this expected length are penalized.
Experimental Results
We evaluated SQD on the ASPEC (Asian Scientific Paper Excerpt Corpus) English-to-Japanese translation task. As shown in the results below, SQD provides a substantial performance boost.
The SQD algorithm with both PG and LMP achieved a 35.43 BLEU score, a gain of over 2.5 points compared to vanilla beam search (32.87). Notably, this improvement does not come at a prohibitive computational cost; the average number of decoding steps and total time remain comparable to standard methods.
Search Space Analysis
The primary advantage of SQD lies in its ability to maintain a higher quality search space. In standard beam search, the quality of alternative hypotheses (the 2nd, 3rd, etc., best options) often drops significantly as the search progresses.
As visualized in the box plots, SQD keeps the log-probabilities of alternative paths much closer to the top hypothesis. This richer set of options allows the model to find better global optima that standard beam search would have discarded.
Conclusion
Single-Queue Decoding offers a flexible alternative to traditional beam search by allowing the decoder to revisit previously discarded paths. By incorporating length-matching penalties and a global priority queue, SQD achieves significant improvements in translation quality. While the approach requires additional memory to store hidden states for potential revisitation, the gains in BLEU score and search space robustness make it a compelling technique for high-quality NMT.
Summary updated