Is Encoder-Decoder Redundant for Neural Machine Translation?

Yingbo Gao, Christian Herold, Zijian Yang, Hermann NeyarXiv 2022

TL;DR

This paper challenges the long-standing assumption that machine translation requires a separate encoder and decoder. By treating translation as a contextualized language modeling task on concatenated source-target sequences, the authors demonstrate that a single "encoder-only" Transformer can match the performance of state-of-the-art models across bilingual, multilingual, and back-translation tasks.

What Problem Does This Paper Address?

Since the inception of Neural Machine Translation (NMT), the encoder-decoder architecture has been the de facto standard. The intuition is simple: an encoder maps the source sentence into a hidden representation, and a decoder generates the target sentence based on that representation.

However, modern Large Language Models (LLMs) have shown an incredible capacity to handle long contexts. This raises a provocative question: Is the strict architectural separation of encoding and decoding actually necessary? If we simply treat the source sentence as additional context for a target-side language model, can we achieve the same results with a simpler, unified architecture?

Methods

The authors propose the Translation Language Model (TLM). Instead of two separate modules, the TLM uses a single Transformer encoder.

  1. Input Representation: The source ($f$) and target ($e$) sentences are concatenated into a single sequence: <s> source </s> <t> target </t>.
  2. Attention Masking: The authors experimented with different masking strategies for the source side. While the target side always uses a causal (triangular) mask to prevent "cheating" during generation, they found that the source side benefits most from a full mask, allowing every source token to attend to every other source token.

    Figure 1: Attention masks in TLM with (a) a triangu- lar mask, and (b) a full mask, at the source side. The horizontal direction is the query direction and the verti- cal direction is the key direction. Shaded areas mean that the attention is valid and white areas mean that the attention is blocked. The matrices C, B, and D cor- respond to the encoder self attention, the decoder self attention and encoder-decoder cross attention in Trans- former, respectively. The matrix A is whitened in both cases because we should not allow the source positions attend to future target positions.
  3. Training Objective: The model is trained with a joint loss: $L_{TLM} = \lambda L_{RE} + L_{MT}$.

  4. $L_{MT}$ is the standard translation loss (cross-entropy on the target tokens).
  5. $L_{RE}$ is an auxiliary source reconstruction loss. This can be formulated as an autoregressive language modeling task (shifting the source) or an auto-encoding task (no shift).

    Figure 2: Shifting versus no shifting of the output at the source side in TLM. The output at the target side is shifted in both cases. <s>, </s>, <t> and </t> are artificial start and end of sentence symbols at the source and target side respectively2. <m> denotes BERT-style (Devlin et al., 2019) randomly masked tokens. When matrix C in Fig.1 is triangular, (a) corresponds to a language modeling objective. When C is full, (b) corresponds to an auto-encoding objective. During search, <s>, f0, ..., fJ, </s>, <t> is presented to the model, and beam search is done by minimizing LMT.
  6. Noise: To prevent the model from learning a trivial copying task during source reconstruction, they applied BERT-style noise (masking 15% of source tokens).

Datasets

The researchers evaluated their approach on several standard benchmarks:

  • IWSLT14 German-to-English (de-en): A smaller, widely-used dataset.
  • WMT16 English-to-Romanian (en-ro): A medium-sized dataset.
  • WMT19 Chinese-to-English (zh-en): A high-resource dataset used to test scaling with back-translation.
  • Multilingual News-Commentary v16: A custom set covering German, Spanish, and French in six directions.
  • English News Crawl: Used for generating synthetic data via back-translation.

Key Insights and Ideas

  • Full Attention is Crucial: The most significant finding regarding architecture was that a triangular (causal) mask on the source side leads to a drop in performance. The model needs to see the entire source context simultaneously to build effective representations for translation.
  • Reconstruction Loss as a Regularizer: Surprisingly, the source reconstruction loss ($L_{RE}$) isn't strictly necessary for high performance, but it acts as a helpful regularizer. Even with $\lambda=0$, the model can learn to translate, though it becomes more sensitive to other hyperparameters.
  • Parameter Parity Matters: You cannot simply replace a 6-layer encoder and 6-layer decoder with a 6-layer TLM. To match baseline performance, the TLM needs a similar total number of parameters (e.g., a 12 or 15-layer encoder).
  • Unified Multimodality: The TLM architecture provides a streamlined interface for incorporating monolingual data (simply train on target-only sequences) and multilingual data without changing the network topology.

Key Results

In almost every test case, the encoder-only TLM performed on par with the standard Transformer encoder-decoder:

  • Bilingual Performance: On de-en, the TLM achieved 35.0 BLEU vs. the baseline's 34.9. On en-ro, it reached 26.2 BLEU vs. the baseline's 26.0.
  • Multilingual Performance: The TLM achieved an overall BLEU of 22.3, nearly identical to the baseline's 22.5.
  • Back-translation: On the high-resource zh-en task, both models improved significantly with synthetic data, with the TLM matching the baseline at 24.7 BLEU.

Limitations and Future Work

  • Inference Efficiency: One potential downside is decoding speed. In a standard encoder-decoder, the source is encoded once. In a TLM, because there is no separate decoder, the entire concatenated sequence (source + generated target) must pass through the full network for every new token generated.
  • Sequence Length: Concatenating source and target doubles the sequence length, which increases the computational cost of self-attention (which scales quadratically, $O(n^2)$).
  • Future Directions: The authors suggest that TLMs could simplify End-to-End Speech Translation. Current models often connect a pre-trained ASR encoder to an MT decoder, often discarding half the parameters. A TLM could potentially retain all pre-trained parameters, leading to more compact and efficient speech-to-text systems.

Summary updated

BibTeX
@misc{gao2022is,
  author = {Yingbo Gao and Christian Herold and Zijian Yang and Hermann Ney},
  title = {{Is Encoder-Decoder Redundant for Neural Machine Translation?}},
  year = {2022},
  eprint = {2210.11807},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.11807},
}
Figure