一句话:首次大规模实证研究 ChatGPT 在竞赛级编程题上的零样本代码生成、修复潜力与代码质量。
论文关注大语言模型在竞赛级编程问题上的代码生成能力。现有研究多考察简单编程题,尚未系统研究复杂规格、严格输入输出格式与高层算法推理的竞赛题。作者开展首个大规模实证研究,先在 Human-Eval 上设计并预热 prompt,再将其用于 APPS 竞赛级数据集,收集 ChatGPT 在 5000 道题上的零样本输出。评估显示其可通过 25.4% 的测试用例;向 ChatGPT 提供额外信息(如测试失败信息)后,它具有把部分通过的程序修复为完全通过程序的潜力。对生成解与已有解的分析表明,面对更难问题时模型更倾向于直接复制代码而非重写。代码质量方面,生成代码的函数与文件规模较小,符合 clean code 标准。
Code generation aims to generate source code implementing human requirements illustrated with natural language specifications. With the rapid development of intelligent software engineering, automated code generation has become a hot research topic in both artificial intelligence and software engineering, and researchers have made significant achievements on code generation. More recently, large language models (LLMs) have demonstrated outstanding performance on code generation tasks, such as ChatGPT released by OpenAI presents the fantastic potential on automated code generation. However, the existing studies are limited to exploring LLMs' ability for generating code snippets to solve simple programming problems, the task of competition-level code generation has never been investigated. The specifications of the programming competition are always complicated and require the specific input/output format as well as the high-level algorithmic reasoning ability. In this study, we conduct the first large empirical study to investigate the zero-shot learning ability of ChatGPT for solving competition programming problems. Specifically, we warm up the design of prompts by using the Human-Eval dataset. Then, we apply the well-designed prompt to the competition-level code generation dataset, namely APPS, to further explore the effectiveness of using ChatGPT for solving competition problems. We collect ChatGPT's outputs on 5,000 code competition problems, the evaluation results show that it can successfully pass 25.4% test cases. By further feeding extra information (e.g, test failed information) to ChatGPT, we observe that ChatGPT has the potential to fix partial pass into a fully pass program. Moreover, we investigate the solutions generated by LLMs and the existing solutions, we find that it prefers to directly copy the code instead of re-write when facing more difficult problems. Finally, we evaluate the code quality generated by ChatGPT in terms of “code cleanness”, we observe that the generated codes are with small functions and file sizes, which are in line with the standard of clean code.