arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2208.08289cs.SE
收藏

CCTEST: 测试与修复代码补全系统

CCTEST: Testing and Repairing Code Completion Systems

Zongjie Li, Chaozheng Wang, Zhibo Liu, Haoxuan Wang, Dong Chen, Shuai Wang, Cuiyun Gao

AI总结:

针对代码补全系统常输出可疑结果且缺乏自动化测试增强框架的问题,提出黑盒测试修复框架CCTEST,通过PSC变异生成输入、检测不一致输出、选取平均表现最优输出修复,在8个系统中检测出大量错误用例,显著提升补全准确率。

摘要:

代码补全是软件开发领域中极具价值的研究方向,近年来大语言模型(LLMs)的发展推动了其应用普及。截至目前,GitHub Copilot、GPT等知名的基于大语言模型的代码补全框架,都是通过在海量非结构化文本和开源代码上进行深度学习训练得到的。作为日常编程任务中的核心组成部分与基石,代码补全极大提升了专业人员构建真实软件系统的效率。与这一蓬勃发展的市场形成对比的是,我们发现代码补全系统经常输出可疑结果,且目前尚无针对代码补全系统的自动化测试与增强框架。本研究提出了CCTEST,这是一个在黑盒设置下测试和修复代码补全系统的框架。CCTEST具备一组新颖的变异策略,即程序结构相关(PSC)变异,用于生成变异后的代码补全输入。随后,它从所有补全后的代码用例中检测出不一致的输出,这些输出代表可能存在错误的案例。此外,CCTEST通过选择最能体现所有输出用例“平均”表现的输出作为代码补全系统的最终输出,以此修复代码补全结果。我们从8个流行的基于大语言模型的代码补全系统中,总共检测到33540个可触发错误案例的输入,真阳性率为86%。经过修复,我们证明代码补全系统的准确率在BLEU分数和Levenshtein编辑相似度指标上分别显著提升了40%和67%。

英文摘要:

Code completion, a highly valuable topic in the software development domain, has been increasingly promoted for use by recent advances in large language models (LLMs). To date, visible LLM-based code completion frameworks such as GitHub Copilot and GPT are trained using deep learning over vast quantities of unstructured text and open source code. As the paramount component and the cornerstone in daily programming tasks, code completion has largely boosted professionals' efficiency in building real-world software systems. In contrast to this flourishing market, we find that code completion systems often output suspicious results, and to date, an automated testing and enhancement framework for code completion systems is not available. This research proposes CCTEST, a framework to test and repair code completion systems in blackbox settings. CCTEST features a set of novel mutation strategies, namely program structure-correlated (PSC) mutations, to generate mutated code completion inputs. Then, it detects inconsistent outputs, representing possibly erroneous cases, from all the completed code cases. Moreover, CCTEST repairs the code completion outputs by selecting the output that mostly reflects the "average" appearance of all output cases, as the final output of the code completion systems. We detected a total of 33,540 inputs (with a true positive rate of 86%) that can trigger erroneous cases from eight popular LLM-based code completion systems. With repairing, we show that the accuracy of code completion systems is notably increased by 40% and 67% with respect to BLEU score and Levenshtein edit similarity.

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

↑