paperbot · PL 论文追踪

全部论文 待读 收藏

P2 PyART: Python API Recommendation in Real-Time

PyART:面向 Python 的实时 API 推荐
ICSE 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE)2021匹配度 2/10 · 论文面向 Python API 实时推荐,用轻量乐观数据流与随机森林,属于机器学习用于开发者工具,与用户关注的“PL→AI(ML/Agentic 程序静态分析)”或“AI→PL(LLM/Agent 改进静态分析/形式化验证)”均不直接相关,也不涉及浮点程序分析或贝叶斯程序分析。引用 54 inbox
Xincheng He, Lei Xu, Xiangyu Zhang, Rui Hao, Yang Feng, Baowen Xu
crossref: 2026-09-12dblp: 2026-09-12arxiv: 2026-09-12

AI 速览

一句话:提出 PyART,用轻量乐观数据流和随机森林实现 Python 实时 API 推荐,优于现有工具。

针对动态语言 Python 中实时 API 推荐困难、现有方法依赖类型推断且在类型缺失或项目特有 API 上表现不佳的问题,本文提出 PyART。该方法通过轻量分析推导“乐观数据流”,虽不完备但模拟人类可获得的局部数据流信息;在推荐点提取数据流、词元相似度和词元共现三类特征,并用随机森林训练预测模型。在 8 个流行 Python 项目上评估,若有历史提交,top-1 准确率超过 50%,top-10 超过 70%,较 APIREC 和 Intellicode 分别提升 28.48%-39.05% 和 24.41%-30.49%;在无历史注释与跨项目场景也整体更优,平均推荐耗时不足 1 秒,满足实时性。

问题
动态语言 Python 的实时 API 推荐具有挑战:现有方法多面向静态语言或依赖类型推断,在类型信息缺失、目标 API 属于项目特有场景下推荐失败或质量差。
方法
PyART 使用轻量分析推导不完备但模拟人类局部推理的乐观数据流,并在推荐点提取数据流、token 相似度与 token 共现特征,用随机森林训练预测模型。
评估
在 8 个流行 Python 项目上,与 APIREC、Intellicode 等比较;有历史提交时 top-1 超 50%、top-10 超 70%,无历史注释和跨项目场景也整体更优,平均推荐时间小于 1 秒。
原文摘要(Abstract)

API recommendation in real-time is challenging for dynamic languages like Python. Many existing API recommendation techniques are highly effective, but they mainly support static languages. A few Python IDEs provide API recommendation functionalities based on type inference and training on a large corpus of Python libraries and third-party libraries. As such, they may fail to recommend or make poor recommendations when type information is missing or target APIs are project-specific. In this paper, we propose a novel approach, PyART, to recommend APIs for Python programs in real-time. It features a light-weight analysis to derives so-called optimistic data-flow, which is neither sound nor complete, but simulates the local data-flow information humans can derive. It extracts three kinds of features: data-flow, token similarity, and token co-occurrence, in the context of the program point where a recommendation is solicited. A predictive model is trained on these features using the Random Forest algorithm. Evaluation on 8 popular Python projects demonstrates that PyART can provide effective API recommendations. When historic commits can be leveraged, which is the target scenario of a state-of-the-art tool ARIREC, our average top-1 accuracy is over 50% and average top-10 accuracy over 70%, outperforming APIREC and Intellicode (i.e., the recommendation component in Visual Studio) by 28.48%-39.05% for top-1 accuracy and 24.41%-30.49% for top-10 accuracy. In other applications such as when historic comments are not available and cross-project recommendation, PyART also shows better overall performance. The time to make a recommendation is less than a second on average, satisfying the real-time requirement.

链接与引用

DOI 原文 · arXiv · PDF(开放获取) · DBLP

BibTeX
@inproceedings{HeXZHFX21a,
  title = {PyART: Python API Recommendation in Real-Time},
  author = {Xincheng He and Lei Xu and Xiangyu Zhang and Rui Hao and Yang Feng and Baowen Xu},
  booktitle = {ICSE},
  year = {2021},
  doi = {10.1109/icse43902.2021.00145}
}