Learning to Reuse Translations: Guiding Neural Machine Translation with Examples

Qian Cao, Shaohui Kuang, Deyi Xiong

Abstract

Modern Neural Machine Translation (NMT) models often fail to leverage existing translation memories, treating each translation task in isolation. This paper introduces the Example-Guided Neural Machine Translation (EGNMT) framework, which enables NMT models to retrieve and incorporate fragments from similar previously translated sentences. To address the challenge of "noise" in retrieved examples, the authors propose a Noise-Masked Encoder (NME) and an Auxiliary Decoder (AD). These components work together to surgically extract relevant translation fragments while ignoring irrelevant content. Evaluation across multiple language pairs shows that EGNMT significantly outperforms standard Transformers, achieving improvements of up to +9 BLEU points.

The Challenge of Translation Memory in NMT

Human translators frequently rely on Translation Memory (TM) systems to maintain consistency and efficiency by referencing past work. While older Statistical Machine Translation (SMT) systems were adept at integrating these memories, modern NMT models typically rely solely on internal parameters learned during training.

A primary difficulty in integrating TM into NMT is that retrieved examples are rarely exact matches. They contain "reusable" fragments that fit the current context and "noise"—words specific to the old sentence that should not be translated. Blindly following an example can lead to errors. The EGNMT framework aims to teach the model how to distinguish between these two types of information.

The EGNMT Framework

The EGNMT framework extends the standard Transformer architecture by adding a dedicated path for processing retrieved examples.

The EGNMT architecture featuring a Primary Encoder, an Example Encoder, and a joint Decoder.

Noise-Masked Encoder (NME)

The NME is designed to filter out irrelevant parts of a retrieved example before they reach the decoder. It uses word alignments to compare the current source sentence with the source sentence of the retrieved example. Words in the example translation that do not correspond to the current source are replaced with a mask symbol <X>. This process ensures the encoder provides the model with only "clean," reusable fragments.

Example of word alignment and the resulting masked sequences used to filter noise from retrieved examples.

Auxiliary Decoder (AD)

To further guide the model, the authors introduce an Auxiliary Decoder during the training phase. This decoder is tasked with predicting a masked version of the target sentence, containing only the words that overlap with the retrieved example. Because the auxiliary decoder shares parameters with the primary decoder, the model learns to prioritize and correctly integrate reusable phrases. During inference, the auxiliary decoder is discarded, leaving a primary decoder that has been "taught" how to effectively use examples.

Experimental Setup and Results

The researchers evaluated EGNMT on three language pairs: Chinese-English (UN Parallel Corpus), English-German, and English-Spanish (JRC-Acquis corpus). Examples were retrieved using Lucene and filtered for semantic similarity using fastText embeddings.

Key Findings

  • Significant Performance Gains: The full EGNMT model achieved massive improvements, including a +9 BLEU point increase over a baseline Transformer and +7 BLEU points over a standard dual-encoder setup.
  • Robustness to Low Similarity: Even when retrieved examples had low fuzzy match scores (20-30%), the NME successfully extracted useful information, proving more robust than models without masking.
  • Efficiency of Shallow Encoders: Interestingly, a single-layer "shallow" encoder for examples performed better than deeper ones. This suggests that the model primarily needs to "borrow" fragments rather than perform deep syntactic analysis of the example.

Discussion and Future Work

The EGNMT framework demonstrates that NMT models can be significantly improved by providing them with relevant examples and the tools to filter them. By sharing parameters between primary and auxiliary decoders, the model learns the abstract concept of "reusability."

Future research may explore utilizing multiple examples simultaneously to combine different useful fragments. Additionally, reducing the dependency on external word alignment tools could make the system more end-to-end and robust to alignment errors.

Summary updated

BibTeX
@inproceedings{cao2020learning,
  author = {Qian Cao and Shaohui Kuang and Deyi Xiong},
  title = {{Learning to Reuse Translations: Guiding Neural Machine Translation with Examples}},
  booktitle = {ECAI},
  year = {2020},
  doi = {10.3233/faia200318},
}
Figure