TypePro: Boosting LLM-Based Type Inference via Inter-Procedural Slicing
Teyu Lin, Minghao Fan, Huaxun Huang, Zhirong Shen, Rongxin Wu

TL;DR
TypePro enhances LLM-based type inference for dynamic languages by using inter-procedural code slicing to provide richer context, significantly improving accuracy over existing methods.
Contribution
It introduces inter-procedural slicing to supplement context for LLMs, enabling more accurate type inference in dynamic languages.
Findings
Achieved Top-1 EM rates of 88.9% on ManyTypes4Py and 86.6% on ManyTypes4TypeScript.
Improved Top-1 EM by 7.1 and 10.3 percentage points over the second-best approach.
Demonstrated effectiveness and robustness of TypePro through extensive experiments.
Abstract
Dynamic languages (such as Python and JavaScript) offer flexibility and simplified type handling for programming, but this can also lead to an increase in type-related errors and additional overhead for compile-time type inference. As a result, type inference for dynamic languages has become a popular research area. Existing approaches typically achieve type inference through static analysis, machine learning, or large language models (LLMs). However, current work only focuses on the direct dependencies of variables related to type inference as the context, resulting in incomplete contextual information and thus affecting the accuracy of type inference. To address this issue, this paper proposes a method called TypePro, which leverages LLMs for type inference in dynamic languages. TypePro supplements contextual information by conducting inter-procedural code slicing. Then, TypePro…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
