Attention-based Vocabulary Selection for NMT Decoding

Baskaran Sankaran, Markus Freitag, Yaser Al-OnaizanarXiv 2017

Abstract

Neural Machine Translation (NMT) models usually use large target vocabulary sizes to capture most of the words in the target language. The vocabulary size is a big factor when decoding new sentences as the final softmax layer normalizes over all possible target words. To address this problem, it is widely common to restrict the target vocabulary with candidate lists based on the source sentence. Usually, the candidate lists are a combination of external word-to-word aligner, phrase table entries or most frequent words. In this work, we propose a simple and yet novel approach to learn candidate lists directly from the attention layer during NMT training. The candidate lists are highly optimized for the current NMT model and do not need any external computation of the candidate pool. We show significant decoding speedup compared with using the entire vocabulary, without losing any translation quality for two language pairs.

Introduction

A major bottleneck in NMT decoding is the final softmax layer. To predict the next word, the model must calculate a probability score for every single word in its vocabulary—which often contains 30,000 to 80,000 entries. Standard practice involves "vocabulary selection": creating a small list of candidate words based on the source sentence and only running the softmax over those. However, most existing methods rely on external tools like Viterbi word aligners or phrase tables, which add complexity and may not perfectly reflect the neural model's internal representations.

Methodology: Learning from Attention

We propose a "self-contained" approach: Attention-based Vocabulary Selection. During training, the NMT model uses an attention mechanism to decide which source words to focus on when generating a target word. We treat these attention weights as "soft alignments" and accumulate them into a sparse matrix that tracks target words frequently associated with source words.

Refinement and Training

To ensure high-quality candidate lists, we implement two key refinements:

  1. Delayed Start: We wait until after the first epoch of training to start recording alignments, ensuring the model has learned basic patterns first.
  2. Thresholding: We only record alignments where the attention weight exceeds a certain threshold ($\alpha_{thr}$), filtering out noise from frequent, non-descriptive words.
Figure 1: BLEU scores and average candidate counts across training epochs for different candidate list sizes (top-k).

As shown in Figure 1, the model's translation quality (BLEU) stabilizes as it learns alignments. Notably, this can be done via "Continue Training": a fully trained NMT model can run one extra epoch to learn these alignment lists without changing the model's weights.

Key Results

The researchers evaluated their method on German $\rightarrow$ English (WMT 2016) and Italian $\rightarrow$ English (20 million sentences) tasks.

Speed and Quality Trade-offs

For word-based models with an 80k vocabulary, the method achieved a 7.3x speedup. For BPE-based models (~40k vocabulary), it provided a ~3x speedup. Crucially, as shown in Table 2, these gains come with virtually no loss in translation quality (BLEU/TER). In some cases, the restricted vocabulary even slightly improved results by filtering out unlikely "noise" words.

Table 2: Decoding speedup and translation quality across different vocabulary sizes and alignment learning methods.

Conclusion

Attention-based vocabulary selection provides a "free" aligner that is internally consistent with the NMT model. It handles subword units (BPE) naturally and offers significant efficiency gains. Future work may explore applying this technique to speed up the training process itself through dynamic vocabulary selection.

Limitations

The performance is sensitive to the $\alpha_{thr}$ parameter; setting it too high can lead to poor coverage where the model misses valid but less-obvious translations. Additionally, while it outperforms external aligners like fast-align, further comparison with architectural changes like Hierarchical Softmax is warranted.

Summary updated

BibTeX
@misc{sankaran2017attention,
  author = {Baskaran Sankaran and Markus Freitag and Yaser Al-Onaizan},
  title = {{Attention-based Vocabulary Selection for NMT Decoding}},
  year = {2017},
  eprint = {1706.03824},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1706.03824},
}
Figure