arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.15676cs.SEcs.AI
收藏

利用机器学习推断可插拔类型

Inferring Pluggable Types with Machine Learning

New Jersey Institute of Technology(新泽西理工学院)

Kazi Amanul Islam Siddiqui, Martin Kellogg

AI总结:

针对可插拔类型系统需手动注解难以部署到遗留代码库的问题,提出NaP-AST表示编码数据流提示,评估多种模型推断类型限定符,验证发现GTN性能最优,并探究了模型性能与Java类数量的关系。

摘要:

可插拔类型系统允许程序员扩展编程语言的类型系统,以强制执行由程序员定义的语义属性。这类系统难以在遗留代码库中部署,因为它们要求程序员手动编写类型注解。本文研究了如何利用机器学习自动推断类型限定符。我们提出了一种新颖的表示形式NaP-AST,它编码最小化的数据流提示,以实现类型限定符的有效推断。我们评估了多种用于推断类型限定符的模型架构,包括Graph Transformer Network(图Transformer网络)、Graph Convolutional Network(图卷积网络)和Large Language Model(大语言模型)。我们进一步将这些模型应用于来自NullAway可插拔类型检查器先前评估的12个开源程序进行验证,结果显示除一个未注解项目外,其余所有项目的警告数均有所降低。我们发现GTN表现最佳,召回率为0.89,精确率为0.6。此外,我们开展了一项研究,估算训练模型达到良好性能所需的Java类数量。在我们的可行性研究中,模型性能在约1.6万个类时得到提升,在约2.2万个类时因过拟合而下降。

英文摘要:

Pluggable type systems allow programmers to extend the type system of a programming language to enforce semantic properties defined by the programmer. Pluggable type systems are difficult to deploy in legacy codebases because they require programmers to write type annotations manually. This paper investigates how to use machine learning to infer type qualifiers automatically. We propose a novel representation, NaP-AST, that encodes minimal dataflow hints for the effective inference of type qualifiers. We evaluate several model architectures for inferring type qualifiers, including Graph Transformer Network, Graph Convolutional Network and Large Language Model. We further validated these models by applying them to 12 open-source programs from a prior evaluation of the NullAway pluggable typechecker, lowering warnings in all but one unannotated project. We discovered that GTN shows the best performance, with a recall of .89 and precision of 0.6. Furthermore, we conduct a study to estimate the number of Java classes needed for good performance of the trained model. For our feasibility study, performance improved around 16k classes, and deteriorated due to overfitting around 22k classes.

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

↑