Jointly Masked Sequence-to-Sequence Model for Non-Autoregressive Neural Machine Translation

Junliang Guo, Linli Xu, Enhong Chen

Abstract

Non-autoregressive translation (NAT) models significantly reduce inference latency by generating tokens in parallel, but they typically lag behind autoregressive models in translation quality. We present Jointly Masked Sequence-to-Sequence (JM-NAT), a model that utilizes simultaneous masking of the encoder and decoder during training to improve representation learning. Combined with a novel $n$-gram loss to reduce repetition, JM-NAT achieves performance comparable to the Transformer baseline on WMT14 tasks while providing over a 5x speedup.

Introduction

Traditional Neural Machine Translation (NMT) models are autoregressive (AR), generating text sequentially from left to right. While this approach captures strong dependencies between words, it creates a computational bottleneck with $O(n)$ complexity. Non-autoregressive translation (NAT) models aim to break this bottleneck by predicting all tokens in parallel, achieving $O(1)$ or $O(k)$ complexity. However, NAT models often struggle with incomplete translations due to shallow encoding and repetitive outputs caused by a lack of local context.

The JM-NAT Architecture

To address these challenges, the authors propose the Jointly Masked (JM-NAT) framework. This approach applies masking strategies to both the encoder and decoder simultaneously to force the model to learn more robust representations.

The JM-NAT architecture featuring joint masking of the encoder and decoder.

Key Methodological Components

  • Encoder Masking: Inspired by BERT, 10% of source tokens are randomly masked during training. This forces the encoder to reconstruct missing information, leading to a deeper understanding of the source sentence.
  • Consecutive Decoder Masking: Unlike random masking, the decoder masks consecutive chunks of the target sentence. This encourages the model to learn local dependencies and grammatical flow between adjacent words.
  • $n$-gram Based Loss: To combat the common NAT issue of word repetition (e.g., "the the cat"), a novel loss function counts matching $n$-grams between the prediction and the target, treating sequences of words as coherent units.
  • Iterative Inference: The model employs a "mask-and-predict" strategy during inference. It begins with a template of [MASK] tokens and iteratively refines the prediction over $k$ steps (typically 4 or 10), re-masking low-confidence tokens in each pass.

Key Insights: The Centrality of the Encoder

A significant finding of this research is that the encoder acts as the "brain" of the NAT model. Preliminary studies indicated that the encoder's quality has a much larger impact on final translation performance than the decoder's. Furthermore, training observations show that the encoder converges more slowly than the decoder. The joint masking strategy acts as a form of adversarial training, making the encoder more resilient and better equipped to provide the high-quality mapping required for parallel decoding.

Experimental Evaluation

The JM-NAT model was evaluated on standard benchmarks including WMT14 (English-German), WMT16 (English-Romanian), and IWSLT14 (German-English). The training utilized Sequence-Level Knowledge Distillation, where the NAT model learns from the output of a high-quality autoregressive teacher.

Performance comparison of JM-NAT against state-of-the-art autoregressive and non-autoregressive models.

As shown in the results table, JM-NAT achieves a BLEU score of 27.69 on the WMT14 En-De task, coming remarkably close to the autoregressive Transformer's 28.04. Crucially, it achieves this quality with a 5.73x speedup at $k=10$. The model also demonstrated significant robustness in adversarial tests and a dramatic reduction in repetitive tokens, dropping from 2.30 in baseline NAT to just 0.17 with the proposed $n$-gram loss.

Conclusion

JM-NAT successfully narrows the gap between non-autoregressive and autoregressive translation. By focusing on robust encoder representations and local context through joint masking and $n$-gram loss, the model provides a high-quality, high-speed alternative for NMT. Future work may focus on reducing the reliance on knowledge distillation and extending this framework to other sequence-to-sequence tasks like summarization.

Summary updated

BibTeX
@inproceedings{guo2020jointly,
  author = {Junliang Guo and Linli Xu and Enhong Chen},
  title = {{Jointly Masked Sequence-to-Sequence Model for Non-Autoregressive Neural Machine Translation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2020},
  doi = {10.18653/v1/2020.acl-main.36},
}
Figure