μ-Forcing: Training Variational Recurrent Autoencoders for Text Generation

Dayiheng Liu, Yang Xue, Feng He, Yuanyuan Chen, Jiancheng Lv

Introduction

Variational Autoencoders (VAEs) are powerful generative models, but they face a significant challenge when applied to text: the "KL vanishing" problem. In a standard VAE, the model balances reconstruction loss with a KL divergence term that encourages the latent space to follow a standard normal distribution. However, when paired with a powerful decoder like a Recurrent Neural Network (RNN), the model often ignores the latent code entirely, relying instead on its own autoregressive properties. This results in the KL divergence dropping to zero, effectively collapsing the VAE into a simple language model that produces repetitive and uninspired text.

Model Architecture

The proposed framework utilizes a Variational Recurrent Autoencoder (VRAE) structure. As shown in Figure 1, the encoder is a bidirectional LSTM (bi-RNN) that processes the input sequence $x_1, \dots, x_T$ to produce the parameters $\mu$ and $\sigma$ of the latent distribution. A latent vector $z$ is sampled from this distribution and passed to an LSTM decoder, which generates the output sequence. This architecture allows the model to capture complex dependencies in text while attempting to map them to a continuous latent space.

Architecture of the Variational Recurrent Autoencoder (VRAE) with a bidirectional LSTM encoder and an LSTM decoder.

The μ-Forcing Method

To combat KL vanishing, the authors introduce μ-Forcing, a regularization technique that ensures the latent variables remain informative. The core idea is to prevent the means ($\mu$) of the latent distributions from collapsing to zero across a batch. When KL vanishing occurs, the encoder typically maps all inputs to the same standard normal distribution, making the latent code useless for the decoder.

μ-Forcing adds a margin-based cost function, $L_\mu$, to the training objective: $$L_\mu = \max(0, \beta - \text{variance}(\mu_{\text{batch}}))$$ where $\beta$ is a hyperparameter representing the minimum required diversity (spread) among the means. By penalizing low variance in the latent means, the encoder is forced to map different inputs to distinct regions of the latent space, ensuring the decoder remains dependent on the latent signal for accurate reconstruction.

Experimental Evaluation

The researchers evaluated μ-Forcing on two datasets: the Amazon Product Reviews Corpus (APRC) and the Chinese Online-Shopping Reviews Corpus (COSR). These corpora provide a rich variety of text for testing the model's ability to capture sentiment and product features in the latent space.

Quantitative and Qualitative Results

As illustrated in Figure 2, μ-Forcing effectively prevents the collapse of the latent space. In the baseline models, the KL loss quickly drops toward zero, and the distribution of $\mu$ values narrows significantly. In contrast, μ-Forcing maintains a healthy KL divergence and a diverse distribution of latent means throughout the training process.

Comparison of KL loss, reconstruction loss, and μ-value distributions between the baseline and μ-Forcing on COSR and APRC datasets.

Key findings from the study include:

  • Improved Reconstruction: On the APRC dataset, μ-Forcing achieved a reconstruction loss of 83.29, compared to 96.48 for the vanilla VRAE, indicating that the latent code provides useful information for decoding.
  • Enhanced Diversity: Using Self-BLEU as a metric, μ-Forcing demonstrated significantly higher output variety. While vanilla VRAEs often collapsed to a single repetitive sentence (Self-BLEU of 100), μ-Forcing maintained diverse generation.
  • Human Preference: In blind A/B tests, human evaluators preferred μ-Forcing outputs over strong baselines like "VRAE + BoW + KLA" 59% of the time, citing better relevance and creativity.
  • Interpretability: The authors demonstrated that the latent space was "smooth" by interpolating between latent vectors, resulting in sentences that logically transitioned in meaning.

Conclusion

μ-Forcing provides a robust and interpretable solution to the KL vanishing problem in text generation. By directly regularizing the diversity of latent means, it ensures that VRAEs maintain a meaningful latent space without the need for complex annealing schedules. This leads to generative models that are not only more accurate in reconstruction but also significantly more diverse and creative in their output.

Summary updated

BibTeX
@article{liu2020forcing,
  author = {Dayiheng Liu and Yang Xue and Feng He and Yuanyuan Chen and Jiancheng Lv},
  title = {{μ-Forcing: Training Variational Recurrent Autoencoders for Text Generation}},
  journal = {ACM Trans. Asian Low Resour. Lang. Inf. Process.},
  year = {2020},
  doi = {10.1145/3341110},
}
Figure