Learning to Guarantee Type Correctness in Code Generation through Type-Guided Program Synthesis
Not on the map. Why?
Abstract (arXiv)
Language models have shown remarkable proficiency in code generation; nevertheless, ensuring type correctness remains a challenge. Although traditional methods, such as constrained decoding, alleviate this problem by externally rejecting untypable code, the model itself does not effectively learn type reasoning internally, which ultimately limits its overall performance. This paper introduces TyFlow, a novel system that internalizes type reasoning within code generation to guide the model to learn the type system. The core of our approach is a novel type-guided program synthesis system that maintains an isomorphism between type derivation trees and synthesis derivation trees, enabling a new code representation based on synthesis decision sequences rather than traditional text-based token sequences. By offloading the complexity of type system learning to the representation itself, models can redirect their computational resources toward higher-level program semantics. Our evaluation shows that TyFlow not only eliminates type errors but also significantly improves functional correctness, highlighting the importance of aligning LMs with type systems internally.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 20 of its 42 references that are in the map. First posted on arXiv 11 Oct 2025.
Builds on
20 of 42 references.
References · 20
- 2017Attention Is All You Needcited by 59,932
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2022Competition-Level Code Generation with AlphaCodecited by 1,427
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2024LongBench v2: Towards Deeper Understanding and Reasoning on Realistic Long-context Multitaskscited by 367
- 2022A Systematic Evaluation of Large Language Models of Codecited by 360
- 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 294
- 2017Beam Search Strategies for Neural Machine Translationcited by 232
- 2024SynCode: LLM Generation with Grammar Augmentationcited by 66
- 2024Bugs in Large Language Models Generated Code: An Empirical Studycited by 59
- 2019TreeGen: A Tree-Based Transformer Architecture for Code Generationcited by 58
8 more
- 2024What's Wrong with Your Code Generated by Large Language Models? An Extensive Studycited by 52
- 2025Type-Constrained Code Generation with Language Modelscited by 32
- 2015Program Synthesis from Polymorphic Refinement Typescited by 20
- 2023Efficient Avoidance of Vulnerabilities in Auto-completed Smart Contract Code Using Vulnerability-constrained Decodingcited by 14
- 2025Grammar-Based Code Representation: Is It a Worthy Pursuit for LLMs?cited by 5
- 2019Program Synthesis by Type-Guided Abstraction Refinementcited by 3
- 2021RbSyn: Type- and Effect-Guided Program Synthesiscited by 1
- 2025GramTrans: A Better Code Representation Approach in Code Generationcited by 1
Built on by
Not cited yet.