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

Python标记类型数据的大规模生成

Large Scale Generation of Labeled Type Data for Python

Ibrahim Abdelaziz, Julian Dolby, Kavitha Srinivas

摘要:

最近,动态类型语言(如Python)获得了前所未有的普及。虽然这些语言减轻了对强制类型注释的需求,但类型在程序理解和防止运行时错误方面仍然扮演着关键角色。一个有吸引力的选择是自动推断类型以获得静态保证而无需编写类型。现有的推理技术主要依赖于静态类型工具,如PyType进行直接类型推断;最近,神经类型推断已经被提出。然而,神经类型推断是数据饥渴的,并且依赖于基于静态类型化收集标记数据。然而,这样的工具在推断用户定义的类型方面很差。此外,开发人员在这些语言中的类型注释非常稀少。在这项工作中,我们提出了新的技术,用于生成高质量的类型,使用1)信息检索技术,工作在有据可查的图书馆提取类型和2)使用模式,通过分析一个大的存储库的程序。我们的研究结果表明,这些技术更精确,解决了静态工具的弱点,并可以用于生成一个大的标记数据集的类型推断的机器学习方法。我们的技术的F1得分为0.52-0.58,而静态类型工具的得分为0.06,我们使用它们为700多个模块生成了37,000多个类型。

英文摘要:

Recently, dynamically typed languages, such as Python, have gained unprecedented popularity. Although these languages alleviate the need for mandatory type annotations, types still play a critical role in program understanding and preventing runtime errors. An attractive option is to infer types automatically to get static guarantees without writing types. Existing inference techniques rely mostly on static typing tools such as PyType for direct type inference; more recently, neural type inference has been proposed. However, neural type inference is data hungry, and depends on collecting labeled data based on static typing. Such tools, however, are poor at inferring user defined types. Furthermore, type annotation by developers in these languages is quite sparse. In this work, we propose novel techniques for generating high quality types using 1) information retrieval techniques that work on well documented libraries to extract types and 2) usage patterns by analyzing a large repository of programs. Our results show that these techniques are more precise and address the weaknesses of static tools, and can be useful for generating a large labeled dataset for type inference by machine learning methods. F1 scores are 0.52-0.58 for our techniques, compared to static typing tools which are at 0.06, and we use them to generate over 37,000 types for over 700 modules.

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

↑