Attribute Alignment: Controlling Text Generation from Pre-trained Language Models

Dian Yu, Zhou Yu, Kenji Sagae

Abstract

Controlling the output of large pre-trained language models (LMs) remains a significant challenge in natural language processing. Existing methods often suffer from high computational costs, loss of linguistic diversity, or the need for extensive retraining. We describe Attribute Alignment, a lightweight approach that steers frozen LMs by learning a simple alignment function to map attribute representations into the model's internal hidden space. By employing a Bayesian disentanglement strategy (ACB), we effectively separate target attributes from the stylistic biases of training data. Our evaluation demonstrates that Attribute Alignment produces fluent, diverse, and accurately controlled text, outperforming previous state-of-the-art methods in both speed and quality.

The Challenge of Controllable Generation

The "Controllability vs. Quality" trade-off is a central hurdle in deploying large LMs like GPT-2. While these models are highly fluent, directing them toward specific topics or sentiments typically requires expensive retraining (e.g., CTRL), fine-tuning that risks "catastrophic forgetting," or slow token-level perturbations (e.g., PPLM) that can degrade grammatical quality. Attribute Alignment addresses these issues by providing a "plug-and-play" mechanism that maintains the original LM's parameters while enabling precise steering.

Methodology: Mapping and Disentanglement

The core of Attribute Alignment is a Multi-Layer Perceptron (MLP) that acts as a translator between attribute tokens and the LM's internal representation. Instead of modifying the LM, the MLP generates "aligned" hidden states from attribute embeddings (e.g., "business" or "positive"). These states are then treated as a prefix by the frozen LM during generation.

The Attribute Alignment framework: An MLP maps attribute representations into aligned hidden states that serve as a prefix for the frozen pre-trained LM.

To address the "noise" inherent in training data—where sentiment is often entangled with a specific domain like movie reviews—the authors introduce Bayes Disentanglement (ACB). This mathematical approach uses Bayes' Rule during inference to subtract domain-specific stylistic influences, ensuring the model captures the intended attribute without being confined to the training set's style.

Experimental Results

Evaluation on the Stanford Sentiment Treebank (SST), AG News, and DBpedia reveals that Attribute Alignment variants, particularly ACB, offer a superior balance of performance metrics. Unlike fine-tuned models which often mimic training data too closely (high corpus resemblance), ACB maintains the fluency and diversity of the original GPT-2 while achieving high attribute accuracy.

Quantitative comparison of Attribute Alignment variants against baselines. ACB achieves high sentiment accuracy while maintaining superior fluency (PPL) and diversity (Dist-n) compared to PPLM and GeDi.

Furthermore, the method demonstrates remarkable efficiency. Because control is applied at the representation level before the generation loop begins, it avoids the per-token gradient calculations that slow down methods like PPLM. The model also shows promising zero-shot capabilities, successfully steering toward topics like "military" that were not explicitly part of the alignment training phase.

Conclusion

Attribute Alignment offers a scalable and efficient path toward controllable text generation. By treating attributes as internal keys rather than external constraints, and by explicitly disentangling style from content, this method preserves the power of pre-trained LMs while giving users the "steering wheel" necessary for specialized applications. Future work will explore extending this framework to more complex attributes and low-resource settings.

Summary updated

BibTeX
@inproceedings{yu2021attribute,
  author = {Dian Yu and Zhou Yu and Kenji Sagae},
  title = {{Attribute Alignment: Controlling Text Generation from Pre-trained Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  doi = {10.18653/v1/2021.findings-emnlp.194},
}
Figure