NeuroLogic Decoding: (Un)supervised Neural Text Generation with Predicate Logic Constraints
Ximing Lu, Peter West, Rowan Zellers, Ronan Le Bras, Chandra Bhagavatula, Yejin Choi
TL;DR
NeuroLogic Decoding tackles the challenge of generating text under complex lexical constraints by integrating predicate-logic constraints into decoding. It represents constraints in CNF, tracks clause states with dedicated prefix tries, and performs pruning, grouping, and selection to search for high-likelihood outputs that satisfy all constraints with beam-search-like efficiency. Across commonsense generation, recipe writing, data-grounded dialogue, and translation bias mitigation, NeuroLogic yields consistent gains in constraint satisfaction and generation quality, including strong zero-shot performance and notable improvements over supervised baselines. The work suggests inference-time constraint enforcement can rival or exceed the benefits of large-scale finetuning, offering a practical path to controllable generation without architectural changes.
Abstract
Conditional text generation often requires lexical constraints, i.e., which words should or shouldn't be included in the output text. While the dominant recipe for conditional text generation has been large-scale pretrained language models that are finetuned on the task-specific training data, such models do not learn to follow the underlying constraints reliably, even when supervised with large amounts of task-specific examples. We propose NeuroLogic Decoding, a simple yet effective algorithm that enables neural language models -- supervised or not -- to generate fluent text while satisfying complex lexical constraints. Our approach is powerful yet efficient. It handles any set of lexical constraints that is expressible under predicate logic, while its asymptotic runtime is equivalent to conventional beam search. Empirical results on four benchmarks show that NeuroLogic Decoding outperforms previous approaches, including algorithms that handle a subset of our constraints. Moreover, we find that unsupervised models with NeuroLogic Decoding often outperform supervised models with conventional decoding, even when the latter is based on considerably larger networks. Our results suggest the limit of large-scale neural networks for fine-grained controllable generation and the promise of inference-time algorithms.
