Static Inference Meets Deep Learning: A Hybrid Type Inference Approach for Python
Not on the map. Why?
Abstract (arXiv)
Type inference for dynamic programming languages such as Python is an important yet challenging task. Static type inference techniques can precisely infer variables with enough static constraints but are unable to handle variables with dynamic features. Deep learning (DL) based approaches are feature-agnostic, but they cannot guarantee the correctness of the predicted types. Their performance significantly depends on the quality of the training data (i.e., DL models perform poorly on some common types that rarely appear in the training dataset). It is interesting to note that the static and DL-based approaches offer complementary benefits. Unfortunately, to our knowledge, precise type inference based on both static inference and neural predictions has not been exploited and remains an open challenge. In particular, it is hard to integrate DL models into the framework of rule-based static approaches. This paper fills the gap and proposes a hybrid type inference approach named HiTyper based on both static inference and deep learning. Specifically, our key insight is to record type dependencies among variables in each function and encode the dependency information in type dependency graphs (TDGs). Based on TDGs, we can easily integrate type inference rules in the nodes to conduct static inference and type rejection rules to inspect the correctness of neural predictions. HiTyper iteratively conducts static inference and DL-based prediction until the TDG is fully inferred. Experiments on two benchmark datasets show that HiTyper outperforms state-of-the-art DL models by exactly matching 10% more human annotations. HiTyper also achieves an increase of more than 30% on inferring rare types. Considering only the static part of HiTyper, it infers 2x ~ 3x more types than existing static type inference tools.
Key facts. Cited by 12 papers in the map (data through 7 Oct 2026). First posted on arXiv 8 May 2021.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2022: 2; 2023: 5; 2024: 4; 2025: 1.
12 papers.
- 2024Reasoning Runtime Behavior of a Program with LLM: How Far Are We?cited by 44
- 2024Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completioncited by 40
- 2023TypeT5: Seq2seq Type Inference using Static Analysiscited by 12
- 2023ChatGPT: A Study on its Utility for Ubiquitous Software Engineering Taskscited by 12
- 2022AutoPruner: Transformer-Based Call Graph Pruningcited by 11
- 2022CodeQueries: A Dataset of Semantic Queries over Codecited by 11
- 2023LExecutor: Learning-Guided Executioncited by 7
- 2024An Empirical Study on Large Language Models in Accuracy and Robustness under Chinese Industrial Scenarioscited by 3
- 2025Call Me Maybe: Enhancing JavaScript Call Graph Construction using Graph Neural Networkscited by 1
- 2023Learning Type Inference for Enhanced Dataflow Analysiscited by 0
- 2023DocGen: Generating Detailed Parameter Docstrings in Pythoncited by 0
- 2024Inferring Pluggable Types with Machine Learningcited by 0
- 2025Call Me Maybe: Enhancing JavaScript Call Graph Construction using Graph Neural Networks22 Jun 2025
- 2024Inferring Pluggable Types with Machine Learning21 Jun 2024
- 2024Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completion30 May 2024
- 2024Reasoning Runtime Behavior of a Program with LLM: How Far Are We?25 Mar 2024
- 2024An Empirical Study on Large Language Models in Accuracy and Robustness under Chinese Industrial Scenarios27 Jan 2024
- 2023DocGen: Generating Detailed Parameter Docstrings in Python11 Nov 2023
- 2023Learning Type Inference for Enhanced Dataflow Analysis1 Oct 2023
- 2023ChatGPT: A Study on its Utility for Ubiquitous Software Engineering Tasks26 May 2023
- 2023TypeT5: Seq2seq Type Inference using Static Analysis16 Mar 2023
- 2023LExecutor: Learning-Guided Execution5 Feb 2023
- 2022CodeQueries: A Dataset of Semantic Queries over Code17 Sep 2022
- 2022AutoPruner: Transformer-Based Call Graph Pruning7 Sep 2022