Abstract
Despite the impressive quality improvements yielded by neural machine translation (NMT) systems, controlling their translation output to adhere to user-provided terminology constraints remains an open problem. We describe our approach to constrained neural decoding based on finite-state machines and multi-stack decoding which supports target-side constraints as well as constraints with corresponding aligned input text spans. We demonstrate the performance of our framework on multiple translation tasks and motivate the need for constrained decoding with attentions as a means of reducing misplacement and duplication when translating user constraints.
Introduction
While Neural Machine Translation (NMT) has reached impressive levels of fluency, it remains a "black box" that is difficult to control. For corporate users, translating brand names or technical terms correctly and consistently is non-negotiable. Standard NMT often ignores user-provided glossaries or, conversely, might repeat a constrained term multiple times because the decoder doesn't "know" it has already covered that part of the source sentence. Previous attempts to solve this, like Grid Beam Search, were computationally expensive and often struggled with constraint placement—putting the right word in the wrong part of the sentence.
Methods: Finite-State Machines and Attention-Guided Decoding
The proposed framework for constrained neural decoding is built on two main pillars: Finite-State Acceptors (FSAs) and attention-based triggering.
Finite-State Acceptors (FSAs)
Before decoding, the system constructs an FSA that represents all valid permutations of the required terminology. This FSA guides the beam search, ensuring the final translation satisfies all constraints. It can handle multi-word phrases and even alternative constraints such as synonyms.
Decoding with Attentions
The "secret sauce" of this approach is the integration of the NMT model’s attention weights. Instead of forcing a word into the output blindly, the system monitors the attention mechanism. If the model is currently "attending" to a specific source span linked to a constraint, the decoder triggers that constraint.
This method offers two major advantages:
- Complexity Reduction: By using attention to decide when to apply a constraint, the search complexity is reduced from exponential ($O(2^c)$) to linear ($O(c)$) relative to the number of constraints ($c$).
- Masking: Once a constraint is used, the system "masks" the corresponding source tokens in the attention mechanism, preventing the model from translating the same concept twice—a common failure mode in standard constrained NMT.
Experimental Evaluation
The researchers evaluated their approach using WMT17 English-German and English-Chinese benchmarks. They tested the system using "Gold Constraints" (extracted from reference translations) to find the upper bound of performance, and "Dictionary Constraints" to simulate real-world user glossaries.
Key Results
The results demonstrate significant improvements in both translation quality and efficiency.
- Quality Gains: Using "Gold Constraints" led to massive BLEU score jumps (e.g., from 24.9 to 36.8 on English-German), proving that terminology control is a powerful lever for translation quality.
- Placement Accuracy: The attention-based approach (v2) successfully fixed "misplacement" errors where the system would otherwise translate a term in the wrong context.
- Speed: The optimized approach achieved up to a 5x speedup over previous state-of-the-art constrained search algorithms.
- Length Normalization: The attention mechanism brought the "length ratio" (lr) of translations back to approximately 1.0, effectively eliminating the word-repetition issues seen in earlier methods.
Conclusion and Future Work
This work demonstrates that treating NMT attention weights as "soft alignments" allows for efficient and accurate terminology control. By pruning the search space and masking covered spans, the authors made constrained decoding practical for production environments.
However, the system relies on the NMT model having high-quality attention. If the attention is blurry or incorrect, constraints might not trigger properly. Future work will explore how this applies to Transformer models, where multiple attention heads make the alignment signal more complex to extract. Additionally, the system remains sensitive to errors in the provided dictionary, as it will faithfully use any provided translation, even if incorrect.
Summary updated