The Alignment Problem in Constrained Code Generation
Not on the map. Why?
Abstract (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 proposed as a solution to mitigate compilation errors by construction, improving functional correctness as a byproduct. However, previous works overlook a critical aspect of constrained decoding: the alignment between constrainer (e.g., types), language model and the target specification language (e.g., TypeScript). Misalignment is caused by the constrainer being incomplete--rejecting programs that belong to the target--or unsound--allowing programs that are not part of the target. The bias created by incompleteness distorts the language model distribution, and can be detrimental for code generation. We evaluate this hypothesis using seven language models, two target languages, two constrainers, enforcing types and syntax during decoding, and we study how language models react to varying levels of incompleteness. On three benchmarks, when the constrainer is incomplete, unconstrained decoding significantly outperforms constrained decoding in terms of functional correctness. Incompleteness pushes the model into low-probability regions of the program space, causing the generation to frequently time out, and reducing functional correctness by up to 97%. These contributions make the community aware of the negative effects of misalignment in constrained decoding, and provide quantitative insights on how to design constrainers that are beneficial for code generation systems with formal guarantees.
Key facts. Cited by 1 paper in the map (data through 7 Oct 2026). Builds on 22 of its 41 references that are in the map. First posted on arXiv 19 Jun 2026.
Builds on
22 of 41 references.
References · 22
- 2017Attention Is All You Needcited by 59,932
- 2024DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Modelscited by 8,851
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
- 2025Small Language Models are the Future of Agentic AIcited by 254
- 2023Efficient Guided Generation for Large Language Modelscited by 192
- 2023Grammar-Constrained Decoding for Structured NLP Tasks without Finetuningcited by 186
- 2023An Empirical Study of the Non-determinism of ChatGPT in Code Generationcited by 134
- 2024SynCode: LLM Generation with Grammar Augmentationcited by 66
10 more
- 2025Flexible and Efficient Grammar-Constrained Decodingcited by 42
- 2025Type-Constrained Code Generation with Language Modelscited by 32
- 2025Constrained Sampling for Language Models Should Be Easy: An MCMC Perspectivecited by 14
- 2025Constrained Decoding of Diffusion LLMs with Context-Free Grammarscited by 13
- 2025ChopChop: a Programmable Framework for Semantically Constraining the Output of Language Modelscited by 12
- 2024PyTy: Repairing Static Type Errors in Pythoncited by 10
- 2025Enhancing Code Generation for Low-Resource Languages: No Silver Bulletcited by 9
- 2025Assessing Small Language Models for Code Generation: An Empirical Study with Benchmarkscited by 8
- 2025LLM-Based Repair of Static Nullability Errorscited by 2
- 2021Union and intersection contracts are hard, actuallycited by 1
Built on by
Citing papers per year: 2026: 1.
1 paper.
Similar, not cited
Close in wording, no citation either way
- 2026Constrained Decoding Eliminates Structural Failures in Small LLMs but Reveals a Scale-Dependent Semantic Gap
- 2024Assessing Code Generation with Intermediate Languages
- 2025Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generation
- 2024Assessing, Exploiting, and Mitigating Syntactic Robustness Failures in LLM-Based Code Generation
- 2026Constraint Decay: The Fragility of LLM Agents in Backend Code Generation
- 2025Holistic Evaluation of State-of-the-Art LLMs for Code Generation
- 2023Enhancing Large Language Models in Coding Through Multi-Perspective Self-Consistency
- 2026Reward-Free Code Alignment from Pretrained or Fine-Tuned LLM: Unpacking the Trade-offs for Code Generation