arXiv:2410.13111cs.LGcs.CL2024-10ICLR被引 14

通过局部约束重采样,实现可控文本生成,提升逻辑一致性与准确性。

Controllable Generation via Locally Constrained Resampling

  • 基于贝叶斯条件化构建局部可分解分布,实现约束下的高效采样
  • 在毒物过滤任务中有效避免有害输出,优于现有方法
  • 在数独求解上达100%准确率,远超GPT4-o和Gemini 1.5的不足50%

自回归模型虽能精细建模自然语言,但在生成符合逻辑约束的复杂内容时仍存在困难。传统独立分布采样受约束影响已难,而自回归分布因缺乏结构,更难满足约束。本文提出一种可行的概率方法,通过贝叶斯条件化对样本施加约束。从模型生成样本出发,构造局部因子化分布,可高效条件化于约束并重采样。通过偏差校正与迭代重采样,生成结果逼近目标分布且严格满足约束。我们在多个任务上评估该方法,包括大模型去毒和数独求解。实验表明,禁止特定毒害表达后,该方法能有效引导输出远离有害内容,性能优于同类方法;在数独任务中,该方法实现100%准确率,而GPT4-o和Gemini 1.5均低于50%。

原文摘要 · Abstract (English)

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.

可控生成约束采样文本去毒数独求解

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。