语言模型中基于语义的约束抽样
Gradient-Based Constrained Sampling from Language Models
摘要:
大型的预训练语言模型生成流畅的文本,但众所周知,很难可控地从中采样。在这项工作中,我们研究约束抽样从这样的语言模型:生成满足用户定义的约束的文本,同时保持流畅性和模型的性能在下游任务。我们提出了MuCoLa --一种采样过程,它将语言模型的对数似然与单个能量函数中的任意(可微)约束相结合,然后以非自回归方式生成样本。具体地说,它将整个输出序列与噪声叠加,并遵循由Langevin Dynamics使用能量函数的梯度定义的马尔可夫链。我们评估了MuCoLa在文本生成方面的软约束和硬约束以及它们的组合,在毒性避免,情感控制和关键词引导生成方面获得了显着的改进。
英文摘要:
Large pretrained language models generate fluent text but are notoriously hard to controllably sample from. In this work, we study constrained sampling from such language models: generating text that satisfies user-defined constraints, while maintaining fluency and the model's performance in a downstream task. We propose MuCoLa -- a sampling procedure that combines the log-likelihood of the language model with arbitrary (differentiable) constraints in a single energy function, and then generates samples in a non-autoregressive manner. Specifically, it initializes the entire output sequence with noise and follows a Markov chain defined by Langevin Dynamics using the gradients of the energy function. We evaluate MuCoLa on text generation with soft and hard constraints as well as their combinations obtaining significant improvements over competitive baselines for toxicity avoidance, sentiment control, and keyword-guided generation.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。