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.


翻译:语言模型在代码生成方面展现出卓越的能力;然而,确保类型正确性仍然是一个挑战。尽管传统方法(如约束解码)通过外部拒绝不可类型化的代码来缓解此问题,但模型本身并未在内部有效学习类型推理,这最终限制了其整体性能。本文提出TyFlow,一种新颖的系统,将类型推理内化于代码生成过程中,以引导模型学习类型系统。我们方法的核心是一个创新的类型引导程序合成系统,该系统维持类型推导树与合成推导树之间的同构关系,从而实现了基于合成决策序列而非传统基于文本的标记序列的新代码表示。通过将类型系统学习的复杂性转移到表示本身,模型能够将其计算资源重新导向更高层次的程序语义。我们的评估表明,TyFlow不仅消除了类型错误,还显著提升了功能正确性,突显了在内部将语言模型与类型系统对齐的重要性。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
生成模型中持续学习的综合综述
专知会员服务
25+阅读 · 2025年6月17日
通过强化学习增强代码生成中的代码大语言模型:综述
专知会员服务
29+阅读 · 2025年1月1日
《大型语言模型代码生成》综述
专知会员服务
68+阅读 · 2024年6月4日
【MIT博士论文】保证性生成模型,155页pdf
专知会员服务
31+阅读 · 2023年8月8日
绝对干货!NLP预训练模型:从transformer到albert
新智元
13+阅读 · 2019年11月10日
深度学习文本分类方法综述(代码)
中国人工智能学会
28+阅读 · 2018年6月16日
展望:模型驱动的深度学习
人工智能学家
12+阅读 · 2018年1月23日
手把手教TensorFlow(附代码)
深度学习世界
15+阅读 · 2017年10月17日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
10+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
7+阅读 · 2015年12月31日
国家自然科学基金
12+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
VIP会员
相关基金
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
10+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
7+阅读 · 2015年12月31日
国家自然科学基金
12+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
Top
微信扫码咨询专知VIP会员