HanoiT: Enhancing Context-aware Translation via Selective Context

Jian Yang, Yuwei Yin, Shuming Ma, Liqun Yang, Hongcheng Guo, Haoyang Huang, Dongdong Zhang, Yutao Zeng, Zhoujun Li, Furu Wei

Abstract

Document-level neural machine translation (NMT) aims to improve translation quality by incorporating surrounding text. However, standard context-aware models often suffer from contextual noise, where irrelevant information from neighboring sentences distracts the decoder. This paper introduces HanoiT (Hanoi Transformer), a model that employs a "Tower of Hanoi" inspired layer-wise selection mechanism to filter out noisy context. By gradually discarding less relevant words through specialized selective layers, HanoiT ensures the decoder focuses on the most pertinent information. Experimental results across four English-to-German benchmarks demonstrate that HanoiT consistently outperforms traditional Transformers and existing context-aware baselines.

1. Introduction

Traditional Neural Machine Translation (NMT) systems typically operate on a sentence-by-sentence basis, ignoring the broader document context. This limitation often leads to inconsistencies in terminology, pronoun resolution, and stylistic flow. While context-aware NMT models have been developed to address this by incorporating neighboring sentences, they frequently treat all context words with equal importance. In reality, much of the surrounding text is "noise"—irrelevant data that can distract the model from the primary translation task.

The challenge lies in effectively sifting through long document contexts to identify the specific information necessary for disambiguation and coherence. This paper presents HanoiT, a novel architecture designed to selectively filter context through a hierarchical pruning process.

2. Methodology: The Hanoi Transformer

HanoiT introduces a specialized encoder-decoder architecture where the encoder is divided into two distinct functional stages: Unified Self-attention and Selective Layers.

2.1 Unified Self-attention Layers ($N_1$)

In the initial stage, the model processes a concatenated sequence consisting of the current source sentence and its surrounding context (typically the previous and subsequent sentences). These $N_1$ layers allow the model to capture the initial semantic relationships between all words in the window, establishing a baseline understanding of the document's local structure.

2.2 Selective Layers ($N_2$)

The core innovation of HanoiT is the Selective Layer stage. Inspired by the "Tower of Hanoi" puzzle—where disks are moved to form a narrowing stack—these layers gradually reduce the amount of context data processed by the model.

  • Selection Criterion: The model calculates a "context-to-source" attention score. A context word is retained only if its average attention score with the source sentence exceeds a predefined threshold $q$.
  • Layer-wise Pruning: As the data ascends through the $N_2$ layers, irrelevant or noisy context words are masked out. This creates a "peak" of essential information at the top layers, ensuring the decoder receives only the most helpful contextual cues.

2.3 Bi-lingual Integration

HanoiT can be extended to handle "bi-lingual context." This involves using a gating mechanism to combine filtered information from both the source document and a preliminary translation of the target document. This helps the model leverage both source-side and target-side cues for better disambiguation.

3. Experimental Setup

The effectiveness of HanoiT was evaluated on four widely used English-to-German (En-De) document-level translation benchmarks:

  • IWSLT-2017: Transcripts of TED talks.
  • NC-2016: News Commentary corpus.
  • Europarl: Proceedings of the European Parliament.
  • WMT-2019: News translation shared task.

The model was compared against standard Transformers and specialized context-aware models like the Flat Transformer and SAN.

4. Results and Discussion

HanoiT demonstrated superior performance across all tested datasets, proving the value of selective context filtering.

4.1 Performance Gains

In mono-lingual context tasks, HanoiT achieved BLEU score improvements ranging from +0.42 to +0.81 over a strong re-implemented Transformer baseline. It also outperformed specialized models; for instance, it surpassed the SAN model by +0.44 BLEU on the NC-2016 dataset.

4.2 The Impact of Selective Filtering

A key finding was that aggressive filtering is often beneficial. Architectures with more selective layers ($N_2$) and fewer unified layers ($N_1$)—such as a 1/5 split—frequently yielded the best results. This suggests that removing noise is as critical as providing context. Visualization of attention maps confirmed that the model successfully pruned context words, focusing instead on semantically related terms (e.g., linking "headache" in the source to "aspirin" in the context).

4.3 Pre-training Compatibility

HanoiT is highly compatible with large-scale pre-trained models. When initialized with BART weights, the model achieved a significant gain of +1.91 BLEU on the IWSLT-2017 dataset, suggesting that the selective mechanism complements the linguistic knowledge captured during pre-training.

5. Conclusion and Future Work

HanoiT provides a robust solution to the problem of contextual noise in document-level NMT. By mimicking the narrowing structure of the Tower of Hanoi, the model effectively prunes irrelevant information, leading to more accurate and coherent translations.

Future research may address the "diminishing returns" observed when expanding the context window beyond a few sentences. Additionally, mitigating error propagation in bi-lingual settings—where the quality of the target context depends on an initial translation pass—remains a priority for further development.

Summary updated

BibTeX
@inproceedings{yang2023hanoit,
  author = {Jian Yang and Yuwei Yin and Shuming Ma and Liqun Yang and Hongcheng Guo and Haoyang Huang and Dongdong Zhang and Yutao Zeng and Zhoujun Li and Furu Wei},
  title = {{HanoiT: Enhancing Context-aware Translation via Selective Context}},
  booktitle = {DASFAA},
  year = {2023},
  doi = {10.1007/978-3-031-30675-4\_34},
}
Figure