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

Guaranteed Generation from Large Language Models

Minbeom Kim, Thibaut Thonet, Jos Rozen, Hwaran Lee, Kyomin Jung, Marc Dymetman

TL;DR

Researchers have proven that it is mathematically impossible for standard Large Language Models (LLMs) to perfectly satisfy hard constraints through training alone without distorting their natural output distribution. To solve this, they introduced GUARD, a framework that combines an optimized "proposal" model with rejection sampling to provide 100% constraint guarantees while maintaining high inference speed and distributional integrity.

The Challenge of Strict Constraints

We often need LLMs to follow strict rules—like "never use word X," "always include keyword Y," or "ensure the story ends happily." Current approaches like Supervised Fine-Tuning (SFT) or Reinforcement Learning from Human Feedback (RLHF) enforce "soft" constraints; they make the desired behavior more likely but offer no absolute guarantee.

If a 100% guarantee is required, the standard fallback is rejection sampling: generating outputs repeatedly until the model produces one that satisfies the rule. However, if the constraint is difficult (e.g., a 0.1% success rate), you might have to generate thousands of samples before one passes, making it too slow for real-world use. Furthermore, simply forcing a model to satisfy a constraint often "breaks" its natural reasoning or creativity, leading to repetitive or biased outputs.

The GUARD Framework

To address this, the authors propose GUARD (GUaranteed Autoregressive Rejection Distribution). The approach rests on three core pillars:

  1. The Gold Model ($g$): The authors define a theoretical "ideal" distribution that perfectly satisfies the constraint while remaining as close as possible (in terms of KL divergence) to the original base model.
  2. The Impossibility Theorem: They provide a formal proof that, assuming $P \neq NP$, no standard autoregressive model can exactly match this "Gold" distribution for all types of constraints. This justifies why inference-time methods like rejection sampling are strictly necessary.
  3. Optimized Proposal ($a'$): Since training a perfect model is impossible, GUARD trains a "proposal" model to get as close to the Gold distribution as possible using Distributional Policy Gradient (DPG). By minimizing the distance to the Gold model, GUARD simultaneously improves text quality and the acceptance rate (how often the model passes the filter).
Conceptual overview of the GUARD framework.

A key innovation in this process is Warm-start DPG, where training is initialized using constraint-aware prompts. This prevents the model from "wandering in the dark" during early training phases when it might otherwise fail to generate any valid samples to learn from.

Key Insights: The "Pythagorean" Trade-off

The paper uses information geometry to reveal a fascinating "Pythagorean" trade-off (illustrated in the figure above). The distance between the proposal model and the ideal target is equal to the sum of the "closeness" of the final output and the "inefficiency" of the sampler. In short: Better training equals faster inference.

The paper also highlights that prompting creates "Positional Bias." Simply prompting a model to include a word (e.g., "Write a sentence including 'amazing'") causes the model to "panic" and drop the word as early as possible, ruining the natural distribution. GUARD avoids this by training the model to place the constraint naturally, wherever it fits best. Ultimately, GUARD clarifies that you don't have to choose between training and inference-time filtering; training's primary job in a guaranteed system is to make the inference-time filter more efficient.

Experimental Results

The authors evaluated GUARD on two challenging scenarios:

  • Lexical Constraints: Forcing the model (Gemma-2B) to include the keyword "amazing" within a 30-token generation. The base model only satisfied the constraint 0.23% of the time. GUARD improved the acceptance rate to 41.6%—a nearly 180x improvement in efficiency for rejection sampling.
  • Sentiment Reversal: Given a negative story opening (ROCStories), a fine-tuned GPT-2 model must generate a continuation ending with a highly positive sentence.

In both tasks, GUARD's outputs were significantly more diverse (lower Self-BLEU scores) and stayed much closer to the "Gold" distribution compared to simple prompting. GUARD "Pareto-dominates" standard fine-tuning, achieving both better distributional closeness and higher inference speed simultaneously.

Limitations and Future Work

The primary limitation of GUARD is its reliance on a binary filter ($b$). The framework assumes you have a perfect way to check if a constraint is met. If your filter is flawed (e.g., a sentiment classifier that makes mistakes), GUARD will perfectly satisfy the filter, but not necessarily the user's intent.

Future work could involve scaling GUARD to much larger models (70B+ parameters), developing more sophisticated multi-step filters for complex logical constraints, and exploring how GUARD can enforce safety "guardrails" without making the model's personality bland or repetitive.

Summary updated

BibTeX
@inproceedings{kim2025guaranteed,
  author = {Minbeom Kim and Thibaut Thonet and Jos Rozen and Hwaran Lee and Kyomin Jung and Marc Dymetman},
  title = {{Guaranteed Generation from Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=8roRgrjbjv},
}
Figure