Constrained Decoding for Fill-in-the-Middle Code Language Models via Efficient Left and Right Quotienting of Context-Sensitive Grammars
Not on the map. Why?
Abstract (arXiv)
Large Language Models are powerful tools for program synthesis and advanced auto-completion, but come with no guarantee that their output code is syntactically correct. This paper contributes an incremental parser that allows early rejection of syntactically incorrect code, as well as efficient detection of complete programs for fill-in-the-middle (FIM) tasks. We extend the Earley parsing algorithm to allow for left and right quotients of context-free grammars, and develop methods to handle quotienting of several context-sensitive features present in the grammars of many common programming languages. The result of these contributions is an efficient, general, and well-grounded method for left and right quotient parsing. To validate our theoretical contributions -- and the effectiveness of certain design decisions -- we evaluate our method on the particularly difficult case of FIM completion for Python 3, with syntax-correctness constraints. Our results demonstrate that constrained generation can significantly reduce the incidence of syntax errors in recommended code.
Key facts. Cited by 8 papers in the map (data through 14 Oct 2026). Builds on 10 of its 27 references that are in the map. First posted on arXiv 28 Feb 2024.
Builds on
10 of 27 references.
References · 10
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2022The Stack: 3 TB of permissively licensed source codecited by 359
- 2022Efficient Training of Language Models to Fill in the Middlecited by 255
- 2023Efficient Guided Generation for Large Language Modelscited by 200
- 2020Code Prediction by Feeding Trees to Transformerscited by 70
- 2019Pythia: AI-assisted Code Completion Systemcited by 55
- 2017Code Completion with Neural Attention and Pointer Networkscited by 49
- 2021Neural Program Generation Modulo Static Analysiscited by 13
- 2022Syntax-Aware On-the-Fly Code Completioncited by 10
Built on by
Citing papers per year: 2024: 1; 2025: 3; 2026: 4.
8 papers.
- 2024SynCode: LLM Generation with Grammar Augmentationcited by 69
- 2025CRANE: Reasoning with constrained LLM generationcited by 38
- 2025Type-Constrained Code Generation with Language Modelscited by 35
- 2025Constrained Decoding of Diffusion LLMs with Context-Free Grammarscited by 14
- 2026An Empirical Analysis of Static Analysis Methods for Detection and Mitigation of Code Library Hallucinationscited by 0
- 2026OCELOT: Inference-Leakage Budgets for Privacy-Preserving LLM Agentscited by 0
- 2026Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Codecited by 0
- 2026Specification-Guided Synthesis of Deadlock-Free Communication Protocol Refinements with Large Language Modelscited by 0
- 2026Specification-Guided Synthesis of Deadlock-Free Communication Protocol Refinements with Large Language Models30 Jul 2026
- 2026Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Code15 Jul 2026
- 2026OCELOT: Inference-Leakage Budgets for Privacy-Preserving LLM Agents10 Jun 2026
- 2026An Empirical Analysis of Static Analysis Methods for Detection and Mitigation of Code Library Hallucinations9 Apr 2026
- 2025Constrained Decoding of Diffusion LLMs with Context-Free Grammars13 Aug 2025
- 2025Type-Constrained Code Generation with Language Models12 Apr 2025
- 2025CRANE: Reasoning with constrained LLM generation13 Feb 2025
- 2024SynCode: LLM Generation with Grammar Augmentation3 Mar 2024