Integrating Vectorized Lexical Constraints for Neural Machine Translation

Shuo Wang, Zhixing Tan, Yang Liu · DOI

Introduction

Neural Machine Translation (NMT) has achieved remarkable success in general translation tasks. However, professional translation often requires adherence to specific terminology, such as technical jargon, brand names, or user-defined glossaries. This requirement, known as lexically constrained NMT, remains a significant challenge. Traditional NMT models operate as "black boxes," making it difficult to enforce the inclusion of specific words or phrases without compromising the fluency of the output.

The Problem: The Representation Gap

The primary obstacle in lexically constrained NMT is the "representation gap." NMT models process information using continuous hidden states (vectors), whereas lexical constraints are discrete tokens. Existing solutions generally fall into two categories, both of which have notable drawbacks:

  1. Data Augmentation: Models are trained on synthetic data where constraints are embedded into the source text. While this encourages the model to learn the mapping, it is often unreliable during inference, as the model may ignore the constraints.
  2. Constrained Decoding: Algorithms like Vectorized Dynamic Beam Allocation (VDBA) force the search process to select specific words. While this ensures constraint satisfaction, it is computationally expensive and often results in "robotic" or ungrammatical translations because the constraints are forced into the sentence from the outside, rather than being integrated into the model's internal logic.

Methodology: Vectorized Lexical Constraints

Researchers from Tsinghua University propose a novel approach that integrates constraints directly into the Transformer architecture by vectorizing them. This method leverages the inherent structure of the Attention mechanism, which uses Keys (K) and Values (V) to process information.

Constraint Vectorization and Attention Integration

The core innovation lies in treating bilingual constraints as a mapping ($Source \rightarrow Target$). The source constraints are converted into keys, and the corresponding target constraints are converted into values. These new key-value pairs are then injected into the Encoder’s self-attention and the Decoder’s cross-attention modules. In this setup, the source constraint acts as an indicator (key) that signals the model to attend to the specific target translation (value) when the context is appropriate.

Output Layer Plug-in

To ensure the model prioritizes the constrained tokens at the final step, the authors introduced a "plug-in" module at the output layer. This module employs a gating mechanism that boosts the probability of constrained tokens based on the similarity between the model's current hidden state and the constraint's embedding. This ensures that the model doesn't just "think" about the constraint but actually selects it for the final output.

Two-Stage Training

Because the parameters required for constraint integration ($\theta_c$) are significantly fewer than the base model parameters ($\theta_v$), the researchers utilized a two-stage training process. First, a standard NMT model is trained on a large corpus. Second, the entire system is fine-tuned to handle lexical constraints, allowing the model to learn how to naturally incorporate these specific terms into its translations.

Experimental Results

The model was evaluated on four translation directions: Chinese $\Leftrightarrow$ English (Zh $\Leftrightarrow$ En) and German $\Leftrightarrow$ English (De $\Leftrightarrow$ En), using datasets from LDC and WMT 2014.

Translation Quality and Success Rate

The proposed method demonstrated superior performance across two key metrics:

  • Translation Quality: The model achieved an average 39.6 BLEU score, significantly outperforming the Vanilla Transformer (35.7) and the VDBA decoding method (37.7). This suggests that integrating constraints internally leads to more natural and fluent translations.
  • Copying Success Rate (CSR): The model reached a 99.6% CSR on average. This matches the performance of "hard" constrained decoding algorithms while maintaining the speed and flexibility of a standard NMT model.

Efficiency and Generalization

Unlike constrained decoding, which slows down significantly during inference, the vectorized approach is highly efficient and suitable for batched inputs in production environments. Furthermore, the model showed strong generalization; even when test constraints had low overlap with the training data (~35%), the model successfully applied them over 94% of the time.

Conclusion and Future Work

By "opening the black box" and integrating constraints into the attention mechanism, this research provides a robust solution for terminology-heavy translation tasks. While the method introduces some parameter overhead and a more complex two-stage training process, the gains in quality and reliability are substantial. Future research may extend this vectorized integration approach to control other text attributes, such as sentiment, style, or specific topics, further expanding the controllability of neural generation models.

Summary updated

BibTeX
@inproceedings{wang2022integrating,
  author = {Shuo Wang and Zhixing Tan and Yang Liu},
  title = {{Integrating Vectorized Lexical Constraints for Neural Machine Translation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.acl-long.487},
}
Figure