arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2303.09564cs.SEcs.LGcs.PL
收藏

TypeT5:使用静态分析的Seq2seq类型推断

TypeT5: Seq2seq Type Inference using Static Analysis

University of Texas at Austin(德克萨斯大学奥斯汀分校)

Jiayi Wei, Greg Durrett, Isil Dillig

摘要:

在用Python和JavaScript编写的程序中,自动预测缺少的类型注释的兴趣越来越大。虽然先前的方法在预测最常见的类型时已经达到了令人印象深刻的准确性,但它们在罕见或复杂的类型上往往表现不佳。在本文中,我们提出了一种新的类型推断方法,将类型预测作为一个代码填充任务,利用CodeT5,一个国家的最先进的seq2seq预训练的语言模型的代码。我们的方法使用静态分析来构造动态上下文的类型签名是由模型预测的每个代码元素。我们还提出了一个迭代解码方案,将以前的类型预测模型的输入上下文中,允许相关的代码元素之间的信息交换。我们的评估表明,所提出的方法TypeT5不仅实现了更高的整体准确性(特别是在罕见和复杂的类型上),而且还产生了更一致的结果,类型错误更少,同时便于用户干预。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑