Large language models can be prompted to produce fluent output for a wide range of taskswithoutbeing specifically trained to do so.
Nevertheless, it is notoriously difficult to control their generation in such a way that it satisfies user-specified constraints.
In this paper, we presentInstructCTG, a simple controlled text generation framework that incorporates different constraints by verbalizing them as natural language instructions.
We annotate natural texts through a combination of off-the-shelf NLP tools and simple heuristics with the linguistic and extra-linguistic constraints they satisfy.
Then, we verbalize the constraints into natural language instructions to form weakly supervised training data, i.e., we prepend the natural language verbalizations of the constraints in front of their corresponding natural language sentences.
Next, we fine-tune a pre-trained language model on the augmented corpus.
Compared to existing methods,InstructCTGis more flexible in terms of the types of constraints it allows the practitioner to use.
It also does not require any modification of the decoding procedure.
Finally,InstructCTGallows the model to adapt to new constraints without re-training through the use of in-context learning.
Our code is available athttps://github.com/MichaelZhouwang/InstructCTG.