Large pre-trained language models are well-established for their ability to generate text seemingly indistinguishable from humans. In this work, we study the problem of constrained sampling from such language models. That is, generating text that satisfies user-defined constraints. Typical decoding strategies which generate samples left-to-right are not always conducive to imposing such constraints globally. Instead, we propose MuCoLa -- a sampling procedure that combines the log-likelihood of the language model with arbitrary differentiable constraints into a single energy function; and generates samples by initializing the entire output sequence with noise and following a Markov chain defined by Langevin Dynamics using the gradients of this energy. We evaluate our approach on different text generation tasks with soft and hard constraints as well as their combinations with competitive results for toxicity avoidance, sentiment control, and keyword-guided generation.
翻译:受过培训的大型语言模型对于其生成似乎与人类无法区分的文本的能力是十分成熟的。 在这项工作中,我们研究了来自这些语言模型的受限抽样问题。 也就是说, 生成满足用户定义限制的文本。 生成从左到右样本的典型解码策略并不总是有利于在全球范围施加这些限制。 相反, 我们提议一个取样程序, 将语言模型的日志相似性和可任意区分的限制结合成一个单一的能源功能; 通过启动由Langevin Directives利用这种能量的梯度定义的整个输出序列, 并遵循由Langevin Directives定义的Markov链条, 生成样本。 我们评估了我们在不同文本生成任务上采用软硬限制的方法, 以及结合了避免毒性、 情绪控制和关键词制导生成的竞争结果。