开源能否击败 ChatGPT?——面向文本到代码生成的大语言模型比较研究
Can OpenSource beat ChatGPT? -- A Comparative Study of Large Language Models for Text-to-Code Generation
AI总结:
本文比较 Bard、BingChat、ChatGPT、Llama2 与 Code Llama 在 LeetCode 文本到 Python 代码生成任务中的表现,发现 ChatGPT 最优,且长上下文会增加代码错误。
摘要:
近年来,大语言模型(LLM)已成为功能强大的工具,在包括软件工程在内的多个领域具有潜在应用。在本研究范围内,我们评估了五种不同的最先进 LLM——Bard、BingChat、ChatGPT、Llama2 和 Code Llama——在文本到代码生成方面的能力。在一项实证研究中,我们将来自编程网站 LeetCode 的、包含编程问题文本描述的提示词输入模型,任务是生成 Python 解决方案。随后,我们使用 LeetCode 的测试功能评估生成输出的质量。结果表明,所考察模型之间的性能存在巨大差异。ChatGPT 迄今最能有效处理这些典型编程挑战,甚至超过 Code Llama 等代码专用模型。为获得进一步洞见,我们测量了生成输出的运行时间和内存使用情况,并将其与 LeetCode 上的其他代码提交进行比较。详细的错误分析包括比较生成代码在正确缩进和形式方面的差异,以及将未正确解决的任务归入特定错误类别,使我们能够对结果和改进潜力形成更细致的认识。结果还显示出一个明显模式:当模型面对以更长提示词形式出现的大量上下文时,其生成的代码会越来越多地出现错误。
英文摘要:
In recent years, large language models (LLMs) have emerged as powerful tools with potential applications in various fields, including software engineering. Within the scope of this research, we evaluate five different state-of-the-art LLMs - Bard, BingChat, ChatGPT, Llama2, and Code Llama - concerning their capabilities for text-to-code generation. In an empirical study, we feed prompts with textual descriptions of coding problems sourced from the programming website LeetCode to the models with the task of creating solutions in Python. Subsequently, the quality of the generated outputs is assessed using the testing functionalities of LeetCode. The results indicate large differences in performance between the investigated models. ChatGPT can handle these typical programming challenges by far the most effectively, surpassing even code-specialized models like Code Llama. To gain further insights, we measure the runtime as well as the memory usage of the generated outputs and compared them to the other code submissions on Leetcode. A detailed error analysis, encompassing a comparison of the differences concerning correct indentation and form of the generated code as well as an assignment of the incorrectly solved tasks to certain error categories allows us to obtain a more nuanced picture of the results and potential for improvement. The results also show a clear pattern of increasingly incorrect produced code when the models are facing a lot of context in the form of longer prompts.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。