Paper commentary
SeqGAN: Sequence Generative Adversarial Nets with Policy Gradient
SeqGAN trains text generators with policy gradients instead of GAN gradients
- Problem GAN gradients fail for discrete tokens, because a small change to a token choice has no matching token. The discriminator also scores only finished sequences, not partial ones.
- Method SeqGAN treats the token generator as a stochastic policy. It uses the discriminator's score on a finished sequence as the reward, estimates partial sequence values by Monte Carlo rollouts, and updates the generator by policy gradient.
- Results On a synthetic oracle task, SeqGAN reaches an NLLoracle of 8.736, against 9.038 for the MLE-trained generator, where lower is better.
Why GANs struggle with discrete tokens
Recurrent generators trained by maximum likelihood predict each token from the true prefix, but at inference they condition on their own earlier outputs, which the training data may never have contained. This exposure bias compounds along the sequence. Scheduled sampling reduces the mismatch by feeding the model its own generated tokens during training, yet a later analysis cited by the authors argues that it is an inconsistent strategy that does not fix the problem at its root.
A GAN pairs a discriminator that separates real data from generated data with a generator that tries to fool it, and this has worked well for natural images. For tokens the approach breaks down. The discriminator's gradient tells the generator how to nudge a continuous output, but a small nudge to a choice from a finite vocabulary has no matching token, so the signal carries little meaning.
A second obstacle is timing. The discriminator judges only a complete sequence, so a partial prefix has no direct score, and it is unclear how its current quality should be weighed against the quality of whatever follows it.
The generator as a stochastic policy
SeqGAN recasts generation as a sequence of decisions. The state at step t is the prefix generated so far, the action is the next token, and the generator G_θ(y_t | Y_{1:t-1}) is a stochastic policy that picks that token. Choosing a token deterministically appends it to the prefix, so the state transition itself carries no randomness. The randomness lives entirely in the policy's choice of action.
The only reward is given after the last token: the discriminator's estimated probability that the finished sequence came from real data, D_φ(Y_{1:T}). Intermediate steps receive no direct reward. Because the policy parameters are updated directly, the discrete token choice never needs to be differentiated through, which is the point where the usual GAN gradient fails for text.
Estimating action values and updating the generator
For an intermediate prefix Y_{1:t}, the action value is the average discriminator score over N completions. Each completion Y^n_{t+1:T} is sampled from a roll-out policy G_β conditioned on the prefix. The formula is \( Q(Y_{1:t-1}, y_t) = \frac{1}{N}\sum_{n=1}^{N} D_\phi(Y^n_{1:T}) \) for t < T, and \( Q = D_\phi(Y_{1:T}) \) at t = T. The roll-out policy is set equal to the generator in these experiments, with a simpler roll-out allowed when speed matters more.
Averaging over N completions reduces the variance of the estimate.
The gradient is approximated on one sampled episode as \( \nabla_\theta J(\theta) \simeq \sum_{t=1}^{T}\sum_{y_t} \nabla_\theta G_\theta(y_t|Y_{1:t-1})\, Q(Y_{1:t-1},y_t) \), which can be rewritten as an expectation of the log-probability gradient weighted by Q. The parameters are then moved by \( \theta \leftarrow \theta + \alpha_h \nabla_\theta J(\theta) \).
Adam and RMSprop can replace the plain step. The Monte Carlo estimates are recomputed for each generated sequence, so the update always uses the current discriminator.
Alternating generator and discriminator training
Training starts by fitting the generator with maximum likelihood on the real sequences, then fitting the discriminator by minimizing cross entropy with negative examples drawn from that generator. The authors found the signal from this pre-trained discriminator informative for adjusting the generator.
Each round has g-steps of generator updates by policy gradient, followed by d-steps in which the discriminator is retrained. The retraining uses the same real sequences as positives and freshly generated sequences as negatives, with equal counts of each. Reusing the same positives with different sets of negatives acts like bootstrapping and reduces the variance of the discriminator's estimates.
The discriminator objective is \[\min_\phi -\mathbb{E}_{Y\sim p_{data}}[\log D_\phi(Y)] - \mathbb{E}_{Y\sim G_\theta}[\log(1-D_\phi(Y))]\], which is the cross entropy between the labels and the predicted probability. Each d-step trains the discriminator for k epochs on this loss.
Generator and discriminator networks
The generator is a recurrent network whose hidden state is updated as h_t = g(h_{t-1}, x_t), with the LSTM cell implementing g. A softmax layer over a bias c and a weight matrix V gives the distribution over the next token. The authors note that other recurrent variants, such as the GRU and attention, could serve as the generator without changing the framework.
The discriminator is a convolutional network over the token embeddings concatenated into a matrix. Each kernel slides over a window of l tokens and produces a feature map, and max-over-time pooling keeps the strongest response per kernel. A highway layer then mixes the pooled features with a transformed copy through a transform gate, and a fully connected sigmoid output gives the probability that the input is real.
The generated sequence has a fixed length T.
Synthetic oracle comparison
A randomly initialized LSTM serves as the oracle and generates 10,000 training sequences of length 20. Each model then draws 100,000 samples, and their NLLoracle under the oracle is averaged, with lower values indicating better sequences. The baselines are random token generation, an MLE-trained LSTM, scheduled sampling and PG-BLEU, which scores finished samples with BLEU.
For scheduled sampling the curriculum rate decreases by 0.002 per epoch.
Random generation reaches an NLLoracle of 10.310 and MLE 9.038. Scheduled sampling reaches 8.985 and PG-BLEU 8.946, while SeqGAN reaches 8.736.
In the learning curves, MLE and scheduled sampling settle at a relatively high NLLoracle after about 150 epochs, while SeqGAN keeps improving the same generator structure. The authors read the gap to PG-BLEU as evidence that a discriminator signal guides the policy better than a predefined score such as BLEU.
How the training schedule affects stability
Four settings are shown: g-steps=100 with d-steps=1 and k=10; g-steps=30 with d-steps=1 and k=30; g-steps=1 with d-steps=1 and k=10; and g-steps=1 with d-steps=5 and k=3.
When the generator takes many steps per discriminator update, convergence is fast, but the generator improves faster than the discriminator can follow. The discriminator then gives misleading signals gradually. Training the discriminator for more epochs reduces this instability.
Updating the discriminator after a single generator epoch, before it is fooled, lets the run learn stably. Using five d-steps per round, so the discriminator sees several different negative sets for the same positives, improves overall performance with good stability. The authors tie this to the theorem in the original GAN work.
Poem and Obama speech generation
The poem corpus contains 16,394 Chinese quatrains of four lines of twenty characters. The Obama corpus contains 11,092 paragraphs from political speeches. BLEU-2 is used for poems because most words in classical Chinese poems have one or two characters, while BLEU-3 and BLEU-4 are used for the speeches. BLEU compares against the whole test set rather than against a specific line.
For the human judgement, 20 real poems and 20 each from SeqGAN and MLE were mixed, and 70 experts judged 60 poems. A poem counted one point when judged human-written. The mean human score is 0.4165 for MLE, 0.5356 for SeqGAN and 0.6011 for real poems, with a p-value of 0.0034 for MLE against the reference. The authors describe SeqGAN as performing comparably to real human poems in this judgement.
Piano-key music generation
The training data are the solo tracks of 695 Nottingham folk tunes in MIDI format. Pitches are mapped to 88 numbers, sampled every 0.4 s, and cut into sequences of length 32. BLEU is used for the discrete piano keys, and mean squared error for the continuous pitch patterns, where a lower error is better.
Limitations
The convergence analysis assumes the discriminator can reach its optimum for a given generator. Only then is its signal meaningful and the adversarial training stable, so the analysis does not cover a discriminator that stays weak.
The exact oracle evaluation exists only for the synthetic task. The poem, speech and music results depend on BLEU against reference texts, and the poem human judgement uses 70 experts on 60 poems. The main text reports one value per model in its tables, with no spread across runs.
The generated sequence length is fixed for the discriminator, and variable-length discrimination is mentioned only as a possibility. The authors state that SeqGAN is the first work to extend GANs to generate sequences of discrete tokens; this is their own claim of priority.
Paper info
- Authors
- Lantao Yu, Weinan Zhang, Jun Wang, Yong Yu
- Venue
- arXiv · Preprint
- First published
- 2016-9-18
- Added
- 2026-11-12
- Updated
- 2017-8-25
- Version
- v6
- arXiv
- 1609.05473
- Category
- cs.LG · cs.AI
- Original paper terms
- CC BY-SA 4.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Lantao Yu, Weinan Zhang, Jun Wang, Yong Yu (2016). SeqGAN: Sequence Generative Adversarial Nets with Policy Gradient. arXiv:1609.05473v6. https://arxiv.org/abs/1609.05473v6
BibTeX
@misc{yu2016seqgan,
title = {{SeqGAN: Sequence Generative Adversarial Nets with Policy Gradient}},
author = {Lantao Yu and Weinan Zhang and Jun Wang and Yong Yu},
year = {2016},
eprint = {1609.05473},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1609.05473v6}
}