再也不用亲自动手了?评估ChatGPT的代码生成质量
No Need to Lift a Finger Anymore? Assessing the Quality of Code Generation by ChatGPT
AI总结:
本研究通过多语言算法题和安全场景,从正确性、复杂度、安全性及多轮修复能力维度系统评估ChatGPT的代码生成质量,揭示其潜在问题,为改进AI代码生成技术奠基。
摘要:
大语言模型(LLM)已在各类自然语言处理任务中展现出令人瞩目的能力。此外,大语言模型在支撑软件工程任务方面也极具价值,尤其是在代码生成领域。自动代码生成是指根据给定的规范或需求自动生成源代码或可执行代码的过程,能够提升开发者的生产力。本研究针对ChatGPT的代码生成质量开展了系统性的实证评估。我们采用了涵盖5种编程语言(即C、C++、Java、Python和JavaScript)的728道算法题,以及涉及18种常见弱点枚举(CWE)的54个代码场景来开展代码生成任务。我们的评估对ChatGPT生成的代码片段进行了全面分析,聚焦于三个关键维度:正确性、复杂度和安全性。我们还专门研究了ChatGPT通过多轮修复流程(即ChatGPT的对话能力)辅助代码生成的能力。通过深入分析生成的代码并检验实验结果,本研究针对ChatGPT在三个关键维度上处理代码生成任务的表现提供了有价值的洞见。总体而言,我们的发现揭示了基于ChatGPT的代码生成存在的潜在问题与局限性,为改进基于人工智能和大语言模型的代码生成技术奠定了基础。
英文摘要:
Large language models (LLMs) have demonstrated impressive capabilities across various NLP tasks. Additionally, LLMs are also highly valuable in supporting software engineering tasks, particularly in the field of code generation. Automatic code generation is a process of automatically generating source code or executable code based on given specifications or requirements, improving developer productivity. In this study, we perform a systematic empirical assessment to the quality of code generation using ChatGPT. We leverage 728 algorithm problems in five languages (i.e., C, C++, Java, Python, and JavaScript) and 18 CWEs with 54 code scenarios for the code generation task. Our evaluation encompasses a comprehensive analysis of code snippets generated by ChatGPT, focusing on three critical aspects: correctness, complexity, and security. We also specifically investigate ChatGPT's ability to engage in multi-round fixing process (i.e., ChatGPT's dialog ability) of facilitating code generation. By delving into the generated code and examining the experimental results, this work provides valuable insights into the performance of ChatGPT in tackling code generation tasks over the three critical aspects. Overall, our findings uncover potential issues and limitations that arise in the ChatGPT-based code generation and lay the groundwork for improving AI and LLM-based code generation techniques.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。