There has been growing interest in automatically predicting missing type annotations in programs written in Python and JavaScript. While prior methods have achieved impressive accuracy when predicting the most common types, they often perform poorly on rare or complex types. In this paper, we present a new type inference method that treats type prediction as a code infilling task by leveraging CodeT5, a state-of-the-art seq2seq pre-trained language model for code. Our method uses static analysis to construct dynamic contexts for each code element whose type signature is to be predicted by the model. We also propose an iterative decoding scheme that incorporates previous type predictions in the model's input context, allowing information exchange between related code elements. Our evaluation shows that the proposed approach, TypeT5, not only achieves a higher overall accuracy (particularly on rare and complex types) but also produces more coherent results with fewer type errors -- while enabling easy user intervention.


翻译:近年来,自动预测Python和JavaScript程序中缺失的类型标注引起了广泛关注。虽然先前的方法在预测最常见类型时达到了令人印象深刻的准确性,但它们往往在罕见或复杂类型上表现不佳。本文提出了一种新的类型推断方法,该方法利用CodeT5(一种用于代码的最先进seq2seq预训练语言模型),将类型预测视为代码填充任务。我们的方法通过静态分析为模型需要预测类型签名的每个代码元素构建动态上下文。我们还提出了一种迭代解码方案,将先前的类型预测融入模型的输入上下文中,从而允许相关代码元素之间的信息交换。评估结果表明,所提出的TypeT5方法不仅实现了更高的整体准确性(特别是在罕见和复杂类型上),而且生成了更为一致的结果,减少了类型错误——同时便于用户干预。

0
下载
关闭预览

相关内容

NeurlPS 2022 | 自然语言处理相关论文分类整理
专知会员服务
51+阅读 · 2022年10月2日
【Google-BryanLim等】可解释深度学习时序预测
专知会员服务
64+阅读 · 2021年12月19日
知识增强预训练语言模型:全面综述
专知会员服务
97+阅读 · 2021年10月19日
Transformer文本分类代码
专知会员服务
118+阅读 · 2020年2月3日
【干货】用BRET进行多标签文本分类(附代码)
专知会员服务
85+阅读 · 2019年12月27日
使用BERT做文本摘要
专知
23+阅读 · 2019年12月7日
Transferring Knowledge across Learning Processes
CreateAMind
29+阅读 · 2019年5月18日
LibRec 精选:推荐系统的常用数据集
LibRec智能推荐
17+阅读 · 2019年2月15日
在Python中使用SpaCy进行文本分类
专知
24+阅读 · 2018年5月8日
【推荐】GAN架构入门综述(资源汇总)
机器学习研究会
10+阅读 · 2017年9月3日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
2+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2008年12月31日
Arxiv
0+阅读 · 2023年5月8日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
8+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
10+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
6+阅读 · 6月17日
相关基金
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
2+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2008年12月31日
Top
微信扫码咨询专知VIP会员