约束自适应拒绝采样
Constrained Adaptive Rejection Sampling
AI总结:
提出约束自适应拒绝采样(CARS),通过自适应剪枝无效前缀来提高拒绝采样的样本效率,同时保持无分布扭曲,在程序模糊测试和分子生成等任务中优于现有方法。
摘要:
语言模型(LMs)越来越多地应用于生成的输出必须满足严格语义或语法约束的场景。现有的约束生成方法处于一个谱系中:贪婪约束解码方法在解码过程中强制执行有效性,但扭曲了LM的分布;而拒绝采样(RS)保留了保真度,但通过丢弃无效输出浪费计算资源。在程序模糊测试等领域,样本的有效性和多样性都至关重要,这两种极端方法都有问题。我们提出约束自适应拒绝采样(CARS),一种严格提高RS样本效率且不产生分布扭曲的方法。CARS从无约束LM采样开始,通过将违反约束的续写记录在trie中并从后续抽取中减去其概率质量,自适应地排除它们。这种自适应剪枝确保已证明无效的前缀不会被重新访问,接受率单调提高,并且生成的样本精确遵循约束分布。在多个领域的实验(例如程序模糊测试和分子生成)中,CARS始终实现更高的效率(以每个有效样本的LM前向传递次数衡量),同时产生比GCD和近似LM分布的方法更强的样本多样性。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。