Adaptable Logical Control for Large Language Models

Honghua Zhang, Po-Nien Kung, Masahiro Yoshida, Guy Van den Broeck, Nanyun Peng
2/3/2026

No official code found. Best implementation: joshuacnf/Ctrl-G (114 stars, MIT, last commit 2025-01-06).

Abstract

Despite the success of Large Language Models (LLMs) on various tasks following human instructions, controlling model generation at inference time poses a persistent challenge. In this paper, we introduce Ctrl-G, an adaptable framework that facilitates tractable and flexible control of LLM generation to reliably follow logical constraints. Ctrl-G combines any production-ready LLM with a Hidden Markov Model, enabling LLM outputs to adhere to logical constraints represented as deterministic finite automata. We show that Ctrl-G, when applied to a TULU2-7B model, outperforms GPT3.5 and GPT4 on the task of interactive text editing: specifically, for the task of generating text insertions/continuations following logical constraints, Ctrl-G achieves over 30% higher satisfaction rate in human evaluation compared to GPT4. When applied to medium-size language models (e.g., GPT2-large), Ctrl-G also beats its counterparts for constrained generation by large margins on standard benchmarks. Additionally, as a proof-of-concept study, we experiment Ctrl-G on the Grade School Math benchmark to assist LLM reasoning, foreshadowing the application of Ctrl-G, as well as other constrained generation approaches, beyond traditional language generation tasks.

View on arXivView PDF

Code Implementations(1)

joshuacnf/Ctrl-GCommunity100%
MIT
11426Python, Jupyter NotebookJun 19, 20241 years agoMIT

Similar Papers

Cite this paper

@article{zhang2026adaptable,
  title  = {Adaptable Logical Control for Large Language Models},
  author = {Honghua Zhang and Po-Nien Kung and Masahiro Yoshida and Guy Van den Broeck and Nanyun Peng},
  year   = {2026},
  eprint = {2406.13892},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2406.13892},
  url    = {https://arxiv.org/abs/2406.13892},
  journal = {NEURIPS 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2406.13892.svg)](https://codeofpaper.com/paper/2406.13892)

Discussion