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

关于微调大型语言模型用于单元测试的大规模实证研究

A Large-scale Empirical Study on Fine-tuning Large Language Models for Unit Testing

Ye Shang, Quanjun Zhang, Chunrong Fang, Siqi Gu, Jianyi Zhou, Zhenyu Chen

AI总结:

本研究针对微调大型语言模型在单元测试中的应用进行了大规模实证研究,涵盖3个任务、5个基准和37个模型,发现微调LLMs在几乎所有指标上均优于现有最先进方法,并指出大规模decoder-only模型表现最佳,同时揭示了提示工程的巨大潜力。

摘要:

单元测试在软件开发中扮演着关键角色,能够提升软件质量和可靠性。然而,手动生成有效的测试用例十分耗时,这激发了对单元测试研究的兴趣。最近,大型语言模型(LLMs)在各种单元测试任务中展现出了潜力,包括测试生成、断言生成和测试演化,但现有研究在范围上存在局限,并且缺乏对LLMs有效性的系统性评估。为了弥补这一空白,我们提出了一项关于微调LLMs用于单元测试的大规模实证研究。我们的研究涉及三个单元测试任务、五个基准、八个评估指标,以及37个不同架构和规模的流行LLMs,消耗了超过3,000个NVIDIA A100 GPU小时。我们关注三个关键研究问题:(1)LLMs与最先进方法相比的性能;(2)不同因素对LLM性能的影响;(3)微调与提示工程的有效性对比。我们的发现表明,LLMs在所有三个单元测试任务中,几乎在所有指标上都优于现有的最先进方法,突显了微调LLMs在单元测试任务中的潜力。此外,大规模的decoder-only模型在各任务中取得了最佳结果,而encoder-decoder模型在相同参数规模下表现更好。另外,微调与提示工程方法之间的性能对比揭示了提示工程方法在单元测试任务中具有相当大的潜在能力。随后,我们讨论了与测试生成任务相关的问题,包括数据泄漏问题、错误检测能力和指标比较。最后,我们进一步为不久的将来基于LLMs的单元测试方法指明了各种实用指南。

英文摘要:

Unit testing plays a pivotal role in software development, improving software quality and reliability. However, generating effective test cases manually is time-consuming, prompting interest in unit testing research. Recently, Large Language Models (LLMs) have shown potential in various unit testing tasks, including test generation, assertion generation, and test evolution, but existing studies are limited in scope and lack a systematic evaluation of the effectiveness of LLMs. To bridge this gap, we present a large-scale empirical study on fine-tuning LLMs for unit testing. Our study involves three unit testing tasks, five benchmarks, eight evaluation metrics, and 37 popular LLMs across various architectures and sizes, consuming over 3,000 NVIDIA A100 GPU hours. We focus on three key research questions: (1) the performance of LLMs compared to state-of-the-art methods, (2) the impact of different factors on LLM performance, and (3) the effectiveness of fine-tuning versus prompt engineering. Our findings reveal that LLMs outperform existing state-of-the-art approaches on all three unit testing tasks across nearly all metrics, highlighting the potential of fine-tuning LLMs in unit testing tasks. Furthermore, large-scale, decoder-only models achieve the best results across tasks, while encoder-decoder models perform better under the same parameter scale. Additionally, the comparison of the performance between fine-tuning and prompt engineering approaches reveals the considerable potential capability of the prompt engineering approach in unit testing tasks. We then discuss the concerned issues on the test generation task, including data leakage issues, bug detection capabilities, and metrics comparisons. Finally, we further pinpoint carious practical guidelines for LLM-based approaches to unit testing tasks in the near future.

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

↑