arXiv

Constrained Adaptive Rejection Sampling

Title: Constrained Adaptive Rejection Sampling

Abstract

As Language Models (LMs) are increasingly deployed in applications requiring generated outputs to adhere to rigorous semantic or syntactic rules, the challenge of constrained generation has gained prominence. Current methodologies exist on a spectrum: Greedy Constrained Decoding (GCD) methods guarantee validity during the decoding process but inadvertently distort the underlying LM distribution. Conversely, Rejection Sampling (RS) maintains distributional fidelity but incurs significant computational waste by discarding invalid outputs. Both approaches present significant drawbacks, particularly in fields like program fuzzing, where maintaining both sample validity and diversity is critical.

To address these limitations, we introduce Constrained Adaptive Rejection Sampling (CARS), a novel approach that enhances the sample efficiency of RS while strictly preserving distributional accuracy. CARS initiates with standard unconstrained LM sampling and employs an adaptive mechanism to eliminate constraint-violating continuations. This is achieved by recording invalid paths in a trie structure and subtracting their associated probability mass from subsequent sampling attempts. This adaptive pruning strategy ensures that prefixes already identified as invalid are never re-sampled, leading to monotonically increasing acceptance rates. Consequently, the final samples conform precisely to the constrained distribution.

Experimental evaluations across multiple domains, including molecular generation and program fuzzing, demonstrate that CARS consistently outperforms existing methods. It achieves superior efficiency, quantified by the number of LM forward passes required per valid sample, and generates higher sample diversity compared to both GCD and techniques that approximate the LM’s distribution.


Source: arXiv Generated at: 2026-06-04 00:00:00 UTC

Related Articles

Zurich Insurance Expands Data-Center Offering Beyond the US
Bloomberg

Zurich Insurance Expands Data-Center Offering Beyond the US

Zurich Insurance Group is expanding its data center insurance products internationally, extending coverage beyond the Un...

Emerging-Market Stocks Fall as Broadcom Miss Disrupts AI Trade
Bloomberg

Emerging-Market Stocks Fall as Broadcom Miss Disrupts AI Trade

Broadcom’s earnings miss triggered a sell-off in AI stocks, dragging down emerging-market equities. This disruption high...

Revolut Co-Founder, CTO Vlad Yatsenko to Step Down From Role
Bloomberg

Revolut Co-Founder, CTO Vlad Yatsenko to Step Down From Role

Revolut co-founder and CTO Vlad Yatsenko is stepping down from his executive role. The resignation marks a significant l...

Netflix Top Tech Exec Stone on Integrating AI
Bloomberg

Netflix Top Tech Exec Stone on Integrating AI

Netflix’s top tech exec discusses integrating AI to enhance content discovery and production efficiency.

Microsoft’s AI Chief Says Anthropic Models Are Too Expensive
Bloomberg

Microsoft’s AI Chief Says Anthropic Models Are Too Expensive

Microsoft AI CEO Mustafa Suleyman criticized Anthropic’s models as too expensive. Meanwhile, Microsoft plans to allow us...

Ramp Notches $44 Billion Valuation in New Funding Round
Bloomberg

Ramp Notches $44 Billion Valuation in New Funding Round

RAMP secured a $44 billion valuation in its latest funding round. CEO Eric Glyman attended the 2026 Reagan National Econ...