Mitigating Bias in Locally Constrained Decoding via Tractable Proposals
Abstract
Lay Summary
Large language models are often asked to produce outputs that must follow strict formats, such as JSON function calls or SQL queries. Current methods usually check only whether the next token is allowed. This can still lead to invalid outputs when the model runs out of tokens, and it can also change the model's intended distribution in undesirable ways. We introduce a decoding method that looks ahead to ensure that every chosen token can still lead to a valid complete output within the given token budget. We represent the constraints as finite automata and run them efficiently on GPUs. We also combine these constraints with a small probabilistic model that estimates which valid continuations are more likely. Experiments on function calling, keyword-based generation, and text-to-SQL show that our method produces valid outputs more reliably and needs fewer samples to approximate the desired constrained distribution. This makes constrained generation more accurate and efficient for structured language-model applications.