Large language models generate fluent texts and can follow natural language instructions to solve a wide range of tasks without task-specific training. Nevertheless, it is notoriously difficult to control their generation to satisfy the various constraints required by different applications. In this work, we present InstructCTG, a controlled text generation framework that incorporates different constraints by conditioning on natural language descriptions and demonstrations of the constraints. In particular, we first extract the underlying constraints of natural texts through a combination of off-the-shelf NLP tools and simple heuristics. We then verbalize the constraints into natural language instructions to form weakly supervised training data. By prepending natural language descriptions of the constraints and a few demonstrations, we fine-tune a pre-trained language model to incorporate various types of constraints. Compared to existing search-based or score-based methods, InstructCTG is more flexible to different constraint types and has a much smaller impact on the generation quality and speed because it does not modify the decoding procedure. Additionally, InstructCTG allows the model to adapt to new constraints without re-training through the use of few-shot task generalization and in-context learning abilities of instruction-tuned language models.
翻译:大型语言模型能够生成流畅的文本,并通过遵循自然语言指令解决广泛的任务,而无需针对特定任务进行训练。然而,控制其生成过程以满足不同应用场景的各种约束条件却极具挑战性。本文提出InstructCTG,一种受控文本生成框架,该框架通过以自然语言描述和示例为约束条件,将不同约束纳入生成过程。具体而言,我们首先结合现成的自然语言处理工具与简单启发式方法,从自然文本中提取底层约束。随后,将约束语言化为自然语言指令,构建弱监督训练数据。通过将约束的自然语言描述与少量示例置于输入前端,我们对预训练语言模型进行微调,使其能够融合多种类型的约束。与现有的基于搜索或评分的方法相比,InstructCTG对不同约束类型更具灵活性,且由于无需修改解码过程,对生成质量与速度的影响显著降低。此外,InstructCTG利用指令调优语言模型的少样本任务泛化与上下文学习能力,使模型无需重新训练即可适应新约束。