Python probabilistic type inference with natural language support
By Zhaogui Xu, X. Zhang, Lin Chen, Kexin Pei, Baowen Xu. 2016
108 citations recorded by the source corpus.
We propose a novel type inference technique for Python programs. Type inference is difficult for Python programs due to their heavy dependence on external APIs and the dynamic language features. We observe that Python source code often contains a lot of type hints such as attribute accesses and variable names. However, such type hints are not reliable. We hence propose to use probabilistic inference to allow the beliefs of individual type hints to be propagated, aggregated, and eventually converge on probabilities of variable types. Our results show that our technique substantially outperforms a state-of-the-art Python type inference engine based on abstract interpretation.
Subfields: Artificial Intelligence, Information Systems, Software, Natural Language Processing, Program Analysis & Verification
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Artificial Intelligence
- Luke S. Zettlemoyer
- Michael Lewis
- Percy Liang
- Hannaneh Hajishirzi
- Wen-tau Yih
- Mohit Bansal
- Greg Durrett
- Noah A. Smith
In Information Systems
- Milod Kazerounian
- Jeffrey S. Foster
- Georgios Gousios
- Satish Chandra
- Michael Pradel
- Jason Liu
- Wen-tau Yih
- Brianna M. Ren
In Software
- Georgios Gousios
- Michael Pradel
- Brianna M. Ren
- Satish Chandra
- Milod Kazerounian
- Jason Liu
- Amir M. Mir
- Eric Wallace
In Natural Language Processing
- Luke S. Zettlemoyer
- Percy Liang
- Wen-tau Yih
- Greg Durrett
- Michael Lewis
- Eric Wallace
- Hannaneh Hajishirzi
- Mohit Bansal
In Program Analysis & Verification
- Milod Kazerounian
- Jeffrey S. Foster
- Georgios Gousios
- Satish Chandra
- Jason Liu
- Brianna M. Ren
- Amir M. Mir
- Sebastian Proksch
Citations in the corpus
- InCoder: A Generative Model for Code Infilling and Synthesis (2022, methodology): “Some recent work has developed supervised machine learning approaches for predicting type annotations for dynamically-typed languages including Python [69, 6, 50] and TypeScript [31, 66, 36].”
- TypeWriter: neural type prediction with search-based validation (2019, background): “exts in which this entity occurs [15, 28]. Other approaches exploit natural language information embedded in source code, e.g., variable names or comments, as a valuable source of informal type hints [21, 37]. While existing approaches for predicting types are effective in some scenarios, they suffe”
- LambdaNet: Probabilistic Type Inference using Graph Neural Networks (2020, methodology): “l user-defined types (classes/interfaces) declared within g, and Y lib is a fixed set of commonly-used library types. Following prior work in this space (Hellendoorn et al., 2018; Raychev et al., 2015; Xu et al., 2016), we limit the scope of our prediction to non-polymorphic and non-function types. Th”
- Sound, heuristic type annotation inference for Ruby (2020, background): “[38] infer types for Python programs by building probabilistic graph models that incorporate multiple sources of information such as variable names, attribute accesses, and dataflow information.”
- OptTyper: Probabilistic Type Inference by Optimising Logical and Natural Constraints (2020, unknown): “For example, names of variables provide information about their types [Xu et al. 2016], natural language in method-level comments provide information about function types [Malik et al. 2019], and lexically nearby tokens provide information about a variable’s type [Hellendoorn et al. 2018].”
- What is decidable about gradual types? (2019, methodology): “A recent example is the inference tool for Python by Xu et al. [2016]. Static type inference also includes the foundational work by Siek and Vachharajani [2008] and Garcia and Cimini [2015].”
- Type4Py: Practical Deep Similarity Learning-Based Type Inference for Python (2021, methodology): “[64] adopt a probabilistic graphical model (PGM) to predict variable types for Python.”