paperbot · PL 论文追踪

全部论文 待读 收藏

P2 DLInfer: Deep Learning with Static Slicing for Python Type Inference

DLInfer:结合静态切片的深度学习用于 Python 类型推断
ICSE 2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE)2023匹配度 4/10 · 该论文属于将深度学习用于程序分析(Python 类型推断)的方向,与“AI→PL”有部分交集;但其核心采用的是静态切片加双向 GRU,并非基于当前 LLM/Agent,也未涉及浮点程序分析、贝叶斯程序分析或 Agentic 程序静态分析,因此与用户当前研究画像的核心问题距离较远。引用 17 inbox
Yanyan Yan, Yang Feng, Hongcheng Fan, Baowen Xu
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出 DLInfer,用静态切片与双向 GRU 深度学习模型自动推断 Python 变量类型,Top-1 准确率达 98.79%。

Python 的动态类型特性虽提升开发效率,却给软件维护与质量保证带来挑战,而手动类型标注成本高且易出错。本文提出 DLInfer,一种基于深度学习的自动类型推断技术。它首先通过静态分析为变量收集切片语句,并利用 Unigram 语言模型算法将其向量化;随后设计双向门控循环单元(GRU)模型学习类型传播信息以完成推断。作者在 700 个开源项目上开展实证研究,评估对内置类型、库类型和用户自定义类型三类基本类型的推断准确率。实验表明,对于可通过静态分析和手动标注获得类型信息的变量,DLInfer 平均 Top-1 准确率达到 98.79%;对于仅能通过动态分析获得类型信息的变量,其平均推断准确率也达到 83.03%。结果说明 DLInfer 能高效推断类型,有望辅助多种 Python 软件工程任务。

问题
Python 的动态类型特性使类型信息缺失,导致软件维护和质量保证困难,而手动类型标注耗费大量资源且可能引入错误。
方法
通过静态分析为变量收集切片语句,使用 Unigram 语言模型算法向量化,并设计双向 GRU 模型学习类型传播信息进行类型推断。
评估
在 700 个开源项目上评估对内置、库和用户自定义三类基本类型的推断准确率;静态可推断变量平均 Top-1 准确率 98.79%,仅动态分析可得类型的变量平均准确率 83.03%。
原文摘要(Abstract)

Python programming language has gained enor-mous popularity in the past decades. While its flexibility signifi-cantly improves software development productivity, the dynamic typing feature challenges software maintenance and quality assurance. To facilitate programming and type error checking, the Python programming language has provided a type hint mechanism enabling developers to annotate type information for variables. However, this manual annotation process often requires plenty of resources and may introduce errors. In this paper, we propose a deep learning type inference technique, namely DLInfer, to automatically infer the type infor-mation for Python programs. DLInfer collects slice statements for variables through static analysis and then vectorizes them with the Unigram Language Model algorithm. Based on the vectorized slicing features, we designed a bi-directional gated recurrent unit model to learn the type propagation information for inference. To validate the effectiveness of DLInfer, we conduct an extensive empirical study on 700 open-source projects. We evaluate its accuracy in inferring three kinds of fundamental types, including built-in, library, and user-defined types. By training with a large-scale dataset, DLInfer achieves an average of 98.79% Top-1 accuracy for the variables that can get type information through static analysis and manual annotation. Further, DLInfer achieves 83.03% type inference accuracy on average for the variables that can only obtain the type information through dynamic analysis. The results indicate DLInfer is highly effective in inferring types. It is promising to apply it to assist in various software engineering tasks for Python programs.

链接与引用

DOI 原文 · DBLP

BibTeX
@inproceedings{YanFFX23,
  title = {DLInfer: Deep Learning with Static Slicing for Python Type Inference},
  author = {Yanyan Yan and Yang Feng and Hongcheng Fan and Baowen Xu},
  booktitle = {ICSE},
  year = {2023},
  doi = {10.1109/icse48619.2023.00170}
}