Training Neural Machine Translation To Apply Terminology Constraints

Georgiana Dinu, Prashant Mathur, Marcello Federico, Yaser Al-Onaizan

Abstract

This paper proposes a novel method to inject custom terminology into neural machine translation at run time. Previous works have mainly proposed modifications to the decoding algorithm in order to constrain the output to include run-time-provided target terms. While being effective, these constrained decoding methods add, however, significant computational overhead to the inference step, and, as we show in this paper, can be brittle when tested in realistic conditions. In this paper we approach the problem by training a neural MT system to learn how to use custom terminology when provided with the input. Comparative experiments show that our method is not only more effective than a state-of-the-art implementation of constrained decoding, but is also as fast as constraint-free decoding.

Introduction

While modern Neural Machine Translation (NMT) systems are impressively fluent, they often struggle with highly specialized domains—such as legal, medical, or technical fields—where specific terms must be translated exactly as defined in a glossary. The standard solution, constrained decoding, modifies the search algorithm at inference time to force specific target words. However, this approach is computationally expensive (often 3x slower) and brittle; rigid constraints often fail to handle necessary word inflections, leading to grammatical errors or translation failures.

Methodology

This work proposes a "black-box" approach that shifts the complexity from the decoding algorithm to the training phase. Instead of forcing the model during search, the model is trained to follow "inline" terminology instructions provided within the source text.

Input Augmentation

Two main techniques were developed to augment source text with terminology:

  1. Train-by-appending: The target term is placed immediately after its source counterpart.
  2. Train-by-replace: The source term is swapped entirely for the target term.

To help the model distinguish between standard text and constraints, the researchers utilized source factors. This adds a numerical signal to every input token: 0 for standard words, 1 for source terms in a glossary, and 2 for the provided target-language constraint.

Examples of the proposed input augmentation methods (Append and Replace) using source factors to signal terminology constraints.

Experimental Setup

The models were tested on English-to-German translation using 2.2 million sentences from the WMT 2018 task. Real-world constraints were extracted from Wiktionary and IATE (the EU's terminology database). Crucially, evaluation was performed in a zero-shot setting, ensuring the model learned the mechanism of using constraints rather than just memorizing specific words.

Key Results

Speed and Efficiency

The proposed method maintains the speed of a standard NMT model. In testing, it proved to be 3x faster than state-of-the-art constrained decoding (Dynamic Beam Allocation), which requires significant overhead during the beam search process.

Accuracy and Translation Quality

On the Wiktionary dataset, the "train-by-replace" method achieved a 93.4% term usage rate, a significant jump from the 76.9% baseline. Unlike constrained decoding, which often suffers a drop in BLEU scores due to its rigidity, this method improved BLEU scores by up to 0.9 points. By treating constraints as suggestions rather than hard rules, the model can correctly inflect terms to fit the grammatical context of the sentence.

Performance comparison across Wiktionary and IATE datasets, showing term usage rate, BLEU score, and inference time.

Discussion and Future Work

By decoupling terminology logic from the decoder architecture, this method remains compatible with standard Transformer models and is suitable for production environments. The model effectively learns a "copying protocol" that generalizes to unseen terms.

However, as a black-box approach, it does not offer the 100% inclusion guarantee of hard-constrained decoding. Future research may explore the limits of constraint density per sentence and apply these techniques to more morphologically rich languages where grammatical inflection is even more complex.

Summary updated

Abstract

This paper proposes a novel method to inject custom terminology into neural machine translation at run time. Previous works have mainly proposed modifications to the decoding algorithm in order to constrain the output to include run-time-provided target terms. While being effective, these constrained decoding methods add, however, significant computational overhead to the inference step, and, as we show in this paper, can be brittle when tested in realistic conditions. In this paper we approach the problem by training a neural MT system to learn how to use custom terminology when provided with the input. Comparative experiments show that our method is not only more effective than a state-of-the-art implementation of constrained decoding, but is also as fast as constraint-free decoding.
BibTeX
@inproceedings{dinu2019training,
  author = {Georgiana Dinu and Prashant Mathur and Marcello Federico and Yaser Al-Onaizan},
  title = {{Training Neural Machine Translation To Apply Terminology Constraints}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2019},
  url = {https://openreview.net/forum?id=HK10nUV-gpm},
}
Figure