[Paper Review] Guiding LLMs The Right Way: Fast, Non-Invasive Constrained Generation
This paper introduces DOMINO, a novel constrained decoding algorithm that enables fast, non-invasive, and subword-aligned generation of structured text using large language models (LLMs). By leveraging pre-computation and speculative decoding, DOMINO enforces context-free grammar constraints with near-zero inference overhead—often achieving up to 1.7× faster throughput than unconstrained decoding—while maintaining or even improving downstream accuracy.
To ensure that text generated by large language models (LLMs) is in an expected format, constrained decoding proposes to enforce strict formal language constraints during generation. However, as we show in this work, not only do such methods incur performance overhead during generation, but many of them also significantly impair task accuracy, if they do not correctly align the underlying LLM sub-word vocabularies with external constraints. To address this, we present a novel decoding algorithm, DOMINO, that can enforce constraints in a fully subword-aligned fashion, while leveraging pre-computation and speculative decoding to achieve virtually no overhead and in some cases even almost 2$ imes$ speedup over unconstrained decoding -- thereby outperforming existing approaches by a wide margin.
Motivation & Objective
- Address the critical challenge of token misalignment in constrained decoding, where subword tokenization disrupts grammar enforcement and degrades model performance.
- Overcome the performance overhead and accuracy degradation common in existing constrained decoding methods that do not align LLM subword vocabularies with syntactic constraints.
- Develop a minimally invasive decoding strategy that preserves the model's natural output distribution while ensuring strict adherence to formal language constraints.
- Achieve high-throughput, low-latency constrained generation by combining pre-computation, speculative decoding, and opportunistic masking for efficient inference.
Proposed method
- Propose DOMINO, a constrained decoding algorithm that enforces context-free grammars (CFGs) with full subword alignment, avoiding suboptimal token choices caused by naive terminal restriction.
- Use pre-computation to build a prior over valid token sequences, enabling efficient speculative decoding during inference without runtime parsing overhead.
- Implement speculative decoding by generating multiple candidate tokens ahead of time and validating them against the grammar, reducing the number of LLM autoregressive steps.
- Introduce opportunistic masking, a fallback mechanism that selectively restricts only the most problematic tokens when speculative decoding is ineffective, minimizing interference.
- Design a bridge token handling mechanism that accounts for multi-token grammar terminals (e.g., "\t" or "}" in JSON) to prevent perplexity spikes and distributional drift.
- Integrate the algorithm with standard LLM inference backends (e.g., Hugging Face Transformers) to ensure broad compatibility and practical deployment.

Experimental results
Research questions
- RQ1To what extent does token misalignment in constrained decoding degrade model performance and increase perplexity compared to unconstrained generation?
- RQ2Can speculative decoding be effectively adapted to constrained decoding to reduce inference latency while maintaining strict grammar enforcement?
- RQ3How does pre-computation of valid token sequences impact the efficiency and accuracy of constrained generation in LLMs?
- RQ4Does minimizing interference during constrained decoding—via subword alignment and opportunistic masking—lead to higher downstream accuracy compared to existing methods?
- RQ5Can constrained decoding achieve higher throughput than unconstrained decoding, particularly in predictable, schema-driven formats?
Key findings
- DOMINO achieves up to 1.7× higher throughput than unconstrained decoding for schema-driven JSON generation using speculative decoding with s=6–10 speculative tokens.
- For free-form JSON, DOMINO’s opportunistic masking introduces only a 4.21% overhead, outperforming baseline methods like llama.cpp and guidance in efficiency.
- With k=∞ (full lookahead), DOMINO recovers and slightly exceeds unconstrained accuracy on GSM8K (0.418 vs. 0.415 for Mistral 7B), demonstrating minimal invasiveness.
- When k is reduced to 0 or 1, performance drops significantly (e.g., 0.308 for Mistral 7B), showing that missing bridge tokens like "," or "}" harms reasoning and structure.
- For complex grammars like C code, speculative decoding is ineffective due to low predictability, but DOMINO still outperforms llama.cpp by 5.4% in throughput (0.78× vs. 0.74× unconstrained).
- Pre-computation time ranges from 1–5 seconds (up to 20s for C), but is not included in throughput measurements, making DOMINO highly efficient at inference time.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.