This work proposes a lookahead-guided decoding framework for context-free grammars based on pushdown automata based on bounded pushdown summaries with reachability labels and upper-bound distances to acceptance.
Abstract
Grammar-constrained decoding helps large language models produce syntactically valid structured outputs, such as code, JSON, and SQL. For context-free grammars, many practical decoders enforce local prefix feasibility: each token must keep the current prefix extendable to some valid completion. Yet, under tokenizer-grammar mismatch and finite token budgets, feasible prefixes may still fail to reach acceptance. We propose a lookahead-guided decoding framework for context-free grammars based on pushdown automata. Offline, we compute bounded pushdown summaries with reachability labels and upper-bound distances to acceptance. Online, these estimates guide horizon-aware pruning and beam search. The resulting decoder is syntactically sound: every output is accepted by the target grammar. Experiments on JSON, SQL, and Linear Temporal Logic (LTL) show both consistent syntactic validity and improved completion quality over existing baselines.
The proposed PSC, a novel grammar-constrained decoding method, can compute the complete vocabulary mask by checking the parser stack exactly once per decoding step, with time complexity independent of the vocabulary size.
Yong-Ming Li, Yihong Dong, Jia Li et al.· Proceedings of the ACM on So...· 0 citations
This work defines an agent, called Autogrammar, that automatically learns context-free grammars from documentation and execution data, formalized as a Kripke structure whose nondeterministic choices are resolved by a language model, enabling declarative control of agent behavior via linear temporal logic constraints.
K. Cheang, G. Hulette, Rahul Kumar et al.· 0 citations
This work studies a production policy in which each ordered family is the conjunction of two regular-language predicates, and shows that the resulting monitor is release-boundary equivalent to an absorbing cumulative oracle for every policy in the declared grammar.
The trie automaton is introduced, a specialized mechanism that exploits finite-set structure via Aho-Corasick multi-pattern matching to precompute per-node token masks, and achieves 7X faster per-step valid-token computation compared to XGrammar and 2.5X faster compilation at K>= 300.
SHIM is introduced, a lightweight, offline-trained correction of the LM's next-token probabilities, conditioned on this syntactic and lexical state together with candidate next tokens, which substantially narrows the gap to the LM's grammar-conditioned distribution compared to masking and online sampling, while running...
Işıl Özgü, Yaoxuan Wu, Guy Van den Broeck et al.· 0 citations
GSA-Beam improves explicit state coverage and final structural diversity while preserving schema validity while preserving schema validity; across several LLM backbones, it reduces reference latency by 22.5% on average compared with standard constrained beam search.
Han-Tao Hua, Ji-Ming Su, Yi-Ping Yao et al.· Proceedings of the Thirty-Fi...· 0 citations
Related blog posts
MIT News · Artificial Intelligence· news.mit.eduOct 13, 2026
Machine-learning networks can learn without detailed instructions from a designer. Those that do may offer insight into how the brain reorganizes itself during learning.
MIT News · Artificial Intelligence· news.mit.eduSep 29, 2026
Professor Sherry Turkle’s new book, “Artificial Intimacy,” offers a withering critique of chatbots and the antisocial dynamics she believes they encourage.