The Program Testing Ability of Large Language Models for Code

📄 arXiv: 2310.05727v1 📥 PDF

作者: Weimin Xiong, Yiwen Guo, Hao Chen

分类: cs.CL, cs.AI, cs.LG, cs.SE

发布日期: 2023-10-09


💡 一句话要点

探索大型语言模型在程序测试中的能力

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大型语言模型 程序测试 代码合成 软件工程 自动化测试

📋 核心要点

  1. 现有的大型语言模型在程序合成方面表现出色,但在程序测试能力的评估上仍显不足。
  2. 本文提出通过深入分析LLMs在程序测试中的表现,探索提升其测试能力的方法。
  3. 实验结果表明,利用生成的测试用例可以显著提高合成程序的质量,提升代码通过率。

📝 摘要(中文)

近年来,针对代码的大型语言模型(LLMs)如CodeX和CodeT5+展现出在代码智能方面的巨大潜力。它们在完成特定任务的程序合成能力上已在HumanEval和MBPP等基准数据集上经过广泛测试。然而,考虑到它们在软件工程中的广泛应用,期待从更多角度评估这些LLMs。本文探讨了LLMs在程序测试中的能力,通过对近期LLMs在程序测试中的深入分析,展示了这些模型的一系列有趣特性,并提出了提升LLMs程序测试能力的方法。我们进一步利用生成的测试用例来改善合成程序的质量,结果显示在HumanEval+上与GPT-3.5-turbo基线相比,代码通过率提高了11.77%和4.22%。

🔬 方法详解

问题定义:本文旨在解决大型语言模型在程序测试能力评估方面的不足,现有方法主要集中在程序合成,而忽视了测试能力的探索。

核心思路:通过分析LLMs在程序测试中的表现,提出利用生成的测试用例来提升程序合成的质量,从而增强模型的整体性能。

技术框架:研究首先对现有LLMs进行性能评估,随后设计实验生成测试用例,并将其应用于程序合成的优化中,最终评估合成程序的通过率。

关键创新:本文的创新点在于首次系统性地评估LLMs在程序测试中的能力,并提出通过测试用例生成来提升合成程序质量的策略,这与传统的只关注程序合成的研究方法有本质区别。

关键设计:在实验中,采用了特定的参数设置和损失函数,以确保生成的测试用例能够有效覆盖程序的不同路径,从而提高合成程序的通过率。具体的网络结构和训练流程也经过精心设计,以适应程序测试的需求。

🖼️ 关键图片

fig_0
fig_1

📊 实验亮点

实验结果显示,利用生成的测试用例可以显著提升合成程序的质量,在HumanEval+数据集上,代码通过率相比GPT-3.5-turbo基线提高了11.77%,与最新的最优模型相比提高了4.22%。

🎯 应用场景

该研究的潜在应用领域包括软件开发、自动化测试和代码审查等。通过提升大型语言模型在程序测试中的能力,可以显著提高软件开发的效率和质量,减少人工测试的成本,推动智能编程工具的发展,具有重要的实际价值和未来影响。

📄 摘要(原文)

Recent development of large language models (LLMs) for code like CodeX and CodeT5+ demonstrates tremendous promise in achieving code intelligence. Their ability of synthesizing code that completes a program for performing a pre-defined task has been intensively tested and verified on benchmark datasets including HumanEval and MBPP. Yet, evaluation of these LLMs from more perspectives (than just program synthesis) is also anticipated, considering their broad scope of applications in software engineering. In this paper, we explore the ability of LLMs for testing programs/code. By performing thorough analyses of recent LLMs for code in program testing, we show a series of intriguing properties of these models and demonstrate how program testing ability of LLMs can be improved. Following recent work which utilizes generated test cases to enhance program synthesis, we further leverage our findings in improving the quality of the synthesized programs and show +11.77% and +4.22% higher code pass rates on HumanEval+ comparing with the GPT-3.5-turbo baseline and the recent state-of-the-art, respectively.