Automatic API method recommendation is an essential task of code intelligence, which aims to suggest suitable APIs for programming queries. Existing approaches can be categorized into two primary groups: retrieval-based and learning-based approaches. Although these approaches have achieved remarkable success, they still come with notable limitations. The retrieval-based approaches rely on the text representation capabilities of embedding models, while the learning-based approaches require extensive task-specific labeled data for training. To mitigate the limitations, we propose APIGen, a generative API recommendation approach through enhanced in-context learning (ICL). APIGen involves two main components: (1) Diverse Examples Selection. APIGen searches for similar posts to the programming queries from the lexical, syntactical, and semantic perspectives, providing more informative examples for ICL. (2) Guided API Recommendation. APIGen enables large language models (LLMs) to perform reasoning before generating API recommendations, where the reasoning involves fine-grained matching between the task intent behind the queries and the factual knowledge of the APIs. With the reasoning process, APIGen makes recommended APIs better meet the programming requirement of queries and also enhances the interpretability of results. We compare APIGen with four existing approaches on two publicly available benchmarks. Experiments show that APIGen outperforms the best baseline CLEAR by 105.8% in method-level API recommendation and 54.3% in class-level API recommendation in terms of SuccessRate@1. Besides, APIGen achieves an average 49.87% increase compared to the zero-shot performance of popular LLMs such as GPT-4 in method-level API recommendation regarding the SuccessRate@3 metric.
Q-ARE: An Evaluation Dataset for Query Based API Recommendation
College of Computer Science and Technology, National University of Defense Technology(国防科技大学计算机学院);State Key Laboratory of Complex & Critical Software Environment(复杂与关键软件环境国家重点实验室)
RACK: Automatic API Recommendation using Crowdsourced Knowledge
传统的代码搜索引擎通常不能很好地执行自然语言查询,因为它们主要应用关键字匹配。因此,这些引擎需要精心设计的查询,其中包含有关代码搜索编程API的信息。不幸的是,现有的研究表明,准备一个有效的代码搜索查询是既具有挑战性和耗时的开发人员。在本文中,我们提出了一种新的API推荐技术--RACK,它通过利用Stack Overflow的众包知识中的关键字-API关联,为代码搜索的自然语言查询推荐相关API列表。我们首先使用11个核心Java包和来自Stack Overflow的344 K Java帖子进行探索性研究来激励我们的技术。使用150个代码搜索查询随机选择的三个Java教程网站的实验表明,我们的技术建议正确的API类的前10名的结果约79%的查询,这是非常有前途的。与最先进技术的两个变体的比较还表明,RACK不仅在Top-K准确率方面,而且在平均平均精确率和平均召回率方面都大大优于它们。
Holistic Combination of Structural and Textual Code Information for Context based API Recommendation
Fudan University(复旦大学);Shanghai Institute of Intelligent Electronics & Systems(上海智能电子与系统研究院);Australian National University(澳大利亚国立大学);Singapore Management University(新加坡管理大学)
Diversity-aware Web APIs Recommendation with Compatibility Guarantee
China Agricultural University(中国农业大学);Weifang University of Science and Technology(潍坊科技学院);St. Francis Xavier University(圣弗朗西斯泽维尔大学);Macquarie University(麦考瑞大学);Persian Gulf University(波斯湾大学);Shiraz University of Technology(设拉子理工大学)
Don't Use a Cannon to Kill a Fly: Lightweight Model Editing for LLMs to Correct Deprecated API Recommendations
Department of Computer Science, City University of Hong Kong(香港城市大学计算机系);The State Key Laboratory of Blockchain and Data Security, Zhejiang University(浙江大学区块链与数据安全国家重点实验室);Hangzhou High-Tech Zone (Binjiang) Institute of Blockchain and Data Security(杭州高新技术开发区(滨江)区块链与数据安全研究院);Midea Group(美的集团)
Evolution of Deprecated APIs and Their Replacements in Python Libraries
College of Computer Science and Technology, Nanjing University of Aeronautics and Astronautics(南京航空航天大学计算机科学与技术学院);Key Laboratory for Safety-critical Software Development and Verification, Nanjing University of Aeronautics and Astronautics(南京航空航天大学安全关键软件开发与验证重点实验室);State Key Laboratory for Novel Software Technology, Nanjing University(南京大学软件新技术国家重点实验室)
Understanding the Impact of AI Code Assistants on Security API Usage: An Empirical Study
Centre for Research on Engineering Software Technologies (CREST) & Adelaide University, Australia(工程软件研究技术中心(CREST)及阿德莱德大学,澳大利亚);Edith Cowan University, Australia(埃德温·考文大学,澳大利亚);CSIRO’s Data61, Australia(CSIRO数据61,澳大利亚)