NeuroLogic A*esque Decoding: Constrained Text Generation with Lookahead Heuristics

Ximing Lu, Sean Welleck, Peter West, Liwei Jiang, Jungo Kasai, Daniel Khashabi, Ronan Le Bras, Lianhui Qin, Youngjae Yu, Rowan Zellers, Noah A. Smith, Yejin Choi

Summary

NeuroLogic Aesque (NeuroLogic) is a novel decoding algorithm designed to provide autoregressive language models with "foresight." By integrating A*-style lookahead heuristics, the algorithm estimates the future cost of satisfying constraints and maintaining linguistic fluency. This approach significantly outperforms standard beam search and previous constrained decoding methods, particularly in zero-shot and few-shot scenarios.

The Challenge: Myopic Generation

Standard text generation from models like GPT is inherently "myopic." The model selects the next token based solely on the preceding context. While effective for open-ended tasks, this approach often fails when specific constraints must be met (e.g., including the words car, drive, and snow). A model might choose a highly probable word in the short term that inadvertently makes it impossible to satisfy a required constraint later in the sequence. Finding the optimal sequence under these conditions is an NP-complete problem.

Methodology: A* Search for Text

The authors introduce NeuroLogic A*esque decoding, inspired by the classic A* search algorithm. Instead of scoring a candidate word based only on its current probability, the algorithm incorporates a heuristic estimate of the future cost.

Figure 1: Conceptual overview of NeuroLogic* decoding. By looking ahead, the model avoids paths that fail to satisfy future constraints (e.g., 'snow').

Key technical contributions include:

  • Lookahead Heuristics: Four methods were developed to estimate future outcomes: Greedy (single sequence), Soft (token mixture), Beam (mini-search), and Sampling (multiple futures).
  • Constraint Integration: Building on the original NeuroLogic algorithm, the lookahead mechanism specifically rewards paths that increase the likelihood of satisfying currently unmet constraints.
  • Versatility: The algorithm is applicable to both constrained tasks and open-ended generation, where it helps maintain long-term fluency.

Experimental Evaluation

The researchers evaluated NeuroLogic* across five diverse tasks, including CommonGen (commonsense generation), WMT17 (machine translation), and E2ENLG (table-to-text).

Figure 5: Performance on the CommonGen dataset. NeuroLogic* variants consistently outperform supervised and unsupervised baselines across automatic and human evaluation metrics.

Key Results

  • CommonGen: Achieved new state-of-the-art results. In unsupervised settings, the METEOR score improved from 27.5 (original NeuroLogic) to 29.6.
  • Machine Translation: Significant improvements in terminology usage rates, particularly for complex constraints (96.5% vs. 93.7% for the baseline).
  • Few-Shot Learning: On the E2ENLG benchmark, NeuroLogic* achieved 100% constraint coverage in few-shot settings, compared to 73.6% for standard beam search.

Key Insights

  • Inference-Time Intelligence: A strong decoding algorithm can enable "off-the-shelf" models to outperform task-specific fine-tuned models. In CommonGen, unsupervised NeuroLogic* outperformed several supervised baselines.
  • Efficiency of Greedy Lookahead: While complex heuristics exist, the authors found that even a simple greedy lookahead provides a massive performance boost with manageable computational overhead.
  • Beyond Constraints: In story generation, lookahead helps avoid repetitive loops and improves overall coherence and "flow," as validated by human evaluators.

Conclusion and Future Work

NeuroLogic* demonstrates that incorporating foresight into decoding is a powerful substitute for massive task-specific training. While the current implementation is computationally more expensive than standard beam search and limited to constraints in Conjunctive Normal Form (CNF), future work may focus on more sophisticated learned heuristics and broader constraint types.

Summary updated

BibTeX
@inproceedings{lu2022neurologic,
  author = {Ximing Lu and Sean Welleck and Peter West and Liwei Jiang and Jungo Kasai and Daniel Khashabi and Ronan Le Bras and Lianhui Qin and Youngjae Yu and Rowan Zellers and Noah A. Smith and Yejin Choi},
  title = {{NeuroLogic A*esque Decoding: Constrained Text Generation with Lookahead Heuristics}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.naacl-main.57},
}
Figure