Large Scale Generation of Labeled Type Data for Python

Ibrahim Abdelaziz, Julian Dolby, Kavitha Srinivas
1/28/2022
cs.PL

Official code: wala/graph4code (370 stars, Jupyter Notebook, EPL-2.0, last commit 2025-12-03).

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

wala/graph4codeOfficial100%
EPL-2.0

GraphGen4Code: a toolkit for creating code knowledge graphs based on WALA code analysis and extraction of documentation and forum content.

37047Jupyter Notebook, JavaApr 9, 202012 months agoEPL-2.0
code-understandingknowledge-graph

Similar Papers

Cite this paper

@article{abdelaziz2022large,
  title  = {Large Scale Generation of Labeled Type Data for Python},
  author = {Ibrahim Abdelaziz and Julian Dolby and Kavitha Srinivas},
  year   = {2022},
  eprint = {2201.12242},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2201.12242}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2201.12242.svg)](https://codeofpaper.com/paper/2201.12242)

Discussion