mlsanityData to 14 Oct 2026

Correctness-Guaranteed Code Generation via Constrained Decoding

arXiv 2508.15866 ↗First posted 20 Aug 2025cs.PL cs.LG cs.SEcited by 7

Not on the map. Why?

Abstract (arXiv)

Language Models (LMs) are increasingly being used for code generation, but ensuring the correctness of generated programs remains a significant challenge. Although imperfect code may be acceptable during software development with human oversight, domains such as video games and robotics require one-shot correctness for runtime-critical components. We present a constrained decoding algorithm for generating semantically correct programs that incorporates a context-sensitive parser, which, at each step, outputs a regular expression that satisfies a critical non-extensible property to guide the generation of the next token sequence that can continue to a correct program. To build such a context-sensitive parser, we propose a framework of a dynamic tree of parsers (ToP) during parsing, where each parser corresponds to a modular context-free grammar enriched with contextual information such as variable scopes and type constraints, with tree branches representing ambiguity in the future code segment. We demonstrate our approach through sLua, a strongly typed variant of Lua, showing that our method can generate semantically correct programs conforming to any prescribed scripting API. We further show that, with careful design, our semantic guarantees extend to runtime correctness, as validated in the application of generating game mechanics for a roguelike video game.

Key facts. Cited by 7 papers in the map (data through 14 Oct 2026). Builds on 9 of its 34 references that are in the map. First posted on arXiv 20 Aug 2025.

Builds on

9 of 34 references.

References · 9

  1. 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,944
  2. 2024Qwen2.5-Coder Technical Reportcited by 1,203
  3. 2019Stochastic Beams and Where to Find Them: The Gumbel-Top-k Trick for Sampling Sequences Without Replacementcited by 211
  4. 2022Synchromesh: Reliable code generation from pre-trained language modelscited by 156
  5. 2022GitHub Copilot AI pair programmer: Asset or Liability?cited by 152
  6. 2024XGrammar: Flexible and Efficient Structured Generation Engine for Large Language Modelscited by 75
  7. 2024Grammar-Aligned Decodingcited by 54
  8. 2024Automata-based constraints for language model decodingcited by 51
  9. 2025Type-Constrained Code Generation with Language Modelscited by 35

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 1; 2026: 6.

7 papers.