Scheduled Sampling for Transformers

Tsvetomila Mihaylova, André F. T. Martins · DOI

TL;DR

This paper adapts "scheduled sampling," a technique that helps sequence-to-sequence models learn from their own mistakes, to the Transformer architecture. By introducing a two-pass decoding strategy, they enable Transformers to benefit from this training method, achieving competitive results in machine translation without significantly increasing training time.

What Problem Does This Paper Address?

Sequence-to-sequence models, widely used in tasks like machine translation, are typically trained using "teacher forcing." This means the model always receives the correct previous word as input during training, even when it's supposed to be predicting the next word. While this leads to fast convergence, it creates a mismatch with how the model operates during inference (when it only has its own predictions to go on). This mismatch, known as "exposure bias," can make models brittle and prone to errors when they encounter their own mistakes. Scheduled sampling was proposed to mitigate this by gradually introducing the model's own predictions into the training process. However, applying this to the Transformer architecture, which relies on attention over the entire preceding sequence rather than just the last word, is not straightforward.

Methods

The authors propose a novel adaptation of scheduled sampling for Transformers, which they call "two-decoder Transformer." The core idea is to modify the training process to include two passes through the decoder:

  1. First Pass (Model Prediction): The decoder, conditioned on the gold target sequence, generates predictions (scores for each word in the vocabulary).
  2. Second Pass (Scheduled Sampling): This pass uses a mixed sequence as input. For each position, it probabilistically chooses between the gold target word and the word predicted by the model in the first pass. This mixing probability follows a schedule that decreases over training, starting with high teacher forcing and gradually increasing the reliance on model predictions.

They also explore different ways to incorporate the model's predictions when they are used:

  • Argmax: Simply using the word with the highest predicted score.
  • Top-k Mix: A weighted average of the embeddings of the top-k most probable words.
  • Softmax with Temperature: A weighted average of embeddings based on softmax scores, with a temperature parameter to control the distribution's sharpness.
  • Gumbel Softmax: A differentiable approximation for sampling from a categorical distribution.
  • Sparsemax: A method that produces sparse probability distributions.

Crucially, they investigate two backpropagation strategies:

  • No Backprop: Only backpropagating through the second decoder pass (the one using the mixed sequence).
  • Backprop through Model Decisions: Backpropagating through both the first and second decoder passes, similar to differentiable scheduled sampling.

Datasets

The paper evaluates their approach on two machine translation tasks:

  • IWSLT 2017 German-English (DE-EN): Using data from Cettolo et al. (2017).
  • KFTT Japanese-English (JA-EN): Using data from Neubig (2011).

Both datasets were preprocessed using byte pair encoding (BPE) with 32,000 merges.

Key Insights and Ideas

  • Transformer's Attention Makes Scheduled Sampling Tricky: Unlike RNNs where the next word depends only on the previous one, Transformers attend to the entire history. This makes directly applying the RNN-style scheduled sampling (choosing between gold or previous prediction) non-trivial, necessitating a structural change.
  • Two-Pass Decoding is Key: The proposed two-pass decoder strategy effectively allows scheduled sampling to be integrated into the Transformer's autoregressive generation process.
  • Mixing Embeddings Matters: Simply using the argmax prediction in the scheduled sampling step performs poorly. Using mixed embeddings (e.g., top-k, softmax, Gumbel softmax, sparsemax) leads to significantly better results.
  • Backpropagation Strategy Impacts Performance: Backpropagating only through the second decoder pass (without model decisions) yields results competitive with or slightly better than a teacher-forcing baseline. However, backpropagating through both decoder passes (differentiable scheduled sampling) led to a significant performance degradation in their experiments.

Key Results

  • The proposed scheduled sampling strategy, particularly when using mixed embeddings and backpropagating only through the second decoder pass, achieved performance close to a teacher-forcing baseline.
  • In the JA-EN language pair, one of their scheduled sampling models even showed a slight improvement (up to 1 BLEU point) over the teacher-forcing baseline on the test set.
  • The "argmax" approach for incorporating model predictions performed poorly, significantly underperforming the teacher forcing baseline.
  • The "differentiable scheduled sampling" (backpropagating through both passes) resulted in much lower BLEU scores, suggesting that this approach might require more careful tuning of the decay schedule or more training steps with teacher forcing initially.

Limitations and Future Work

  • Differentiable Scheduled Sampling Performance: The authors acknowledge the poor performance of the differentiable scheduled sampling setup and suggest that it needs further examination, possibly by adjusting the decay schedule to allow more initial teacher forcing.
  • Exploring More Schedules: They propose experimenting with a wider variety of decay schedules, especially those that start decreasing more slowly to avoid rapid performance degradation.
  • More Language Pairs: The authors plan to test their approach on additional language pairs to further validate its effectiveness.
  • Understanding Degradation: Further investigation is needed to understand why the differentiable scheduled sampling setup degrades so quickly.

Summary updated

BibTeX
@inproceedings{mihaylova2019scheduled,
  author = {Tsvetomila Mihaylova and André F. T. Martins},
  title = {{Scheduled Sampling for Transformers}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2019},
  doi = {10.18653/v1/p19-2049},
}
Figure