Efficient Context-Aware Neural Machine Translation with Layer-Wise Weighting and Input-Aware Gating

Hongfei Xu, Deyi Xiong, Josef van Genabith, Qiuhui Liu

Abstract

Standard Neural Machine Translation (NMT) systems often fail to maintain document-level consistency due to their sentence-by-sentence processing nature. This paper proposes a lightweight, efficient context-aware NMT model that leverages pre-trained sentence-level Transformers. By introducing layer-wise weighting of encoder representations and an input-aware gating mechanism, the model effectively captures cross-sentence context while minimizing computational overhead. Experimental results on English-Russian translation tasks demonstrate that the proposed approach outperforms previous state-of-the-art models in handling discourse phenomena like pronouns and ellipsis, while being nearly twice as fast in training and decoding.

Introduction

While sentence-level NMT has achieved high accuracy, it ignores document-level context, leading to inconsistencies in translating pronouns (deixis), maintaining lexical cohesion, and failing to handle dropped words (ellipsis). Existing context-aware models often rely on complex, parameter-heavy modules added to frozen pre-trained models, making them computationally expensive. This research addresses the challenge of incorporating cross-sentence context efficiently without massive overhead.

Methodology

The proposed architecture builds upon a frozen, pre-trained sentence-level Transformer, reusing its internal features to form context representations.

Architecture of the proposed context-aware NMT model, highlighting the input-aware source context encoding and context-aware decoding layers.

Layer-Wise Weighting

Instead of using only the final encoder layer, the model learns a weighted combination of all pre-trained encoder layers. This is based on the insight that shallower layers often retain more raw contextual information that deeper layers might abstract away.

Input-Aware Gating

To filter out irrelevant information from context sentences, a cross-attention network analyzes the current source sentence. A gating mechanism then "resets" or filters context features that do not contribute to the current translation task.

Context-Aware Decoding

A lightweight decoding layer is added on top of the pre-trained decoder. It integrates information from the source sentence, filtered source context, and target context (previous translations). To ensure robustness, target context embeddings are subject to a 0.1 token dropout.

Experimental Setup

The model was trained on the OpenSubtitles2018 English-Russian corpus (6M instances). Evaluation utilized standard BLEU scores and contrastive linguistic test sets designed to measure performance on discourse phenomena: deixis, lexical cohesion, and ellipsis.

Results and Discussion

The proposed model demonstrates significant improvements in both efficiency and linguistic accuracy.

Performance comparison across BLEU, training time (seconds/epoch), decoding speed (documents/second), and additional parameters.

Efficiency Gains

The model adds only 17.8M parameters, significantly fewer than baselines like CADec (34.6M) or Zhang et al. (75.8M). It achieves nearly double the decoding speed of CADec (4.98 vs 2.46 docs/s) and faster training times.

Linguistic Performance

Despite its lightweight nature, the model outperforms previous state-of-the-art systems on all contrastive test sets:

  • Deixis: 85.4% (vs 81.6% for CADec)
  • Lexical Cohesion: 64.3% (vs 58.1%)
  • Ellipsis (Inflection): 77.1% (vs 72.2%)
  • Ellipsis (VP): 81.3% (vs 80.0%)

Key Insights

Ablation studies revealed that shallow layers are most important for context encoding. Furthermore, the input-aware gating mechanism is crucial; removing it leads to a drop of over 2 points in linguistic test set accuracy. Interestingly, stacking multiple context layers was found to degrade performance, likely due to document-level data scarcity and overfitting.

Conclusion

This work presents a highly efficient method for context-aware NMT. By reusing pre-trained representations through layer-wise weighting and filtering them with input-aware gating, the model achieves superior discourse-level translation quality with minimal computational cost. Future work may focus on leveraging monolingual data to overcome the current document-level parallel data bottleneck.

Summary updated

BibTeX
@inproceedings{xu2020efficient,
  author = {Hongfei Xu and Deyi Xiong and Josef van Genabith and Qiuhui Liu},
  title = {{Efficient Context-Aware Neural Machine Translation with Layer-Wise Weighting and Input-Aware Gating}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2020},
  doi = {10.24963/ijcai.2020/544},
}
Figure