Abstract: In this paper we explore the effect of architectural choices on learning a Variational Autoencoder (VAE) for text generation. In contrast to the previously introduced VAE model for text where both the encoder and decoder are RNNs, we propose a novel hybrid architecture that blends fully feed-forward convolutional and deconvolutional components with a recurrent language model. Our architecture exhibits several attractive properties such as faster run time and convergence, ability to better handle long sequences and, more importantly, it helps to avoid some of the major difficulties posed by training VAE models on textual data.
The Challenge of RNN-based VAEs
Variational Autoencoders (VAEs) have revolutionized generative modeling by learning a continuous latent space—a structured "map" of data where navigating between points allows for the generation of new, realistic samples. While highly successful in the image domain, VAEs have historically struggled with text.
The primary obstacle is the RNN decoder. Recurrent Neural Networks (RNNs) are exceptionally powerful language models that predict the next token based on previous ones. During training, an RNN decoder often learns to ignore the latent vector $z$ entirely, relying solely on its own internal history. This phenomenon, known as KL collapse, occurs when the model sets the latent information to zero to simplify the optimization objective. Effectively, the VAE reverts to a standard, deterministic language model, rendering the latent space useless for controlled generation.
The Hybrid Convolutional-Recurrent Architecture
To address these issues, we propose a Hybrid Convolutional-Recurrent VAE. The core idea is to limit the "modeling power" of the decoder's history-tracking mechanism, forcing it to rely on the global context provided by the latent space.
Our architecture consists of four main components:
- Convolutional Encoder: We use 1D-convolutions to compress the input text into a latent vector $z$. Unlike RNNs, convolutions have a fixed receptive field, which naturally captures local patterns while the latent vector is forced to represent the global structure.
- Deconvolutional Decoder: A series of deconvolutional (upsampling) layers expand the latent vector back into a sequence of activations.
- Recurrent Layer: A final LSTM or ByteNet layer sits atop the deconvolutional outputs to handle the fine-grained, local dependencies of language.
- Auxiliary Reconstruction Loss: To further combat KL collapse, we introduce an auxiliary loss ($J_{aux}$). This forces the model to predict the output text directly from the deconvolutional layers before the recurrent layer processes them. Since these layers lack access to the "history" of generated words, they must rely entirely on the latent vector $z$ to achieve high reconstruction accuracy.
Experimental Results
We evaluated our model on the Penn Treebank (PTB) for character-level generation and a dataset of 1M Tweets for large-scale qualitative analysis.
Overcoming KL Collapse
In traditional LSTM-based VAEs, the KL divergence (a measure of information stored in the latent space) often drops toward zero for sequences longer than 48 characters. In our hybrid model, the KL term remains stable and significantly higher (around 12.5 compared to 1.0–3.8 for the LSTM baseline). This confirms that the model is actively utilizing the latent space.
Efficiency and Sequence Length
Because convolutions are highly parallelizable on modern GPUs, our hybrid model is approximately 2x faster to train than all-recurrent versions. Furthermore, it successfully handles sequences of 50+ characters, a regime where standard LSTM VAEs typically fail to converge or suffer from complete collapse.
Qualitative Diversity
Generative results on the tweet dataset highlight the model's ability to produce diverse and grammatically varied text. While standard LSTM VAEs often default to repetitive, generic phrases (e.g., repeating user handles), the hybrid model generates more unique and contextually rich sentences, demonstrating a more meaningful navigation of the learned latent space.
Conclusion
By strategically combining convolutional and recurrent components, we have developed a VAE architecture that is more robust to the common pitfalls of text generation. The limited receptive field of convolutions, paired with an auxiliary reconstruction loss, effectively prevents KL collapse and enables the learning of a rich, informative latent space for long textual sequences. Future work will explore applying this hybrid approach to semi-supervised tasks and conditioned generation, such as controlling sentiment or style in synthesized text.
Summary updated