基于局部约束重采样的可控生成
Controllable Generation via Locally Constrained Resampling
AI总结:
提出基于局部约束重采样的概率方法,通过贝叶斯条件化从局部分布采样并重采样以纠正偏差,在LLM解毒和数独任务上实现全局最优约束生成且保证满足约束。
摘要:
自回归模型在建模自然语言的复杂性方面展现出了前所未有的能力。然而,它们在生成遵循逻辑约束的复杂输出方面仍然存在困难。从完全独立的分布中采样以满足约束条件是很困难的。从自回归分布中采样以满足约束条件更是难上加难:我们不仅要应对约束本身的困难,还要应对分布缺乏结构的问题。我们提出了一种易于处理的概率方法,通过执行贝叶斯条件化来抽取满足约束的样本。我们的方法考虑了整个序列,从而比当前的贪心方法实现更全局最优的约束生成。从模型样本开始,我们引入一个局部的、因式分解的分布,使得我们可以易于处理地以约束为条件进行条件化。为了生成满足约束的样本,我们从条件分布中采样,纠正样本中的偏差并重新采样。由此产生的样本紧密近似目标分布,并保证满足约束。我们在多项任务上评估了我们的方法,包括 LLM 解毒和求解数独谜题。我们表明,通过禁止一系列有毒表达,我们的方法能够引导模型的输出远离有毒生成,优于类似的解毒方法。最后,我们展示了我们的方法在数独上实现了完美的准确率,而 GPT4-o 和 Gemini 1.5 的准确率低于 50%。
英文摘要:
Autoregressive models have demonstrated an unprecedented ability at modeling the intricacies of natural language. However, they continue to struggle with generating complex outputs that adhere to logical constraints. Sampling from a fully-independent distribution subject to a constraint is hard. Sampling from an autoregressive distribution subject to a constraint is doubly hard: We have to contend not only with the hardness of the constraint but also the distribution's lack of structure. We propose a tractable probabilistic approach that performs Bayesian conditioning to draw samples subject to a constraint. Our approach considers the entire sequence, leading to a more globally optimal constrained generation than current greedy methods. Starting from a model sample, we induce a local, factorized distribution which we can tractably condition on the constraint. To generate samples that satisfy the constraint, we sample from the conditional distribution, correct for biases in the samples and resample. The resulting samples closely approximate the target distribution and are guaranteed to satisfy the constraints. We evaluate our approach on several tasks, including LLM detoxification and solving Sudoku puzzles. We show that by disallowing a list of toxic expressions our approach is able to steer the model's outputs away from toxic generations, outperforming similar approaches to detoxification. We conclude by showing that our approach achieves a perfect accuracy on Sudoku compared to <50% for GPT4-o and Gemini 1.5.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。