MacLaSa: Multi-Aspect Controllable Text Generation via Efficient Sampling from Compact Latent Space

Hanxing Ding, Liang Pang, Zihao Wei, Huawei Shen, Xueqi Cheng, Tat-Seng Chua

Introduction

Controllable Text Generation (CTG) is a pivotal task in natural language processing, aimed at producing text that adheres to specific constraints, such as sentiment, topic, or style. While single-attribute control has seen significant progress, multi-aspect control—where a model must simultaneously satisfy multiple constraints (e.g., a "positive" review about "technology")—remains a formidable challenge. Existing methods often struggle with a trade-off between generation speed and text quality. MacLaSa introduces a novel framework that addresses these bottlenecks by mapping multiple attributes into a unified, compact latent space and utilizing efficient sampling techniques.

The Challenges of Multi-Aspect Control

The authors identify two primary limitations in current CTG methodologies:

  1. Optimization-based Methods: Approaches like PPLM perform iterative searches in high-dimensional, discrete text spaces during the decoding process. While effective at steering the model, they are prohibitively slow for real-time applications.
  2. Prefix-based Methods: These methods use continuous vectors to steer Large Language Models (LLMs). However, they often suffer from "mutual interference." When multiple prefixes (e.g., "positive" and "sports") are combined, the resulting text quality often degrades because the distribution centers for these distinct aspects are located far apart in the model's representation space, leading to incoherent outputs.

MacLaSa seeks to bridge this gap by creating a space where multiple attributes can coexist without interference.

The MacLaSa Framework

The MacLaSa framework is structured into three distinct stages designed to optimize both control precision and inference efficiency.

1. Building a Compact Latent Space

The foundation of MacLaSa is a Variational Autoencoder (VAE) that maps text into a continuous latent space. To ensure this space is conducive to multi-aspect control, the authors introduce two specialized loss functions:

  • Classification Loss ($L_C$): This ensures that the latent representations retain sufficient information for a classifier to distinguish between different attributes.
  • Aspect Discrepancy Loss ($L_D$): This is the core innovation of the framework. It penalizes the distance between the centers of different attribute distributions. By forcing regions like "Sentiment" and "Topic" to overlap or reside in close proximity, the model minimizes the domain gap that typically causes text quality to deteriorate during multi-aspect steering.

2. Compositional Control via Joint Energy-Based Models (EBMs)

Once the compact space is established, target attributes are defined as an energy landscape where low energy corresponds to high attribute relevance. Because EBMs are inherently compositional, the framework can achieve joint control by simply summing the energy functions of different attributes (e.g., $Energy_{Total} = Energy_{Positive} + Energy_{Sports}$).

3. Efficient Sampling with ODEs

To overcome the slowness of traditional Markov Chain Monte Carlo (MCMC) sampling, MacLaSa adapts an Ordinary Differential Equation (ODE) sampler, a technique inspired by recent advances in diffusion models. This allows the model to efficiently "drift" from a random noise vector toward the target latent representation. The resulting sampled vector is then passed to the VAE decoder to generate the final text.

Experimental Evaluation

The model was evaluated on two benchmark datasets: IMDb Movie Reviews (for sentiment control) and AGNews (for topic control). The authors trained the framework on 20,000 randomly sampled sentences from each dataset and utilized 15 attribute-unrelated prompts to trigger generation during testing.

Key Results

MacLaSa demonstrated superior performance compared to strong baselines such as PPLM, Contrastive Prefixes, and LatentOps:

  • Attribute Alignment: MacLaSa achieved an average accuracy of 59.18% across eight attribute combinations, representing an 11.62% improvement over the strongest baseline.
  • Inference Speed: The framework achieved a 5.9x speedup compared to prefix-based contrastive methods (0.10s vs. 0.59s per sentence) and was orders of magnitude faster than optimization-based methods like Mix&Match.
  • Text Quality: In human evaluations, MacLaSa received higher scores for fluency (3.25/5) and diversity (2.96/5) than all other tested baselines.

Discussion and Limitations

MacLaSa demonstrates that the "interference problem" in multi-aspect control is largely spatial. By explicitly encouraging attribute clusters to live near each other through the Aspect Discrepancy Loss, the model prevents the generation of "gibberish" often associated with mixed control signals. Furthermore, by framing sampling as an ODE problem, MacLaSa brings the efficiency of modern generative modeling to the CTG domain.

However, some limitations remain:

  • Retraining Requirements: Adding a new aspect (e.g., "politeness") requires retraining the VAE framework to incorporate the new attribute into the compact latent space.
  • KL Vanishing: Like many VAE-based architectures, MacLaSa must manage the "KL vanishing" problem, where the decoder ignores the latent vector. While the authors used scheduling techniques to mitigate this, it remains a challenge for training stability.
  • Scaling: While the current implementation uses GPT-2 Medium, future research could explore scaling this latent-space approach to larger LLMs or more complex, fine-grained constraints.

Summary updated

BibTeX
@inproceedings{ding2023maclasa,
  author = {Hanxing Ding and Liang Pang and Zihao Wei and Huawei Shen and Xueqi Cheng and Tat-Seng Chua},
  title = {{MacLaSa: Multi-Aspect Controllable Text Generation via Efficient Sampling from Compact Latent Space}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.292},
}
Figure