比较人类与LLM生成的代码:结论尚无定论!
Comparing Human and LLM Generated Code: The Jury is Still Out!
AI总结:
本研究使用72个软件工程任务,通过静态分析基准对比GPT-4与人类生成的Python代码质量,发现GPT-4通过测试多但代码更复杂且存在严重安全异常,人类在标准遵守及复杂创新任务上表现更优。
摘要:
关于AI支持的软件开发,人们寄予了厚望。然而,在研究领域中,旨在验证此类技术的真正实用性的评估工作仍然有限,尤其是在与人类编码输出进行比较时。我们弥补了这一空白,使用一个包含72个不同软件工程任务的基准数据集,比较了大型语言模型(LLMs)与人类程序员在生成Python软件代码方面的有效性。我们使用GPT-4作为代表性的LLM,针对人类和该LLM生成的代码,我们评估了代码质量与对Python编码标准的遵守情况、代码安全性与漏洞、代码复杂度以及功能正确性。我们使用了各种静态分析基准,包括Pylint、Radon、Bandit和测试用例。在显著的结果中,结果显示人类生成的代码在遵守编码标准方面的评分高于GPT-4。我们观察到人类和GPT-4生成的代码中均存在安全缺陷,然而,人类生成的代码表现出更多种类的问题,但GPT-4的代码包含了更严重的异常情况。我们的结果显示,尽管GPT-4能够生成编码解决方案,但它经常生成更复杂的代码,可能需要更多的返工以确保可维护性。但另一方面,我们的结果表明,在一系列任务中,GPT-4生成的代码通过的测试用例数量多于人类生成的代码。话虽如此,GPT-4经常在涉及深入领域知识的复杂问题解决中遇到困难。本研究突出了LLMs在支持软件开发方面的潜在实用性,然而,需要全面、创新或非常规解决方案的任务,以及仔细的调试和错误纠正,似乎由人类程序员开发得更好。我们为软件工程社区规划了一项议程。
英文摘要:
Much is promised in relation to AI-supported software development. However, there has been limited evaluation effort in the research domain aimed at validating the true utility of such techniques, especially when compared to human coding outputs. We bridge this gap, where a benchmark dataset comprising 72 distinct software engineering tasks is used to compare the effectiveness of large language models (LLMs) and human programmers in producing Python software code. GPT-4 is used as a representative LLM, where for the code generated by humans and this LLM, we evaluate code quality and adherence to Python coding standards, code security and vulnerabilities, code complexity and functional correctness. We use various static analysis benchmarks, including Pylint, Radon, Bandit and test cases. Among the notable outcomes, results show that human-generated code recorded higher ratings for adhering to coding standards than GPT-4. We observe security flaws in code generated by both humans and GPT-4, however, code generated by humans shows a greater variety of problems, but GPT-4 code included more severe outliers. Our results show that although GPT-4 is capable of producing coding solutions, it frequently produces more complex code that may need more reworking to ensure maintainability. On the contrary however, our outcomes show that a higher number of test cases passed for code generated by GPT-4 across a range of tasks than code that was generated by humans. That said, GPT-4 frequently struggles with complex problem-solving that involve in-depth domain knowledge. This study highlights the potential utility of LLMs for supporting software development, however, tasks requiring comprehensive, innovative or unconventional solutions, and careful debugging and error correction seem to be better developed by human programmers. We plot an agenda for the software engineering community.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。