Abstract
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.
Introduction
While Large Language Models (LLMs) are incredibly fluent, they are notoriously difficult to "steer" with precision. Standard prompting often fails when a model is required to generate text that satisfies multiple complex constraints simultaneously—such as including specific keywords, following a strict grammatical structure, and maintaining a particular sentiment.
Historically, researchers addressed this through decoding-time constraints, modifying search algorithms like Beam Search to force specific token selections. However, these methods often compromise text quality, significantly slow down generation speed, and lack flexibility, typically requiring bespoke algorithms for each new constraint type.
The InstructCTG Framework
Presented at ICML 2023, InstructCTG simplifies controlled text generation by treating it as a natural language instruction-following task. Instead of modifying the decoding process, the framework incorporates constraints during the training stage.
The core of InstructCTG is a weakly supervised data synthesis pipeline:
- Constraint Imputation: Using a massive unlabeled corpus (C4), the authors employed off-the-shelf NLP tools (e.g., POS taggers, sentiment classifiers) to identify constraints already satisfied by existing sentences.
- Verbalization: These raw constraints were converted into natural language instructions using templates (e.g., "Write something with positive sentiment that has 10 to 15 words").
- Instruction Tuning: A T0-11B model was fine-tuned on these pairs, learning the relationship between constraint descriptions and the resulting text.
- Meta In-Context Learning: To handle unseen constraints, demonstrations were included in the prompt, leveraging the model's ability to generalize to novel rules at test time.
Experimental Setup
The researchers utilized a diverse array of datasets to ensure broad coverage of constraint types:
- C4: Used for lexical, syntactic, and length constraints.
- Amazon Reviews & Political Slant: Used for sentiment and style constraints.
- M2D2: Used for topic and domain constraints.
- GYAFC, FlickrStyle, & Wiki Neutrality: Used for formality, stylized captions, and bias reduction.
- QQP & SQuAD: Used for conditional tasks like paraphrase and question generation.
Key Results and Analysis
InstructCTG demonstrates significant advantages over traditional search-based or score-based methods in terms of fluency, speed, and satisfaction rates.
- Superior Fluency: By incorporating constraints during training rather than forcing them during decoding, the model maintains its internal understanding of grammar and flow, resulting in much lower perplexity scores.
- Efficiency: InstructCTG uses standard decoding, making it 4x faster than NeuroLogic decoding and over 40x faster than Diffusion-LM.
- Constraint Satisfaction: As shown in Figure 2, InstructCTG maintains higher performance levels than baselines even as the number of constraints increases. It matched or exceeded the satisfaction rates (SUCC) of computationally expensive decoding algorithms across all categories.
- Zero-Shot Generalization: The model achieved 83-87% satisfaction on constraints not present in the training set, proving its ability to "understand" natural language instructions rather than just memorizing templates.
Conclusion and Future Work
InstructCTG represents a shift toward more flexible and efficient controlled text generation. By leveraging weak supervision and instruction tuning, it achieves state-of-the-art results without the overhead of constrained decoding.
Future work may explore scaling these techniques to larger architectures like GPT-4 and expanding the breadth of constraints to include logical consistency and factual accuracy. Additionally, the authors note the importance of safety, as instruction following could potentially be used to generate toxic content more effectively if not properly moderated.
Summary updated