arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2005.02161cs.PLcs.LGstat.ML
收藏

LambdaNet:基于图神经网络的概率类型推断

LambdaNet: Probabilistic Type Inference using Graph Neural Networks

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

Jiayi Wei, Maruth Goyal, Greg Durrett, Isil Dillig

摘要:

随着渐进式类型在Python和TypeScript等语言中越来越流行,自动推断类型注释的需求越来越大。虽然类型注释有助于完成代码完成和静态错误捕获等任务,但这些注释不能完全由编译器确定,并且手工注释很繁琐。提出了一种基于图神经网络的TypeScript概率类型推断方案。我们的方法首先使用轻量级的源代码分析生成一个程序抽象称为类型依赖图,它链接类型变量与逻辑约束以及名称和使用信息。给定这个程序抽象,然后我们使用图神经网络在相关类型变量之间传播信息,并最终进行类型预测。我们的神经架构既可以预测数字或字符串等标准类型,也可以预测在训练过程中没有遇到的用户定义类型。我们的实验结果表明,我们的方法优于以前的工作在这个空间中的$14\%$(绝对)库类型,同时有能力作出类型预测,是现有技术的范围之外。

英文摘要:

As gradual typing becomes increasingly popular in languages like Python and TypeScript, there is a growing need to infer type annotations automatically. While type annotations help with tasks like code completion and static error catching, these annotations cannot be fully determined by compilers and are tedious to annotate by hand. This paper proposes a probabilistic type inference scheme for TypeScript based on a graph neural network. Our approach first uses lightweight source code analysis to generate a program abstraction called a type dependency graph, which links type variables with logical constraints as well as name and usage information. Given this program abstraction, we then use a graph neural network to propagate information between related type variables and eventually make type predictions. Our neural architecture can predict both standard types, like number or string, as well as user-defined types that have not been encountered during training. Our experimental results show that our approach outperforms prior work in this space by $14\%$ (absolute) on library types, while having the ability to make type predictions that are out of scope for existing techniques.

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

↑