1 Hit in 0.37 sec

Type4Py: Deep Similarity Learning-Based Type Inference for Python [article]

Amir M. Mir, Evaldas Latoskinas, Sebastian Proksch, Georgios Gousios
2021 arXiv   pre-print
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, learning-based approaches have been proposed to enable automatic type annotations based on existing, partially annotated codebases.
more » ... However, it is still quite challenging for learning-based approaches to give a relevant prediction in the first suggestion or the first few ones. In this paper, we present Type4Py, a deep similarity learning-based hierarchical neural network model that learns to discriminate between types of the same kind and dissimilar types in a high-dimensional space, which results in clusters of types. Nearest neighbor search suggests a list of likely types for arguments, variables, and functions' return. The results of the quantitative and qualitative evaluation indicate that Type4Py significantly outperforms state-of-the-art approaches at the type prediction task. Considering the Top-1 prediction, Type4Py obtains a Mean Reciprocal Rank of 72.5%, which is 10.87% and 16.45% higher than that of Typilus and TypeWriter, respectively.
arXiv:2101.04470v2 fatcat:wdyshjbse5ba3o2akw3btluncy