Controlled text generation allows for enforcing user-defined constraints on large language model outputs—critical as LLMs become increasingly prevalent. While energy-based decoding methods combine multiple constraints through weighted averages, they often struggle to balance fluency with constraint satisfaction.
We identify that this suboptimal balance stems from sampling in continuous space rather than the natural discrete space of text tokens. Our solution, Discrete Auto-regressive Biasing (DAB), leverages gradients while operating entirely in the discrete text domain.
DAB introduces a novel formulation by defining a joint distribution over the generated sequence and an auxiliary bias sequence. To efficiently sample from this distribution, we propose a Langevin-within-Gibbs sampling algorithm using gradient-based discrete MCMC.
Our method significantly improves constraint satisfaction while maintaining superior fluency—all with reduced computational costs. Experiments demonstrate DAB's advantages on sentiment control, language detoxification, and keyword-guided generation tasks.
High-level diagram for the proposed DAB algorithm. Given prompts and an external constraint, DAB iteratively improves constraint satisfaction while preserving fluency by leveraging discrete sampling to work in the natural discrete domain of text.
Current energy-based controlled decoding methods face a fundamental challenge: they operate in continuous token probability space, while natural language is inherently discrete.
This mismatch leads to suboptimal balance between constraint satisfaction and fluency, requiring extensive hyperparameter tuning of energy function coefficients with limited success.
We propose a novel formulation for controlled text generation that operates natively in discrete token space, avoiding the continuous approximations that limit previous approaches.
This approach models the ideal balance between two objectives:
By formulating the problem in discrete space, DAB better captures the true distribution of well-formed text while satisfying constraints.
To efficiently sample from our joint distribution, we implement a Langevin-within-Gibbs sampling algorithm using gradient-based discrete MCMC. Our algorithm uses gradient-based discrete sampling to obtain a bias sequence that satisfies the external constraint, but may not be fluent. Given this satisfactory sequence, we then produce a fluent sequence through auto-regressively generating a response. This alternating cycle of sampling the bias sequence and sampling the response sequence can be seen as Gibbs sampling, where we sample the bias sequence conditioned on the response, and then the response sequence conditioned on the bias.
More technical diagram of DAB algorithm for a single iteration. Given the previous Bias sequence and response sequence from the LLM, we first compute a distribution to increase constraint satisfaction, leveraging gradient information from the constraint function. We then map these tokens to a penalty vector, using the embedding table to compute a distance penalty. We then incorporate these bias vectors into auto-regressive generation, effectively steering the LM towards satisfactory generations while preserving the fluency of the original LM distribution.
We compared DAB with several strong baselines.
In the Sentiment Control experiment, we evaluated each method's ability to steer language model generations toward positive or negative sentiment. Models were prompted with neutral text and instructed to continue with either positive or negative sentiment. Performance was measured using both our internal sentiment classifier and an external benchmark classifier to ensure robust evaluation. We also measured fluency metrics to ensure controlled generation maintained language quality.
As shown in the chart, DAB maintains a better balance between control and fluency when compared to other methods. DAB simultaneously has the best control performance in regards to both the internal and external classification score while maintaining competitive fluency metrics, being beaten by only BOLT in regards to CoLA acceptability.
Method | Prompt | Positive Sentiment Control |
---|---|---|
DAB (Ours) | The horse | The horse is also a very good and reliable companion. It has been used to carry the family's two- |
MuCoLA | The horse | The horse is not only a beautiful and well-crafted piece of art, but it is also a great way |
COLD | The horse | The horse head was still in the water, but the horse still had a good head. The horse |
BOLT | The horse | The horseback riding course is a great way to get acquainted with the trails and the terrain. The course is |
LM-Steer | The horse | The horseman delivers a stunningly beautiful, wonderfully lyrical, beautifully tender, powerfully moving, beautifully lyrical |
We introduced Discrete Auto-regressive Biasing (DAB), a novel approach to controlled text generation that operates directly in discrete token space. Our method defines a joint distribution over the generated sequence and an auxiliary bias sequence, effectively addressing the limitations of continuous space methods.
Through extensive experiments on sentiment control, toxicity reduction, and keyword-guided generation, we demonstrated that DAB consistently outperforms existing methods. Our approach achieves superior constraint satisfaction while maintaining or improving text fluency, all with reduced computational requirements compared to baseline methods.
Future research directions include extending DAB to handle multiple simultaneous constraints, developing more efficient sampling strategies for the bias sequence, and exploring applications in personalized content generation and domain-specific text adaptation.
@article{pynadath2025controlled,
title={Controlled LLM Decoding via Discrete Auto-regressive Biasing},
author={Pynadath, Patrick and Zhang, Ruqi},
journal={ICLR},
year={2025}
}