mlsanityData to 7 Oct 2026

Type4Py: Practical Deep Similarity Learning-Based Type Inference for Python

arXiv 2101.04470 ↗First posted 12 Jan 2021cs.LG cs.PL cs.SEcited by 19

Not on the map. Why?

Abstract (arXiv)

Dynamic languages, such as Python and Javascript, trade static typing for developer flexibility and productivity. Lack of static typing can cause run-time exceptions and is a major factor for weak IDE support. To alleviate these issues, PEP 484 introduced optional type annotations for Python. As retrofitting types to existing codebases is error-prone and laborious, machine learning (ML)-based approaches have been proposed to enable automatic type inference based on existing, partially annotated codebases. However, previous ML-based approaches are trained and evaluated on human-provided type annotations, which might not always be sound, and hence this may limit the practicality for real-world usage. In this paper, we present Type4Py, a deep similarity learning-based hierarchical neural network model. It learns to discriminate between similar and dissimilar types in a high-dimensional space, which results in clusters of types. Likely types for arguments, variables, and return values can then be inferred through the nearest neighbor search. Unlike previous work, we trained and evaluated our model on a type-checked dataset and used mean reciprocal rank (MRR) to reflect the performance perceived by users. The obtained results show that Type4Py achieves an MRR of 77.1%, which is a substantial improvement of 8.1% and 16.7% over the state-of-the-art approaches Typilus and TypeWriter, respectively. Finally, to aid developers with retrofitting types, we released a Visual Studio Code extension, which uses Type4Py to provide ML-based type auto-completion for Python.

Key facts. Cited by 19 papers in the map (data through 7 Oct 2026). Builds on 11 of its 62 references that are in the map. First posted on arXiv 12 Jan 2021.

Builds on

11 of 62 references.

References · 11

  1. 2014Adam: A Method for Stochastic Optimizationcited by 36,960
  2. 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,160
  3. 2013Distributed Representations of Words and Phrases and their Compositionalitycited by 3,462
  4. 2015Pointer Networkscited by 882
  5. 2020On the Bottleneck of Graph Neural Networks and its Practical Implicationscited by 624
  6. 2018The Adverse Effects of Code Duplication in Machine Learning Models of Codecited by 123
  7. 2020LambdaNet: Probabilistic Type Inference using Graph Neural Networkscited by 44
  8. 2019TypeWriter: Neural Type Prediction with Search-based Validationcited by 32
  9. 2020Typilus: Neural Type Hintscited by 29
  10. 2020OptTyper: Probabilistic Type Inference by Optimising Logical and Natural Constraintscited by 14
  11. 2018Triplet-based Deep Similarity Learning for Person Re-Identificationcited by 3

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2022: 1; 2023: 7; 2024: 7; 2025: 3; 2026: 1.

19 papers.

Sort:

By area:

  1. 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 1,906
  2. 2024EffiBench: Benchmarking the Efficiency of Automatically Generated Codecited by 62
  3. 2023Bias Testing and Mitigation in LLM-based Code Generationcited by 53
  4. 2024EffiLearner: Enhancing Efficiency of Generated Code via Self-Optimizationcited by 28
  5. 2024MHPP: Exploring the Capabilities and Limitations of Language Models Beyond Basic Code Generationcited by 25
  6. 2025EffiBench-X: A Multi-Language Benchmark for Measuring Efficiency of LLM-Generated Codecited by 24
  7. 2023Deep Learning for Code Intelligence: Survey, Benchmark and Toolkitcited by 22
  8. 2024EffiCoder: Enhancing Code Generation in Large Language Models through Efficiency-Aware Fine-tuningcited by 15
  9. 2023TypeT5: Seq2seq Type Inference using Static Analysiscited by 12
  10. 2024Measuring the Influence of Incorrect Code on Test Generationcited by 9
  11. 2023LExecutor: Learning-Guided Executioncited by 7
  12. 2023Type Prediction With Program Decomposition and Fill-in-the-Type Trainingcited by 6
7 more
  1. 2025Treefix: Enabling Execution with a Tree of Prefixescited by 2
  2. 2022Cross-Domain Evaluation of a Deep Learning-Based Type Inference Systemcited by 1
  3. 2023An Exploratory Literature Study on Sharing and Energy Use of Language Models for Source Codecited by 1
  4. 2023DocGen: Generating Detailed Parameter Docstrings in Pythoncited by 0
  5. 2024Inferring Pluggable Types with Machine Learningcited by 0
  6. 2025Automated Type Annotation in Python Using Large Language Modelscited by 0
  7. 2026AgentExecutor: Partial Code Execution via Agentic Context Generationcited by 0