EffiBench: Benchmarking the Efficiency of Automatically Generated Code
作者: Dong Huang, Yuhao Qing, Weiyi Shang, Heming Cui, Jie M. Zhang
分类: cs.SE, cs.CL
发布日期: 2024-02-03 (更新: 2025-05-10)
备注: Camera Ready for NeurIPS 2024
🔗 代码/项目: GITHUB | HUGGINGFACE
💡 一句话要点
提出EffiBench以评估自动生成代码的效率问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 代码生成 效率评估 绿色计算 基准测试 人工智能
📋 核心要点
- 现有代码生成模型在生成代码的效率方面表现不佳,未能满足绿色计算的需求。
- EffiBench通过提供1000个效率关键的编码问题,结合人类标准解决方案,来评估代码生成模型的效率。
- 实验结果显示,GPT-4生成的代码效率显著低于人类编写的解决方案,最高执行时间差异达到43.92倍。
📝 摘要(中文)
代码生成模型在软件开发中日益重要,然而,现有研究主要关注生成代码的正确性,而忽视了代码效率这一对绿色计算和可持续发展至关重要的方面。本文提出了EffiBench,一个包含1000个效率关键编码问题的基准,旨在评估代码生成模型生成代码的效率。EffiBench包含多样化的LeetCode编码问题,并为每个问题提供了一个可执行的人类编写的标准解决方案,该方案在LeetCode解决方案排行榜上获得了最佳效率。通过EffiBench,我们实证评估了42个大型语言模型(35个开源和7个闭源)生成高效代码的能力。评估结果表明,LLMs生成的代码效率普遍低于人类编写的标准解决方案,例如,GPT-4生成的代码平均执行时间是人类标准解决方案的3.12倍。
🔬 方法详解
问题定义:本文旨在解决自动生成代码在效率方面的不足,现有方法多关注正确性,忽视了效率对可持续发展的重要性。
核心思路:通过构建EffiBench基准,提供多样化的编码问题及其高效的人类标准解决方案,从而评估和比较不同代码生成模型的效率。
技术框架:EffiBench包含1000个编码问题,每个问题都有对应的高效人类解决方案,评估过程涉及42个大型语言模型的生成代码效率。
关键创新:EffiBench的创新在于其专注于代码生成的效率评估,填补了现有研究的空白,并提供了一个标准化的基准测试平台。
关键设计:在设计中,EffiBench确保每个问题的标准解决方案在LeetCode排行榜上具有最佳效率,评估时通过执行时间和内存使用量等指标进行量化。
🖼️ 关键图片
📊 实验亮点
实验结果表明,GPT-4生成的代码在执行时间上平均是人类标准解决方案的3.12倍,极端情况下甚至达到43.92倍。这一发现强调了当前代码生成模型在效率方面的不足,提示未来研究需重视代码效率的提升。
🎯 应用场景
EffiBench的研究成果可广泛应用于软件开发领域,尤其是在需要高效代码生成的场景中,如嵌入式系统、移动应用和大数据处理等。通过提升代码生成模型的效率,能够有效支持绿色计算和可持续发展目标,推动更环保的软件开发实践。
📄 摘要(原文)
Code generation models have increasingly become integral to aiding software development. Although current research has thoroughly examined the correctness of the code produced by code generation models, a vital aspect that plays a pivotal role in green computing and sustainability efforts has often been neglected. This paper presents EffiBench, a benchmark with 1,000 efficiency-critical coding problems to assess the efficiency of code generated by code generation models. EffiBench contains a diverse set of LeetCode coding problems. Each problem is paired with an executable human-written canonical solution, which obtains the SOTA efficiency on the LeetCode solution leaderboard. With EffiBench, we empirically examine the ability of 42 large language models (35 open-source and 7 closed-source) to generate efficient code. Our evaluation results demonstrate that the efficiency of the code generated by LLMs is generally worse than the efficiency of human-written canonical solutions. For example, GPT-4 generated code has an average \textbf{3.12} times execution time that of the human-written canonical solutions. In the most extreme cases, the execution time and total memory usage of GPT-4 generated code are \textbf{13.89} and \textbf{43.92} times that of the canonical solutions. The source code of EffiBench is released on https://github.com/huangd1999/EffiBench. We also provide the LeaderBoard at https://huggingface.co/spaces/EffiBench/effibench-leaderboard.