Differentiable Scheduled Sampling for Credit Assignment

Kartik Goyal, Chris Dyer, Taylor Berg-Kirkpatrick

Abstract

We demonstrate that a continuous relaxation of the argmax operation can be used to create a differentiable approximation to greedy decoding for sequence-to-sequence (seq2seq) models. By incorporating this approximation into the scheduled sampling training procedure (Bengio et al., 2015)—a well-known technique for correcting exposure bias—we introduce a new training objective that is continuous and differentiable everywhere and that can provide informative gradients near points where previous decoding decisions change their value. In addition, by using a related approximation, we demonstrate a similar approach to sampled-based training. Finally, we show that our approach outperforms cross-entropy training and scheduled sampling procedures in two sequence prediction tasks: named entity recognition and machine translation.

Introduction: The Challenge of Exposure Bias

Sequence-to-sequence (seq2seq) models, widely used in tasks like machine translation, typically rely on Teacher Forcing during training. In this regime, the model is provided with the ground-truth previous token to predict the next one. However, at inference time, the model must rely on its own previous (and potentially erroneous) predictions. This discrepancy, known as exposure bias, often leads to cascading failures where a single early mistake causes the model to diverge significantly from a coherent output.

Scheduled Sampling was introduced to mitigate this by occasionally feeding the model's own predictions back into itself during training. However, the standard implementation uses a discrete argmax operation to select the next token. Because argmax is non-differentiable, it prevents gradients from flowing back through the model's decoding decisions. Consequently, the model cannot learn how a specific decision at one time step affects the loss at much later steps, a problem known as poor credit assignment.

Methods: Differentiable Scheduled Sampling

To address the non-differentiability of standard scheduled sampling, the authors propose Differentiable Scheduled Sampling. Instead of selecting a single discrete word and feeding its embedding into the next step, the model computes a weighted average of all word embeddings based on the current output distribution.

Architecture of the differentiable scheduled sampling approach, showing the soft relaxation of the argmax operation.

Key components of this method include:

  1. Soft Argmax: A "peaked softmax" is used, controlled by a temperature parameter $\alpha$. As $\alpha$ increases, the resulting distribution becomes sharper, eventually approximating a one-hot vector corresponding to the hard argmax.
  2. Soft Reparametrized Sampling: For models that utilize sampling, the authors employ the Gumbel-Softmax trick. This allows for differentiable sampling, maintaining a gradient path back to the model parameters.
  3. Annealing: The training process begins with a "smooth" approximation (low $\alpha$) and gradually increases $\alpha$ to make the approximation sharper. This helps the model navigate the optimization landscape more effectively in early stages.

Key Insights: Solving Credit Assignment

By making the decoding process continuous, the model can finally perform effective credit assignment. If a prediction at step $i$ leads to a high loss at step $i+n$, the gradient can signal exactly how the scores at step $i$ should have been adjusted to avoid that future error. This "Backpropagation through Decisions" allows the model to learn to avoid mistakes rather than just reacting to them.

Furthermore, the use of a smooth approximation early in training provides a more informative gradient signal. While the true objective function might be jagged and discontinuous due to discrete decisions, the soft relaxation creates a smoother surface that guides the optimization toward better global minima.

Experimental Results

The proposed method was evaluated on two distinct tasks: Named Entity Recognition (NER) using the CoNLL 2003 German dataset, and Machine Translation (MT) using the IWSLT 2014 German-to-English dataset.

Performance comparison showing that the proposed soft-annealed approach outperforms both baseline cross-entropy and standard scheduled sampling.

As shown in the results table, the "soft annealed" approach consistently outperformed both the standard Cross-Entropy (CE) baseline and the original non-differentiable Scheduled Sampling (Bengio et al., 2015):

  • NER: The soft annealed greedy approach achieved a 56.33 F1 score, compared to 53.32 for the CE baseline.
  • Machine Translation: The relaxed sample-based decoder reached 20.60 BLEU, a notable improvement over the 19.11 baseline.

Importantly, the authors noted that despite the added complexity of calculating weighted averages across embeddings, the training speed on modern GPUs remained nearly identical to standard methods.

Conclusion and Future Work

Differentiable Scheduled Sampling provides a mathematically sound way to bridge the gap between training and inference in seq2seq models. While the method is sensitive to hyperparameter tuning—specifically the annealing schedules for $\alpha$ and the mixing probability—it offers a significant performance boost by enabling proper credit assignment. Future work may explore scaling this approach to even larger vocabularies and more complex search spaces where "always sampling" variants currently face stability challenges.

Summary updated

BibTeX
@inproceedings{goyal2017differentiable,
  author = {Kartik Goyal and Chris Dyer and Taylor Berg-Kirkpatrick},
  title = {{Differentiable Scheduled Sampling for Credit Assignment}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2017},
  url = {https://openreview.net/forum?id=H1WWm3xu-r},
}
Figure