paper-with-me

Papers

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

2021-01-12 · Amir M. Mir, Evaldas Latoskinas, Sebastian Proksch, Georgios Gousios

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.

📄 PDF Abstract BibTeX arXiv:2101.04470

Code (1)

saltudelft/type4py 공식 구현 pytorch

Tasks

Type predictionVocal Bursts Type Prediction

Similar Papers 제목 키워드 기반

TypyBench: Evaluating LLM Type Inference for Untyped Python Repositories

2025-07-28 · Honghua Dong, Jiacheng Yang, Xun Deng, Yuhe Jiang 외 arxiv

Type inference for dynamic languages like Python is a persistent challenge in software engineering. While large language models (LLMs) have shown promise in code understanding, their type inference capabilities remain un…

ManyTypes4Py: A Benchmark Python Dataset for Machine Learning-based Type Inference

2021-04-10 · Amir M. Mir, Evaldas Latoskinas, Georgios Gousios

In this paper, we present ManyTypes4Py, a large Python dataset for machine learning (ML)-based type inference. The dataset contains a total of 5,382 Python projects with more than 869K type annotations. Duplicate source …

BIG-bench Machine LearningVocal Bursts Type Prediction

DLTPy: Deep Learning Type Inference of Python Function Signatures using Natural Language Context

2019-12-02 · Casper Boone, Niels de Bruin, Arjan Langerak, Fabian Stelmach

Due to the rise of machine learning, Python is an increasingly popular programming language. Python, however, is dynamically typed. Dynamic typing has shown to have drawbacks when a project grows, while at the same time …

Typilus: Neural Type Hints

2020-04-06 · Miltiadis Allamanis, Earl T. Barr, Soline Ducousso, Zheng Gao

Type inference over partial contexts in dynamically typed languages is challenging. In this work, we present a graph neural network model that predicts types by probabilistically reasoning over a program's structure, nam…

Graph Neural NetworkOne-Shot LearningVocal Bursts Type Prediction

ManyTypes4TypeScript: A Comprehensive TypeScript Dataset for Sequence-Based Type Inference

2022-10-17 · International Conference on Mining Software Repositories 2022 10 · Kevin Jesse, Premkumar T. Devanbu

In this paper, we present ManyTypes4TypeScript, a very large corpus for training and evaluating machine-learning models for sequence-based type inference in TypeScript. The dataset includes over 9 million type annotat…

Type prediction