NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Controllable Text Generation via Probability Density Estimation in the Latent Space

Yuxuan Gu, Xiaocheng Feng, Sicheng Ma, Lingyuan Zhang, Heng Gong, Weihong Zhong, Bing Qin

Introduction

Controllable text generation (CTG) is a pivotal task in natural language processing, aiming to guide large language models (LLMs) to produce text that adheres to specific constraints—such as sentiment, topic, or toxicity levels—without the need for extensive retraining. A prominent approach involves steering the model within its latent space, the internal mathematical representation of text. However, these latent spaces are notoriously difficult to navigate due to their high-dimensionality, asymmetry, and non-convexity. Traditional methods often struggle with "dead zones" during interpolation, where the model produces incoherent text or fails to maintain the desired attributes.

Conceptual comparison of controllable generation methods, highlighting the transition from messy latent manifolds to structured prior spaces.

As illustrated in Figure 1, existing techniques like discrete sampling or latent optimization often fail to find the precise intersection where multiple attributes overlap. To address these challenges, we introduce PriorControl, a framework that establishes a "bijective bridge" between the complex latent space of an LLM and a clean, well-behaved prior space.

The PriorControl Framework

The core innovation of PriorControl lies in the use of Normalizing Flows—a sequence of invertible functions—to map the irregular latent distributions ($x$) to simple, isotropic Gaussian distributions ($z$) in a prior space. This transformation is a bijection, meaning any point in the clean prior space can be mapped back exactly to the latent space without loss of information.

The PriorControl architecture, illustrating the flow from encoder to latent space, the invertible transformation to prior space for control, and final generation via a fixed language model.

The PriorControl pipeline, shown in Figure 6, consists of four main stages:

  1. Latent Space Estimation: A learnable encoder maps sentences into a latent space. This space is connected to a fixed GPT-2 model via prefix-tuning, where the latent vector acts as a "prefix" that guides the model's generation process.
  2. Invertible Transformation: Normalizing Flows transform the messy latent space into a Gaussian prior space. This "unfolds" the complex geometry of the latent space into a more manageable form.
  3. Control in the Prior Space: Navigation becomes significantly easier in the isotropic prior space. For single-attribute control, the system samples from the corresponding Gaussian distribution. For multi-attribute control, it utilizes linear interpolation between distribution centers or constrained optimization using Ordinary Differential Equations (ODEs) to find the "sweet spot" where multiple attributes intersect.
  4. Generation: The controlled vector is mapped back to the latent space and serves as a prefix for the LLM to generate the final text.

Experimental Evaluation

PriorControl was evaluated on three standard benchmarks for controllable generation:

  • IMDb movie reviews: Used for Sentiment control (Positive vs. Negative).
  • AGNews: Used for Topic control (World, Sports, Business, Science/Tech).
  • Jigsaw Toxic Comment Classification: Used for Detoxification (generating non-toxic text).

The framework was compared against several state-of-the-art baselines, including GeDi and LatentOps. The study used a subset of 10,000 samples from each dataset to construct the latent space, ensuring a fair comparison with previous methods.

Key Results and Insights

PriorControl achieved a new state-of-the-art (SOTA) across several key metrics:

  • Attribute Relevance: The model reached an average relevance of 97.1% for sentiment and 95.9% for topic control, significantly outperforming baselines.
  • Multi-Attribute Stability: In complex scenarios requiring multiple simultaneous attributes (e.g., "Positive + Sports + Non-Toxic"), PriorControl demonstrated superior reliability and lower performance variance compared to previous optimization-based approaches.
  • Text Quality: By avoiding over-optimization in the latent space, the model maintained high fluency (measured by Perplexity) and diversity (Distinctness), avoiding the repetitive text often seen in other latent steering methods.
  • Comparison with ChatGPT: Interestingly, while ChatGPT is generally more fluent, PriorControl showed stronger attribute relevance in specific categories like "World" topics, where ChatGPT tended to produce more generic responses.

The authors also provide mathematical proofs for three critical properties: Attribute Preservation, Intersection Invertibility, and Inequality Maintenance. These guarantees ensure that the geometric operations performed in the prior space translate accurately and predictably to the latent space.

Conclusion

PriorControl demonstrates that the inherent complexity of LLM latent spaces can be effectively managed by mathematically mapping them into a structured Gaussian prior. This approach not only improves the precision of attribute control but also enhances the stability and quality of the generated text. While the model currently requires balanced data and a few thousand labeled samples per attribute, it represents a significant step forward in making LLMs more steerable and reliable for specific downstream tasks.

Summary updated

BibTeX
@inproceedings{gu2023controllable,
  author = {Yuxuan Gu and Xiaocheng Feng and Sicheng Ma and Lingyuan Zhang and Heng Gong and Weihong Zhong and Bing Qin},
  title = {{Controllable Text Generation via Probability Density Estimation in the Latent Space}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.704},
}
Figure