Introduction
Lexically constrained Neural Machine Translation (NMT) aims to force the model to use specific terminology or phrases in its output. This is critical for domain-specific translations, such as technical manuals or brand-consistent marketing materials. Traditional methods often rely on "black-box" approaches like constrained decoding (modifying beam search) or data augmentation. However, these methods frequently result in slow inference speeds or unnatural, "robotic" translations due to a fundamental "representation gap" between discrete word constraints and the continuous vector space of NMT models.
Methodology: Opening the Black Box
This research proposes a novel architecture that integrates constraints directly into the Transformer's internal mechanisms by vectorizing them.
Constraints as Keys and Values
The core innovation treats source-target constraint pairs as additional Keys and Values within the attention modules. When the model's "Query" (representing the current context) matches a "Key" (the source constraint), the attention mechanism naturally assigns higher weight to the corresponding "Value" (the target constraint).
Architectural Integration
To bridge the manifold differences between layers, the authors utilize layer-wise adaptation networks. These small networks transform constraint vectors to align with the specific linguistic information captured at each encoder and decoder layer. Constraints are injected into both the encoder self-attention and the decoder cross-attention layers.
Furthermore, an Output Layer Plug-in is introduced. This component uses a gating mechanism to boost the probability of generating constrained tokens based on the cosine similarity between the decoder's hidden state and the target word embeddings. The system is trained in two stages: first, a vanilla NMT model is established, followed by fine-tuning the entire architecture with a weighted loss function to balance general translation quality with constraint adherence.
Experimental Results
The model was evaluated on Chinese-English (Zh-En) and German-English (De-En) datasets, using human-annotated alignment sets to ensure meaningful constraints.
- Translation Quality: The proposed method achieved superior BLEU scores compared to strong baselines like VDBA and CDAlign. For instance, on the Zh-En task, it reached 34.4 BLEU, outperforming VDBA's 31.6.
- Constraint Adherence: The model demonstrated a 94.4% Copying Success Rate (CSR) using standard beam search. When combined with constrained decoding, this success rate rose to near-perfection at 99.6%. Notably, the model maintained high success rates even for constraints not seen during training, indicating it learned the concept of following constraints rather than just memorizing pairs.
- Efficiency: By integrating constraints into the forward pass, the model avoids the heavy computational overhead of specialized decoding algorithms, making it significantly faster and more suitable for production environments.
Conclusion
By moving away from external decoding hacks and instead vectorizing lexical constraints for architectural integration, this approach achieves a high degree of control over NMT output without sacrificing fluency or speed. The model's improved Expected Calibration Error (ECE) suggests it produces more naturally calibrated translations. Future work may extend this vectorization technique to control other attributes such as style, sentiment, or topic.
Summary updated