TypeCare: Boosting Python Type Inference Models via Context-Aware Re-Ranking and Augmentation
Wonseok Oh, Hakjoo Oh
Abstract
Type annotations improve Python code quality by enabling better readability, static analysis, and developer productivity. However, manually annotating existing code is labor-intensive and errorprone. While recent learning-based models have advanced automatic type inference, they struggle with rare or complex types that are underrepresented in training data.
We present TypeCare, a model-agnostic post-processing technique that refines the outputs of existing type inference models using code context, without requiring retraining or fine-tuning existing models. TypeCare combines two key components: (1) Re-Ranking, which prioritizes semantically and syntactically relevant types, and (2) Augmentation, which generates additional contextually plausible candidates. Applied to three state-of-the-art type inference models-TypeT5, Tiger, and TypeGen-TypeCare consistently improves top-1 accuracy, achieving up to 40.1% gains on complex types that existing models often fail to predict correctly.
• Software and its engineering → Software testing and debugging.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 529ad1b2-bfaf-426f-9af4-e0f117282c33Builds on12
- CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and GenerationYue Wang, Weishi Wang, Shafiq R. Joty, Steven C. H. HoiEMNLP 2021 · 1,224 citations
- InCoder: A Generative Model for Code Infilling and SynthesisDaniel Fried, Armen Aghajanyan, Jessy Lin, Sida Wang et al.ICLR 2023 · 140 citations
- LambdaNet: Probabilistic Type Inference using Graph Neural NetworksJiayi Wei, Maruth Goyal, Greg Durrett, Isil DilligICLR 2020 · 119 citations
- TypeWriter: neural type prediction with search-based validationMichael Pradel, Georgios Gousios, Jason Liu, Satish ChandraFSE 2020 · 102 citations
- Typilus: neural type hintsMiltiadis Allamanis, Earl T. Barr, Soline Ducousso, Zheng GaoPLDI 2020 · 92 citations
Related papers
- Automating Just-In-Time Python Type Annotation UpdatingZhipeng Xue, Zhipeng Gao, Xing Hu, Jingyuan Chen et al.ICSE 2026
- TypeT5: Seq2seq Type Inference using Static AnalysisJiayi Wei, Greg Durrett, Isil DilligICLR 2023 · 4 citations
- TIGER: A Generating-Then-Ranking Framework for Practical Python Type InferenceChong Wang, Jian Zhang, Yiling Lou, Mingwei Liu et al.ICSE 2025 · 1 citation
- PyTER: effective program repair for Python type errorsWonseok Oh, Hakjoo OhFSE 2022 · 22 citations
- Static Type Recommendation for PythonKe Sun, Yifan Zhao, Dan Hao, Lu ZhangASE 2022 · 6 citations
