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对不同约束类型更具灵活性,且由于不修改解码过程,对生成质量与速度的影响显著降低。此外,借助指令微调语言模型的少样本任务泛化与上下文学习能力,该方法无需重新训练即可适应新约束。