通过联合训练改进检索增强的深度断言生成
Improving Retrieval-Augmented Deep Assertion Generation via Joint Training
AI总结:
针对现有检索增强断言生成方法中检索与生成模块割裂的问题,提出AG-RAG方法,以CodeT5为基础通过联合训练优化密集检索器与生成器,在多基准上显著优于现有基线方法。
摘要:
单元测试旨在验证被测软件系统基本单元的正确性,在软件开发与测试中发挥着关键作用。近期研究提出了一种检索-编辑方法来生成单元测试预言,即断言。尽管该方法颇具前景,但仍存在诸多局限,远未臻于完善,例如将断言检索与生成拆分为两个独立组件,二者无法相互增益。本文提出AG-RAG,这是一种检索增强的自动化断言生成方法,利用外部代码库与联合训练来解决先前工作的各类技术局限。受整形手术假说启发,AG-RAG尝试将相关单元测试与先进预训练语言模型(PLMs)相结合,采用检索增强微调策略。AG-RAG构建了一个密集检索器,通过语义匹配搜索相关的测试-断言对(TAPs);还构建了一个检索增强生成器,以焦点测试和检索到的TAPs为输入合成准确的断言。此外,AG-RAG以代码感知语言模型CodeT5为基础,同时支撑断言检索与生成两项任务。进一步地,该方法采用联合训练策略,将检索器与生成器作为完整流水线协同优化。这种统一设计使两个组件都能专门适配于检索更有用的TAPs,从而生成准确的断言。我们在两个基准上、采用三项指标,将AG-RAG与六种最先进的AG(断言生成)方法进行了广泛评估。实验结果表明,AG-RAG在所有基准和指标上均显著优于先前的AG方法,例如在准确率方面,比最新基线EditAS分别提升20.82%和26.98%。AG-RAG还正确生成了1739个和2866个所有基线都无法生成的独特断言,数量分别是EditAS的3.45倍和9.20倍。
英文摘要:
Unit testing attempts to validate the correctness of basic units of the software system under test and has a crucial role in software development and testing. Very recent work proposes a retrieve-and-edit approach to generate unit test oracles, i.e., assertions. Despite being promising, it is still far from perfect due to some limitations, such as splitting assertion retrieval and generation into two separate components without benefiting each other. In this paper, we propose AG-RAG, a retrieval-augmented automated assertion generation approach that leverages external codebases and joint training to address various technical limitations of prior work. Inspired by the plastic surgery hypothesis, AG-RAG attempts to combine relevant unit tests and advanced pre-trained language models (PLMs) with retrieval-augmented fine-tuning. AG-RAG builds a dense retriever to search for relevant test-assert pairs (TAPs) with semantic matching and a retrieval-augmented generator to synthesize accurate assertions with the focal-test and retrieved TAPs as input. Besides, AG-RAG leverages a code-aware language model CodeT5 as the cornerstone to facilitate both assertion retrieval and generation tasks. Furthermore, the retriever is optimized in conjunction with the generator as a whole pipeline with a joint training strategy. This unified design fully adapts both components specifically for retrieving more useful TAPs, thereby generating accurate assertions. We extensively evaluate AG-RAG against six state-of-the-art AG approaches on two benchmarks and three metrics. Experimental results show that AG-RAG significantly outperforms previous AG approaches on all benchmarks and metrics, e.g., improving the most recent baseline EditAS by 20.82% and 26.98% in terms of accuracy. AG-RAG also correctly generates 1739 and 2866 unique assertions that all baselines fail to generate, 3.45X and 9.20X more than EditAS.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。