Fine-grained Sentiment Controlled Text Generation

Bidisha Samanta, Mohit Agarwal, Niloy GangulyarXiv 2020

Abstract

Controlled text generation aims to produce sentences with specific attributes while maintaining original content. Existing methods often suffer from content loss due to forced disentanglement or provide only coarse binary control. We present DE-VAE (Disentangled-Entangle-VAE), a hierarchical framework that utilizes invertible normalizing flows to bridge a rich, entangled latent space with a clean, disentangled space. This architecture enables fine-grained sentiment manipulation while preserving the semantic integrity of the text. Evaluated on Yelp, Amazon, and IMDB datasets, DE-VAE demonstrates superior sentiment control accuracy and content retention compared to state-of-the-art baselines.

Introduction

The challenge of controlled text generation lies in the deep intertwining of sentiment and content in natural language. Most current approaches attempt to separate these into distinct latent spaces. However, this often results in two primary issues: Content Loss, where the model loses the complex dependencies required for realistic text, and Coarse Control, where sentiment is treated as a binary toggle rather than a continuous spectrum.

DE-VAE addresses these hurdles by introducing a hierarchical latent structure. It maintains a "messy" but information-rich entangled space for high-quality generation and a "clean" disentangled space for precise attribute manipulation.

Methodology: The DE-VAE Framework

The core of DE-VAE is a hierarchical VAE architecture that connects two distinct latent hierarchies via a lossless transformation.

DE-VAE Architecture

The process involves several key components:

  1. The Entangled Space ($z_s$): A lower-level space that captures dense representations of the input text using a BERT encoder. This space is optimized for sentence reconstruction, ensuring that the complex relationship between style and content is preserved.
  2. The Disentangled Space ($z_f$): A higher-level space where control occurs. A single dimension ($z_a$) is dedicated to sentiment, while others ($z_u$) handle unspecified features.
  3. Invertible Normalizing Flows: To bridge these spaces without information loss, the model employs R-NVP (Real-valued Non-Volume Preserving) flows. This invertible transformation allows the model to manipulate sentiment in the disentangled space and map it back to the rich entangled space for final generation.
  4. Supervised Control: A sentiment regressor provides supervision for the $z_a$ dimension, ensuring that sliding values along this axis corresponds to predictable changes in perceived sentiment.

Experimental Results

The model was evaluated on the Yelp, Amazon, and IMDB review datasets. Key metrics included sentiment control accuracy and content preservation, the latter measured by Jaccard overlap between the original and generated sentences.

Performance Comparison on Yelp and Amazon

Sentiment Control and Content Preservation

As shown in the experimental results, DE-VAE consistently outperforms baselines. It achieved a sentiment control accuracy of 0.95 on Yelp and 0.90 on IMDB. Crucially, DE-VAE maintains significantly higher Jaccard overlap scores, indicating that it preserves the original content much more effectively than competitors like ctrlGen when flipping sentiment. Furthermore, DE-VAE is significantly faster at both training and generation than entangleGen.

Smooth Interpolation

Qualitative analysis confirms that DE-VAE allows for smooth transitions. By incrementing the value of the sentiment dimension ($z_a$), the model can transform a sentence like "i am totally disappointed" into "i am highly recommend" while keeping the subject matter (e.g., the staff or the food) intact. This fine-grained control is a significant advancement over binary sentiment toggles.

Conclusion

DE-VAE demonstrates that hierarchical latent spaces connected by invertible normalizing flows provide a robust solution for fine-grained attribute control in text generation. By avoiding the information loss associated with standard disentanglement, the model achieves high accuracy and superior content preservation. Future work may explore scaling this framework to control multiple independent attributes simultaneously, such as tense and formality alongside sentiment.

Summary updated

BibTeX
@misc{samanta2020fine,
  author = {Bidisha Samanta and Mohit Agarwal and Niloy Ganguly},
  title = {{Fine-grained Sentiment Controlled Text Generation}},
  year = {2020},
  eprint = {2006.09891},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2006.09891},
}
Figure