Type4Py: Deep Similarity Learning-Based Type Inference for Python

ArXiv(2021)

引用 2|浏览2
暂无评分
摘要
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. However, it is still quite challenging for learningbased approaches to give a relevant prediction in the first suggestion or 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’s, respectively.
更多
查看译文
关键词
type4py,python,similarity,learning-based
AI 理解论文
溯源树
样例
生成溯源树,研究论文发展脉络
Chat Paper
正在生成论文摘要