Mask-Predict: Parallel Decoding of Conditional Masked Language Models

Marjan Ghazvininejad, Omer Levy, Yinhan Liu, Luke Zettlemoyer

Introduction

Standard machine translation models, such as the Transformer, are inherently autoregressive, generating text sequentially from left to right. This process creates a significant computational bottleneck during inference because each token depends on all previously generated ones. While non-autoregressive models aim to generate all words simultaneously to improve speed, they often suffer from the "multi-modality problem," leading to ungrammatical repetitions like "The The cat sat."

Researchers at Facebook AI Research have introduced Mask-Predict, a novel decoding algorithm that addresses these challenges. By utilizing a Conditional Masked Language Model (CMLM) and an iterative refinement process, Mask-Predict achieves a 3x speedup over standard Transformers while maintaining translation quality within 1–2 BLEU points of state-of-the-art autoregressive models.

Methodology

Conditional Masked Language Models (CMLMs)

Unlike standard Transformers that employ a causal mask to prevent the model from attending to future tokens, CMLMs use a bi-directional decoder. During training, the model receives a source sentence and a target sentence where a random subset of tokens is replaced with a [MASK] symbol. The model is then trained to predict these missing tokens based on the source sentence and the surrounding unmasked target context.

The Mask-Predict Algorithm

Mask-Predict is an iterative decoding strategy designed to refine parallel predictions:

  1. Initialization: The process begins with a sequence of [MASK] tokens. To determine the initial sequence length, the authors added a special LENGTH token to the encoder.
  2. Predict: All masked tokens are predicted in parallel.
  3. Mask: The model identifies tokens with the lowest prediction confidence and re-masks them. The number of masked tokens decreases linearly across iterations.
  4. Repeat: The masked tokens are re-predicted using the high-confidence tokens from the previous step as context.
Example of iterative refinement using Mask-Predict.

This iterative approach allows the model to "reconsider" its choices over a fixed number of steps (typically 4 to 10), effectively eliminating the noise and repetitions common in single-pass parallel generation.

Evaluation and Results

The model was evaluated on standard benchmarks, including WMT’14 English-German (EN-DE), WMT’16 English-Romanian (EN-RO), and WMT’17 English-Chinese (EN-ZH). To simplify the data distribution, the authors employed Knowledge Distillation, training the CMLM on outputs from a pre-trained autoregressive Transformer teacher.

Performance and Efficiency

Mask-Predict demonstrated a significant performance leap, outperforming previous non-autoregressive state-of-the-art models by approximately 4 BLEU points on WMT’14 EN-DE. Notably, a CMLM with 10 iterations achieves quality comparable to a standard Transformer while being three times faster at inference.

Trade-off between decoding speed-up and translation performance (BLEU).

Key findings include:

  • Iteration Efficiency: Most corrections occur early; even with just 4 iterations, the model surpasses previous iterative and non-autoregressive models.
  • Constant Time Complexity: Unlike autoregressive decoding ($O(N)$), Mask-Predict runs for a fixed number of iterations ($O(T)$), making it highly efficient for long sequences.
  • Bi-directionality: Allowing the decoder to see both left and right context during refinement is crucial for producing coherent results.

Limitations

Despite its successes, Mask-Predict has some limitations. It is heavily dependent on Knowledge Distillation, performing significantly worse when trained on raw data. Additionally, the model must commit to a sequence length at the start, which is handled via a heuristic of decoding multiple length candidates in parallel. While the gap is narrowing, there remains a slight quality sacrifice for the gain in speed, especially in complex language pairs.

Conclusion

Mask-Predict represents a major step forward in non-autoregressive machine translation. By combining bi-directional context with iterative refinement, it breaks the sequential bottleneck of traditional decoding without the catastrophic quality loss seen in earlier parallel methods.

Summary updated

BibTeX
@inproceedings{ghazvininejad2019mask,
  author = {Marjan Ghazvininejad and Omer Levy and Yinhan Liu and Luke Zettlemoyer},
  title = {{Mask-Predict: Parallel Decoding of Conditional Masked Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2019},
  doi = {10.18653/v1/d19-1633},
}
Figure