Abstract
We consider the task of text generation in language models with constraints specified in natural language. To this end, we first create a challenging benchmark Cognac that provides as input to the model a topic with example text, along with a constraint on text to be avoided. Unlike prior work, our benchmark contains knowledge-intensive constraints sourced from databases like Wordnet and Wikidata, which allows for straightforward evaluation while striking a balance between broad attribute-level and narrow lexical-level controls. We find that even state-of-the-art language models like GPT-3 fail often on this task, and propose a solution to leverage a language model's own internal knowledge to guide generation. Our method, called CognacGen, first queries the language model to generate guidance terms for a specified topic or constraint, and uses the guidance to modify the model's token generation probabilities. We propose three forms of guidance (binary verifier, top-k tokens, textual example), and employ prefix-tuning approaches to distill the guidance to tackle diverse natural language constraints. Through extensive empirical evaluations, we demonstrate that CognacGen can successfully generalize to unseen instructions and outperform competitive baselines in generating constraint conforming text.
Introduction
Large language models (LLMs) demonstrate remarkable fluency but frequently struggle with "negative constraints"—explicit instructions to avoid specific content. For instance, when prompted to "list British citizens but avoid politicians," a standard model may still generate "Winston Churchill" due to powerful internal associations. Existing controllable generation methods often rely on fixed control codes or external classifiers, which fail to scale to the diverse, knowledge-intensive constraints found in natural language.
The COGNAC Benchmark
To address this, researchers introduced COGNAC, a benchmark designed for knowledge-heavy constraints. It utilizes:
- WordNet: Hierarchical constraints (e.g., Topic: "Motor Vehicle", Constraint: "Car").
- Wikidata: Factual relation constraints (e.g., Topic: "Citizens of UK", Constraint: "Occupation = Politician").
- Natural Language Diversity: 35 different instruction templates to test generalization across various phrasings.
Methodology: COGNACGEN
The proposed framework, COGNACGEN, operates in two distinct stages to bridge the gap between a model's latent knowledge and its generation output.
1. Self-Guidance Distillation
Instead of external supervision, COGNACGEN queries the LLM to generate its own examples for both the topic and the constraint. For example, it might ask the model to list politicians. This internal knowledge is then distilled into steerable parameters using prefix-tuning, creating specific "topic" and "constraint" prefixes.
2. Guided Inference with Tries
During generation, these prefixes produce "guidance terms." To handle multi-token entities (like "George Orwell"), the system employs a trie-based decoding mechanism. This look-ahead strategy modifies next-token probabilities, boosting on-topic tokens while penalizing those that would lead to a constraint violation.
Key Results
The primary evaluation metric is Instruction Conformance (IC), measuring the percentage of outputs that are both on-topic and constraint-compliant.
Empirical results show that COGNACGEN (1.5B parameters) significantly outperforms the much larger GPT-3 (175B). On WordNet, COGNACGEN achieved an IC of 32.4 compared to GPT-3’s 22.4. On Wikidata, it reached 31.8 versus GPT-3’s 20.2. Notably, the model maintained high fluency (measured by perplexity) and successfully generalized to unseen natural language instructions.
Conclusion and Future Work
COGNACGEN demonstrates that targeted guidance can enable smaller models to outperform massive ones in instruction following. The core insight is that LLMs often possess the necessary knowledge to satisfy constraints but require specialized decoding strategies to apply it effectively. Future research will focus on scaling this approach to handle multiple simultaneous or conflicting constraints and addressing potential biases within the underlying knowledge bases.
Summary updated