一句话:提出黑盒测试与修复框架 CCTEST,通过结构一致变异检测并修复 LLM 代码补全系统的错误输出。
基于大语言模型的代码补全系统(如 GitHub Copilot、GPT)已成为日常开发的重要工具,但它们经常输出可疑结果,且目前缺乏自动化的测试与增强框架。本文提出 CCTEST,在黑盒设定下对代码补全系统进行测试与修复。其核心是一组新颖的变异策略——程序结构一致性(PSC)变异,用于生成保持程序结构一致的补全输入;随后从所有补全结果中检测不一致输出,以定位可能的错误案例。在修复阶段,CCTEST 选择最能反映所有输出案例“平均”形态的结果作为系统最终输出。作者在八个主流 LLM 代码补全系统上使用约 1.8 万个测试输入,检测出 33,540 个可触发错误案例的输入(真阳性率 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 black-box settings. CCTEST features a set of novel mutation strategies, namely program structure-consistent (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. With around 18K test inputs, we detected 33,540 inputs that can trigger erroneous cases (with a true positive rate of 86%) 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.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{LiWLWCWG23,
title = {CCTEST: Testing and Repairing Code Completion Systems},
author = {Zongjie Li and Chaozheng Wang and Zhibo Liu and Haoxuan Wang and Dong Chen and Shuai Wang and Cuiyun Gao},
booktitle = {ICSE},
year = {2023},
doi = {10.1109/icse48619.2023.00110}
}