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

Diffusion Guided Language Modeling

Justin Lovelace, Varsha Kishore, Yiwei Chen, Kilian Q Weinberger

Abstract

Current language models demonstrate remarkable proficiency in text generation. However, for many applications it is desirable to control attributes, such as sentiment, or toxicity, of the generated language---ideally tailored towards each specific use case and target audience. For auto-regressive language models, existing guidance methods are prone to decoding errors that cascade during generation and degrade performance. In contrast, text diffusion models can easily be guided with, for example, a simple linear sentiment classifier---however they do suffer from significantly higher perplexity than auto-regressive alternatives. In this paper we use a guided diffusion model to produce a latent proposal that steers an auto-regressive language model to generate text with desired properties. Our model inherits the unmatched fluency of the auto-regressive approach and the plug-and-play flexibility of diffusion. We show that it outperforms previous plug-and-play guidance methods across a wide range of benchmark data sets. Further, controlling a new attribute in our framework is reduced to training a single logistic regression classifier.

Introduction

Large Language Models (LLMs) have achieved unprecedented levels of fluency, yet controlling their output remains a significant challenge. Ensuring that generated text adheres to specific constraints—such as being non-toxic or following a particular sentiment—is crucial for real-world deployment. Current solutions generally fall into two categories: fine-tuning/alignment (e.g., RLHF) and plug-and-play guidance (e.g., PPLM, GeDi). Fine-tuning is computationally expensive and often leads to an "alignment tax," where general model performance degrades. Plug-and-play methods, while flexible, typically manipulate discrete token probabilities at each decoding step, which can lead to cascading errors and ungrammatical outputs.

Diffusion Guided Language Modeling (DGLM) proposes a middle ground. It leverages the high-level planning capabilities of diffusion models to generate a "semantic proposal" in a continuous latent space, which then guides a standard auto-regressive decoder. This approach preserves the fluency of the decoder while providing the modular steerability of diffusion.

Methodology

The DGLM framework consists of three primary components that decouple semantic planning from token-level generation:

  1. Semantic Latent Space: The model operates within the embedding space of a frozen Sentence-T5 encoder. This space captures high-level meanings in 768-dimensional vectors, providing a structured environment for guidance.
  2. Diffusion Network: Conditioned on a text prefix, a transformer-based diffusion model iteratively denoises a random vector to produce a semantic proposal. This proposal represents a likely embedding for the text's continuation.
  3. Guided Decoder: A lightweight prompt generator transforms the semantic proposal into a sequence of "soft tokens." These tokens are prepended to the original prefix and fed into a standard auto-regressive decoder (e.g., GPT-2) to guide the final word-by-word generation.
Overview of the DGLM architecture showing the integration of plug-and-play guidance within the diffusion process.

To control the model, the authors employ Diffusion Posterior Sampling (DPS). Because the latent space is continuous and well-structured, simple logistic regression classifiers can be used to provide gradients that "nudge" the diffusion process toward desired attributes. This allows for "plug-and-play" control without modifying the underlying language model weights. Additionally, the use of Gaussian noise augmentation during training makes the decoder robust to the slight imperfections inherent in diffusion sampling.

Results and Evaluation

The authors evaluated DGLM across several control tasks, including toxicity mitigation, sentiment steering, and topic control, using datasets such as C4, RealToxicityPrompts, and Amazon Polarity.

Toxicity Mitigation

DGLM demonstrated a superior ability to reduce toxicity while maintaining high fluency. As shown in the evaluation metrics, DGLM reduced the toxicity rate to 0.005—a significant reduction from the 0.254 baseline—while maintaining a perplexity of 38.2. In contrast, competing methods like GeDi achieved similar toxicity reduction but at the cost of much higher perplexity (170.5), indicating a loss of natural language quality.

Performance trade-offs for toxicity mitigation. DGLM (triangles) maintains lower perplexity and higher diversity (Dist-3) compared to baselines.

Fluency and Diversity

A key finding is that DGLM often matches or exceeds the fluency of unguided baselines. By guiding in the continuous latent space rather than the discrete token space, the model avoids the "cascading errors" common in previous plug-and-play systems. Furthermore, DGLM produced more diverse text (measured by Dist-3 scores) than standard auto-regressive models, suggesting that the diffusion-based proposal encourages a wider range of valid continuations.

Conclusion

DGLM represents a significant step forward in controllable text generation by combining the strengths of diffusion and auto-regressive modeling. By shifting the guidance mechanism to a continuous semantic space, it achieves state-of-the-art performance in attribute control without sacrificing the fluency that makes LLMs so effective. The simplicity of adding new controls via linear classifiers makes DGLM a highly practical and scalable framework for diverse applications.

Summary updated

BibTeX
@inproceedings{lovelace2024diffusion,
  author = {Justin Lovelace and Varsha Kishore and Yiwei Chen and Kilian Q Weinberger},
  title = {{Diffusion Guided Language Modeling}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  url = {https://openreview.net/forum?id=pOtJ4nHO0Z},
}
Figure