arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2506.05754cs.AIcs.CLcs.LG
收藏

语言模型的约束采样应当简单:一个MCMC视角

Constrained Sampling for Language Models Should Be Easy: An MCMC Perspective

UCSD(加州大学圣地亚哥分校);Peking University(北京大学)

Emmanuel Anaya Gonzalez, Sairam Vaidya, Kanghee Park, Ruyi Ji, Taylor Berg-Kirkpatrick, Loris D'Antoni

AI总结:

本文提出基于MCMC的约束采样框架,通过Metropolis-Hastings准则在满足硬约束的同时保持语言模型原始分布,兼顾约束满足、单调收敛和高效采样,在合成基准和程序模糊测试中优于现有方法。

摘要:

约束解码使语言模型(LMs)能够生成可证明满足硬约束的样本。然而,现有的约束解码方法常常扭曲底层模型分布,这一局限在程序模糊测试等应用中尤为突出,因为在这些应用中,人们希望生成多样且有效的程序输入用于测试目的。我们提出了一种基于马尔可夫链蒙特卡洛(MCMC)的新约束采样框架,该框架同时满足三个核心要求:约束满足性(每个样本都满足约束)、单调收敛性(采样过程收敛到真实条件分布)以及高效性(在少量步骤内产生高质量样本)。我们的方法在有效输出上构建提议分布,并基于语言模型的似然应用Metropolis-Hastings接受准则,确保对约束空间进行有原则且高效的探索。实验表明,我们的采样器在合成基准和真实世界程序模糊测试任务上均优于现有方法。

英文摘要:

Constrained decoding enables Language Models (LMs) to produce samples that provably satisfy hard constraints. However, existing constrained-decoding approaches often distort the underlying model distribution, a limitation that is especially problematic in applications like program fuzzing, where one wants to generate diverse and valid program inputs for testing purposes. We propose a new constrained sampling framework based on Markov Chain Monte Carlo (MCMC) that simultaneously satisfies three core desiderata: constraint satisfying (every sample satisfies the constraint), monotonically converging (the sampling process converges to the true conditional distribution), and efficient (high-quality samples emerge in few steps). Our method constructs a proposal distribution over valid outputs and applies a Metropolis-Hastings acceptance criterion based on the LM's likelihood, ensuring principled and efficient exploration of the constrained space. Empirically, our sampler outperforms existing methods on both synthetic benchmarks and real-world program fuzzing tasks.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑