利用蜕变测试探索并提升基于大语言模型的自动程序修复的鲁棒性
Exploring and Lifting the Robustness of LLM-powered Automated Program Repair with Metamorphic Testing
AI总结:
本文提出蜕变测试框架MT-LAPR,通过九种蜕变关系生成语义等价的测试用例,系统评估并暴露LAPR技术的不稳定性,进而训练基于CodeT5的代码可读性增强模型作为预处理步骤,显著提升LAPR鲁棒性最高达49.32%。
摘要:
近年来,基于大语言模型的自动程序修复(LAPR)技术取得了最先进的缺陷修复性能,并在工业界和学术界得到了广泛应用与研究。然而,大语言模型(LLMs)被证明对输入提示高度敏感,语义等价程序在表达上的细微差异就可能导致修复失败。因此,在实际部署LAPR技术之前,对其进行鲁棒性测试至关重要。但相关研究十分匮乏。为此,我们提出了MT-LAPR,一个专门针对LAPR技术的蜕变测试框架,该框架总结了开发者广泛认可的九种蜕变关系(MRs),涵盖三个扰动层级:token级、语句级和块级。随后,我们将所提出的蜕变关系应用于有缺陷的代码以生成测试用例,这些测试用例在语义上等价,但会影响LAPR的推理。实验在两个被广泛研究的缺陷修复数据集Defect4J和QuixBugs以及四个近期发布的具备缺陷修复能力的大语言模型上进行,结果表明平均有34.4%至48.5%的测试用例暴露了LAPR技术的不稳定性,证明了MT-LAPR的有效性,并揭示了代码可读性与LAPR技术鲁棒性之间的正相关关系。受上述发现启发,本文利用MT-LAPR生成的测试用例作为样本,训练一个基于CodeT5的代码编辑模型,旨在提高代码可读性,并将其作为数据预处理步骤嵌入LAPR工作流中。大量实验表明,该方法显著增强了LAPR的鲁棒性,最高提升达49.32%。
英文摘要:
In recent years, Large language model-powered Automated Program Repair (LAPR) techniques have achieved state-of-the-art bug-fixing performance and have been pervasively applied and studied in both industry and academia. Nonetheless, LLMs were proved to be highly sensitive to input prompts, with slight differences in the expressions of semantically equivalent programs potentially causing repair failures. Therefore, it is crucial to conduct robustness testing on LAPR techniques before their practical deployment. However, related research is scarce. To this end, we propose MT-LAPR, a Metamorphic Testing framework exclusively for LAPR techniques, which summarizes nine widely-recognized Metamorphic Relations (MRs) by developers across three perturbation levels: token, statement, and block. Afterward, our proposed MRs are applied to buggy codes to generate test cases, which are semantically equivalent yet to affect the inference of LAPR. Experiments are carried out on two extensively examined bug-fixing datasets, i.e., Defect4J and QuixBugs, and four bug-fixing abled LLMs released recently, demonstrating that 34.4% - 48.5% of the test cases expose the instability of LAPR techniques on average, showing the effectiveness of MT-LAPR and uncovering a positive correlation between code readability and the robustness of LAPR techniques. Inspired by the above findings, this paper uses the test cases generated by MT-LAPR as samples to train a CodeT5-based code editing model aiming at improving code readability and then embeds it into the LAPR workflow as a data preprocessing step. Extensive experiments demonstrate that this approach significantly enhances the robustness of LAPR by 49.32% at most.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。