Controlled Text Generation Using Dictionary Prior in Variational Autoencoders

Xianghong Fang, Jian Li, Lifeng Shang, Xin Jiang, Qun Liu, Dit-Yan Yeung

Abstract

This paper introduces Dictionary Prior (DPrior), a novel data-driven approach to Variational Autoencoders (VAEs) that replaces standard Gaussian priors with a set of learnable "dictionary atoms." By interpolating these atoms via a Dirichlet distribution and employing contrastive learning, the authors achieve state-of-the-art text generation performance and precise control over sentence attributes like sentiment, tense, and topic.

Introduction

Variational Autoencoders (VAEs) are powerful tools for text generation, but they suffer from two persistent "bottlenecks": insufficient representation capacity and poor controllability. Most VAEs assume a simple Gaussian distribution for their latent space, which is often too restrictive for the complexity of natural language. This leads to posterior collapse, a failure mode where the model ignores the latent variables entirely and reverts to a standard language model. Furthermore, mapping discrete attributes (like sentiment or tense) to continuous latent spaces without losing text quality or "disentangling" content from style is notoriously difficult. The authors propose DPrior to create a prior that is expressive enough to avoid collapse and structured enough for fine-grained control.

Methodology

The core innovation is the Dictionary Prior (DPrior). Instead of sampling from a standard normal distribution, the model maintains a dictionary of learnable vectors called atoms.

The DPrior architecture, featuring dictionary atoms, Dirichlet interpolation, and contrastive learning components.

To form a latent variable $z$, the model samples weights from a Dirichlet distribution and creates a weighted sum (interpolation) of the dictionary atoms. This allows the latent space to be continuous for fluency while being anchored to specific points for structure. Because the density of this dictionary-based prior is hard to calculate directly, the authors use a "dual-form" KL divergence based on Fenchel duality, involving an auxiliary neural network. To enable controlled generation, the dictionary is split into disjoint subsets, and a contrastive loss (InfoNCE) forces the encoder to map sentences to the correct "neighborhood" of atoms in the dictionary.

Experimental Setup

The researchers evaluated DPrior on two fronts:

  • Language Modeling (Quality/Capacity): Tested on Penn Treebank (PTB), SNLI, Yahoo Answers, and Yelp corpora.
  • Controlled Text Generation: Evaluated using Yelp-s/t/st (sentiment and tense) and Arxiv (topic categories: AI, CV, and NLP).

Results and Discussion

DPrior achieved state-of-the-art performance, recording the lowest Perplexity (PPL) and highest Mutual Information (MI) across all language modeling benchmarks compared to variants like MoG-VAE or Vamp-VAE. In controlled tasks, it achieved a 99.2% accuracy in sentiment generation and 98.7% accuracy in matching target research topics.

Comparison of latent space clustering and training metrics between standard DPrior and DPrior with contrastive learning (DPrior+c).

Visualization of the latent space using PCA demonstrates that contrastive learning is essential for attribute separation. As shown in the figures above, without contrastive learning, attributes are mixed; with it, the latent space partitions into distinct "islands." This "convex hull" advantage provides a structured optimization space that prevents the model from getting lost during training, effectively mitigating posterior collapse. Qualitative analysis further revealed that atoms physically close in the dictionary generated semantically related sentences, proving the model learns a meaningful hierarchy.

Conclusion

DPrior successfully bridges the gap between discrete control and continuous generation. While the authors acknowledge a "finite support region"—where the model can only generate what lies within the boundaries of its dictionary atoms—the results show significant improvements in both fluency and controllability. Future work will look into extending DPrior to infinite support regions and applying it to more complex creative tasks like poetry generation and machine translation.

Summary updated

BibTeX
@inproceedings{fang2022controlled,
  author = {Xianghong Fang and Jian Li and Lifeng Shang and Xin Jiang and Qun Liu and Dit-Yan Yeung},
  title = {{Controlled Text Generation Using Dictionary Prior in Variational Autoencoders}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.findings-acl.10},
}
Figure