Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Constrained Adaptive Rejection Sampling

About

Language Models (LMs) are increasingly used in applications where generated outputs must satisfy strict semantic or syntactic constraints. Existing approaches to constrained generation fall along a spectrum: greedy constrained decoding methods enforce validity during decoding but distort the LM's distribution, while rejection sampling (RS) preserves fidelity but wastes computation by discarding invalid outputs. Both extremes are problematic in domains such as program fuzzing, where both validity and diversity of samples are essential. We present Constrained Adaptive Rejection Sampling (CARS), an approach that strictly improves the sample-efficiency of RS without distributional distortion. CARS begins with unconstrained LM sampling and adaptively rules out constraint-violating continuations by recording them in a trie and subtracting their probability mass from future draws. This adaptive pruning ensures that prefixes proven invalid are never revisited, acceptance rates improve monotonically, and the resulting samples exactly follow the constrained distribution. In experiments on a variety of domains -- e.g., program fuzzing and molecular generation -- CARS consistently achieves higher efficiency -- measured in the number of LM forward passes per valid sample -- while also producing stronger sample diversity than both GCD and methods that approximate the LM's distribution.

Pawe{\l} Parys, Sairam Vaidya, Taylor Berg-Kirkpatrick, Loris D'Antoni• 2025

Related benchmarks

TaskDatasetResultRank
Text-to-SQLSpider (dev)
EX57.8
196
PlanningPDDL
Progress Rate70
33
XML FuzzingXML fuzzing benchmarks
Mean Lines Covered8.05e+3
27
JSON FuzzingJSON
Line Coverage3.24e+3
24
FuzzingJSON fuzzing target
Generations to Find 100 Valid Samples121
24
Molecular GenerationHydrocarbon Chains
Sample Efficiency108
21
Molecule GenerationIsocyanates
Sample Efficiency132
21
Molecular GenerationAcrylates (Acry.)
Sample Efficiency277
21
SQL fuzzingSQL fuzzing benchmarks
Mean Lines Covered2.29e+4
19
FuzzingXML fuzzing target
Generations Count (100 valid samples)215
15
Showing 10 of 12 rows

Other info

Follow for update