arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.09834cs.SE
收藏

大语言模型遇见库演化:评估基于大语言模型的代码补全中的废弃API使用

LLMs Meet Library Evolution: Evaluating Deprecated API Usage in LLM-based Code Completion

Chong Wang, Kaifeng Huang, Jian Zhang, Yebo Feng, Lyuye Zhang, Yang Liu, Xin Peng

AI总结:

针对基于大语言模型的代码补全中因库演化导致的废弃API使用问题,首次评估7个先进LLM在8个Python库相关任务中的表现,揭示现状与原因,提出两种轻量级修复方法并提供研究启示。

摘要:

在大型代码语料库上预训练或微调的大语言模型(LLMs)已在生成代码补全方面展现出有效性。然而,由于库的快速持续演化,基于LLM的代码补全中,LLMs可能难以使用正确且最新的应用程序编程接口(APIs)。尽管现有研究强调了预测错误API的问题,但基于LLM的代码补全中废弃API使用这一特定问题尚未得到深入研究。为填补这一空白,我们开展了首个关于基于LLM的代码补全中废弃API使用的评估研究。该研究涉及7个先进LLMs、来自8个流行Python库的145个API映射以及28,125个补全提示。研究结果从模型、提示和库的角度揭示了基于LLM的代码补全中废弃API和替代API使用的现状(即API使用合理性和废弃使用率),并指出了背后的根本原因。基于这些发现,我们提出两种轻量级修复方法REPLACEAPI和INSERTPROMPT,可作为未来缓解基于LLM的补全中废弃API使用研究的基准方法。此外,我们还为未来将库演化与LLM驱动的软件开发相集成的研究提供了启示。

英文摘要:

Large language models (LLMs), pre-trained or fine-tuned on large code corpora, have shown effectiveness in generating code completions. However, in LLM-based code completion, LLMs may struggle to use correct and up-to-date Application Programming Interfaces (APIs) due to the rapid and continuous evolution of libraries. While existing studies have highlighted issues with predicting incorrect APIs, the specific problem of deprecated API usage in LLM-based code completion has not been thoroughly investigated. To address this gap, we conducted the first evaluation study on deprecated API usage in LLM-based code completion. This study involved seven advanced LLMs, 145 API mappings from eight popular Python libraries, and 28,125 completion prompts. The study results reveal the status quo (i.e., API usage plausibility and deprecated usage rate) of deprecated API and replacing API usage in LLM-based code completion from the perspectives of model, prompt, and library, and indicate the root causes behind. Based on these findings, we propose two lightweight fixing approaches, REPLACEAPI and INSERTPROMPT, which can serve as baseline approaches for future research on mitigating deprecated API usage in LLM-based completion. Additionally, we provide implications for future research on integrating library evolution with LLM-driven software development.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑