paper-with-me

Papers

Correctness-Guaranteed Code Generation via Constrained Decoding

2025-08-20 · Lingxiao Li, Salar Rahili, Yiwei Zhao 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.

📄 PDF Abstract BibTeX arXiv:2508.15866

Code (0)

등록된 구현이 없습니다.

Tasks

Code Generation

Similar Papers 제목 키워드 기반

Constrained Decoding of Diffusion LLMs with Context-Free Grammars

2025-08-13 · Niels Mündler, Jasper Dekoninck, Martin Vechev arxiv

Large language models (LLMs) have shown promising performance across diverse domains. Many practical applications of LLMs, such as code completion and structured data extraction, require adherence to syntactic constraint…

Code Completion

The Alignment Problem in Constrained Code Generation

2026-06-19 · Matteo Biagiola, Jahrim Gabriele Cesario, Luca Di Grazia, George Zakhour 외 arxiv

Large Language Models (LLMs) have demonstrated strong capabilities in code generation, but their outputs frequently contain syntax or type errors that result in compilation failures. Constrained decoding has been propose…

Code Generation

Constrained Decoding for Secure Code Generation

2024-04-30 · Yanjun Fu, Ethan Baker, Yu Ding, Yizheng Chen

Code Large Language Models (Code LLMs) have been increasingly used by developers to boost productivity, but they often generate vulnerable code. Thus, there is an urgent need to ensure that code generated by Code LLMs is…

Code Generation

CRANE: Reasoning with constrained LLM generation

2025-02-13 · Debangshu Banerjee, Tarun Suresh, Shubham Ugare, Sasa Misailovic 외

Code generation, symbolic math reasoning, and other tasks require LLMs to produce outputs that are both syntactically and semantically correct. Constrained LLM generation is a promising direction to enforce adherence to …

Code GenerationMathvalid

TreeCoder: Systematic Exploration and Optimisation of Decoding and Constraints for LLM Code Generation

2025-11-27 · Henrijs Princis, Arindam Sharma, Cristina David arxiv

Large language models (LLMs) have shown remarkable ability to generate code, yet their outputs often violate syntactic or semantic constraints when guided only through natural language prompts. We introduce TreeCoder, th…

Prompt EngineeringCode Generation