MaskGAN: Better Text Generation via Filling in the _______

William Fedus, Ian Goodfellow, Andrew M. Dai

Abstract

Neural text generation models typically rely on autoregressive language models or seq2seq architectures. While these models achieve state-of-the-art results on machine translation and summarization benchmarks, they often suffer from exposure bias due to teacher forcing during training. Furthermore, they are usually optimized for perplexity, which does not always correlate with high-quality, human-like text generation. To address these issues, researchers introduce MaskGAN, an actor-critic conditional Generative Adversarial Network (GAN) that frames text generation as an in-filling task. By explicitly training the generator to produce high-quality samples conditioned on surrounding context, MaskGAN produces significantly more realistic text than standard maximum-likelihood approaches.

The Problem: Exposure Bias and Perplexity

Most traditional text generation models are autoregressive, meaning they predict the next word based sequentially on previous words. During training, these models utilize a technique called Teacher Forcing, where the model is fed the correct "ground truth" word to help it predict the subsequent one.

However, at inference time, there is no "teacher" to provide the ground truth. If the model makes a minor error early in the sequence, that error compounds, pushing the model into an unfamiliar state space it never encountered during training. This phenomenon is known as exposure bias. Additionally, these models are typically optimized for perplexity (how well they predict a specific dataset's distribution). Unfortunately, lower perplexity does not strictly guarantee that the generated text will sound natural or high-quality to human readers.

Methods: Text Generation as In-filling

To overcome these limitations, the authors introduce MaskGAN, which reimagines text generation as a "fill-in-the-blank" (in-filling) task.

  1. The Task: Instead of strictly predicting the next word sequentially, the model is provided a sequence with certain words "masked" out. Its objective is to fill in these missing blanks coherently.
  2. The Architecture: MaskGAN employs a Seq2Seq (encoder-decoder) generator. The encoder processes the surrounding context (the unmasked words), and the decoder generates the missing tokens.
The MaskGAN Generator architecture illustrating the encoder-decoder setup for in-filling missing text.
  1. The GAN Framework:
  2. Generator (The Actor): Attempts to fill in the blanks so realistically that a discriminator network cannot distinguish the generated text from the original text.
  3. Discriminator (The Critic): Evaluates each token in the sequence, classifying whether it is "real" (from the ground truth) or "fake" (imputed by the generator).
  4. Reinforcement Learning (RL): Because text generation involves discrete word choices (which are non-differentiable), the authors utilize Policy Gradients (REINFORCE). They incorporate a Critic network to estimate the "value" of a state. This actor-critic setup significantly reduces the high variance typically associated with RL training, enabling faster and more reliable convergence.

Key Insights

  • In-filling as a Dense Reward Signal: Traditional text GANs often provide a single, sparse reward at the very end of a generated sentence. MaskGAN’s in-filling approach allows the discriminator to provide a fine-grained reward signal for every single token, giving the generator precise feedback on where it succeeded or failed.
  • Context is King: By supplying the discriminator with the "true context" (the unmasked words), the model avoids a common failure mode where the discriminator penalizes valid but unexpected word pairings.
  • Perplexity vs. Quality: The study reinforces the concept that a model can exhibit "worse" (higher) perplexity on a test set while actually producing more diverse, human-preferred samples. MaskGAN intentionally explores "off-manifold" phrasing to find realistic alternatives that standard Maximum Likelihood Estimation (MLE) models would heavily penalize.

Experimental Results

The researchers evaluated MaskGAN on two classic NLP datasets: the Penn Treebank (PTB) (Wall Street Journal articles) and IMDB Movie Reviews (testing diverse, emotive language).

  • Human Preference: In blind head-to-head evaluations on Amazon Mechanical Turk, human raters overwhelmingly preferred MaskGAN's output over standard MLE models. On the IMDB dataset, MaskGAN was rated as having better "Overall Quality" 58% of the time, compared to just 15.7% for the MLE baseline.
  • Beating Prior GANs: MaskGAN outperformed previous state-of-the-art text GANs, such as SeqGAN, in both grammaticality and topicality.
  • Quantitative Realism: When evaluated by a pre-trained language model acting as an independent scorer, MaskGAN samples achieved a perplexity of 108.3, whereas MLE-based samples scored a significantly worse 273.1. This indicates that MaskGAN's output aligns much closer to natural English distributions.
Qualitative comparison of text generated by MaskGAN versus MaskMLE on the IMDB dataset.

Limitations and Future Work

While MaskGAN represents a significant step forward, it shares some common generative modeling challenges:

  • Mode Collapse: Like many GANs, MaskGAN experiences a slight loss of diversity. It occasionally relies on "safe" n-grams known to fool the discriminator, leading to fewer unique phrases than MLE models.
  • Boundary Issues: The model sometimes struggles with syntax at the boundaries—the transition between a pre-existing context word and a newly filled-in word can occasionally be ungrammatical.
  • Global Coherence: While local phrases are highly realistic, the model can still lose the overarching narrative over very long sequences.

The authors note that future iterations could benefit from replacing the LSTM backbone with attention-only architectures (like Transformers) to further enhance the quality and coherence of the in-filling process.

Summary updated

BibTeX
@inproceedings{fedus2018maskgan,
  author = {William Fedus and Ian Goodfellow and Andrew M. Dai},
  title = {{MaskGAN: Better Text Generation via Filling in the \_\_\_\_\_\_\_}},
  booktitle = {International Conference on Learning Representations},
  year = {2018},
  url = {https://openreview.net/forum?id=ByOExmWAb},
}
Figure