Pith. sign in

REVIEW 3 cited by

Type-Constrained Code Generation with Language Models

Not yet reviewed by Pith; the record is open.

This paper has not been read by Pith yet. Machine review is queued; the pith claim, tier, and objections will appear here once it completes.

SPECIMEN: schema-true, not a live event

T0 review · schema-true

One-sentence machine reading of the paper's core claim.

pith:XXXXXXXX · record.json · timestamp

arxiv 2504.09246 v2 pith:5FHUUCHF submitted 2025-04-12 cs.LG cs.PL

classification cs.LGcs.PL
keywords codeapproachgenerationlanguagellmsmodelsdecodingdemonstrate
verification ladder T0 review T1 audit T2 compute T3 formal
0 comments
read the original abstract

Large language models (LLMs) have achieved notable success in code generation. However, they still frequently produce uncompilable output because their next-token inference procedure does not model formal aspects of code. Although constrained decoding is a promising approach to alleviate this issue, it has only been applied to handle either domain-specific languages or syntactic features of general-purpose programming languages. However, LLMs frequently generate code with typing errors, which are beyond the domain of syntax and generally hard to adequately constrain. To address this challenge, we introduce a type-constrained decoding approach that leverages type systems to guide code generation. For this purpose, we develop novel prefix automata and a search over inhabitable types, forming a sound approach to enforce well-typedness on LLM-generated code. We formalize our approach on a foundational simply-typed language and extend it to TypeScript to demonstrate practicality. Our evaluation on the HumanEval and MBPP datasets shows that our approach reduces compilation errors by more than half and significantly increases functional correctness in code synthesis, translation, and repair tasks across LLMs of various sizes and model families, including state-of-the-art open-weight models with more than 30B parameters. The results demonstrate the generality and effectiveness of our approach in constraining LLM code generation with formal rules of type systems.

Discussion (0). Sign in to comment.

Forward citations

Cited by 3 Pith papers

Reviewed papers in the Pith corpus that reference this work. Sorted by Pith novelty score. Full citation record

  1. Implementing Grassroots Logic Programs with Multiagent Transition Systems and AI (Full Version)

    cs.PL 2026-02 unverdicted novelty 6.0 of 10

    dGLP and madGLP are deterministic, implementation-ready semantics for Grassroots Logic Programs, proved correct against the abstract nondeterministic semantics.

  2. Moded Types for Grassroots Logic Programs, by AI, for AI (Full Version)

    cs.PL 2026-01 conditional novelty 5.0 of 10

    Well-typed Grassroots Logic Programs are claimed to produce only values matching their declared moded types and to accept all inputs those types permit, verified through a moded-atom semantics.

  3. Position Paper: Programming Language Techniques for Bridging LLM Code Generation Semantic Gaps

    cs.SE 2025-07 unverdicted novelty 2.0 of 10

    A position paper arguing that PL techniques, especially formal verification and structure-aware representations, should be deeply integrated into LLM code generation.

Pith tools