TL;DR
Researchers at Purdue University have developed Discrete Auto-regressive Biasing (DAB), a new decoding algorithm that enforces constraints on LLM outputs (like sentiment or toxicity) by sampling directly in the discrete space of text tokens. By ditching the standard practice of "continuous relaxation," DAB achieves a superior balance between fluency and constraint satisfaction while running 2x faster than state-of-the-art energy-based decoding methods.
What Problem Does This Paper Address?
Large Language Models (LLMs) are powerful, but getting them to follow specific rules—like "don't be toxic" or "use these specific keywords"—without expensive fine-tuning is difficult.
Current "plug-and-play" methods often use Energy-Based Models (EBMs). These define an "energy function" where lower energy equals better constraint satisfaction. To find the best text, these methods usually perform gradient-based sampling in continuous spaces (like word embeddings or logit distributions) and then project the results back into discrete words.
The authors identify a major flaw here: language is fundamentally discrete. Continuous-space sampling leads to tiny, incremental updates that struggle to navigate the "jagged" landscape of human language. This often results in a "fluency-control trade-off" where the model either ignores the constraint or produces gibberish. Furthermore, these methods are computationally expensive because they require backpropagating through the entire auto-regressive generation process to calculate gradients.
Methods
The authors propose DAB, which operates entirely in the discrete text domain.
- Joint Distribution Formulation: Instead of just modeling the output sequence $Y$, they introduce an auxiliary bias sequence $B$ (also made of discrete tokens). They define a joint distribution $P(Y, B | X)$ where $B$ acts as a "guide" that satisfies the constraints, and $Y$ is the fluent response influenced by that guide.
- Langevin-within-Gibbs Sampling: To sample from this distribution, the algorithm alternates between two steps:
- Sampling $B$ given $Y$: It uses a Discrete Langevin Proposal (DLP). This leverages gradients of the constraint function to suggest new tokens for the bias sequence without leaving the discrete domain.
- Sampling $Y$ given $B$: It performs standard auto-regressive generation, but "biases" the LLM's logits based on the semantic distance (in embedding space) to the tokens in $B$.
- Efficiency Hack: Because DAB samples $B$ based on the current $Y$ and then generates a new $Y$ based on $B$, it avoids the need to backpropagate through the LLM's internal states to get gradients. This significantly reduces the number of expensive GPU operations.
Datasets
The researchers evaluated DAB across three major tasks:
- Sentiment Control: Generating positive text using prompts from Dathathri et al. (2020) and evaluating with classifiers trained on Yelp Polarity and SST-2.
- Language Detoxification: Mitigating toxicity using 1,000 prompts from the RealToxicityPrompts dataset.
- Keyword-Guided Generation: Forcing the model to use specific keywords across 7 different topics (e.g., "Military," "Space," "Politics").
Key Insights and Ideas
- Discrete is Better: The "aha moment" is that staying in the discrete domain allows for "more directional and substantial updates." In continuous space, a gradient update might move an embedding slightly, but not enough to change the actual word. In discrete space, the model can "jump" directly to a more useful token.
- Stability: Continuous methods (like BOLT) often see their perplexity (a measure of gibberishness) explode as sampling steps increase. DAB remains remarkably stable, maintaining high fluency even with many iterations.
- The "Guide" Concept: By treating the bias sequence $B$ as a separate entity from the output $Y$, the model can use $B$ to "scout" the constraint landscape while $Y$ focuses on staying grammatically correct.
Key Results
- Speed: DAB is consistently 2x faster than BOLT (the leading continuous-bias baseline) in terms of tokens generated per second.
- Sentiment: On the Yelp evaluation, DAB achieved a sentiment score of 0.894 compared to BOLT’s 0.747, while maintaining similar fluency.
- Detoxification: DAB reduced average maximum toxicity to 0.211, outperforming all baselines (MuCOLA, COLD, BOLT, and LM-Steer).
- Exploration: The authors showed that DAB explores a much wider variety of unique tokens during the sampling process compared to continuous methods, proving it is better at searching the "space" of possible sentences.
Limitations and Future Work
- Scaling Gradients: While faster than previous methods, the number of gradient computations still increases with the number of queries, which could be a bottleneck for massive-scale deployments.
- Compositional Constraints: The current paper focuses on single constraints (e.g., just sentiment). The authors note that they haven't yet explored how DAB handles multiple, potentially conflicting constraints (e.g., "be positive" AND "talk about war").
- Discrete MCMC Refinement: The algorithm uses a single MCMC step for efficiency; exploring more complex sampling schedules could potentially improve results further.
The code for DAB is available at: https://github.com/patrickpynadath1/dab
Summary updated