arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2412.03578cs.SEcs.AIcs.CLcs.PL
收藏

PerfCodeGen:利用执行反馈提升大语言模型生成代码的性能

PerfCodeGen: Improving Performance of LLM Generated Code with Execution Feedback

The Chinese University of Hong Kong(香港中文大学);Salesforce Research(Salesforce研究院)

Yun Peng, Akhilesh Deepak Gotmare, Michael Lyu, Caiming Xiong, Silvio Savarese, Doyen Sahoo

AI总结:

针对LLM生成代码仅关注功能正确性而缺乏效率优化的问题,提出无需训练的PerfCodeGen框架,通过执行时运行时间反馈优化代码,在更多问题上实现加速,开源模型效率媲美闭源模型,基准测试性能超越参考方案。

摘要:

大语言模型(LLMs)被广泛用于辅助软件开发任务,但其性能评估仅局限于生成代码的功能正确性。然而,人类程序员不仅要求LLM生成的代码正确,还要求其具备最优效率。我们提出PerfCodeGen,这是一个无需训练的框架,通过在自我优化迭代中融入测试用例执行时基于运行时间的反馈,提升LLM生成代码的性能。与使用基础LLM配合复杂提示技术相比,PerfCodeGen在显著更高比例的问题上实现了加速。将其应用于Phi-3-mini等开源语言模型时,PerfCodeGen实现的运行效率可与GPT-4等强大闭源模型的提示效果媲美。我们在HumanEval、MBPP和APPS等基准测试中取得了最先进的运行效率,使用GPT-3.5和GPT-4的PerfCodeGen经常超越真实参考解决方案。此外,我们证明了该方法在提升不同规模开源LLM(包括Phi-3-mini、Llama 3 8B、Mixtral 8x7B、Command R和Llama 3 70B)代码质量方面的有效性。

英文摘要:

Large Language Models (LLMs) are widely adopted for assisting in software development tasks, yet their performance evaluations have narrowly focused on the functional correctness of generated code. Human programmers, however, require LLM-generated code to be not only correct but also optimally efficient. We propose PerfCodeGen, a training-free framework that enhances the performance of LLM-generated code by incorporating feedback based on runtime during test case execution into the self-refinement iterations. With PerfCodeGen, we achieve speedups for a significantly higher proportion of problems compared to using the base LLM with sophisticated prompting techniques. Applied to open language models like Phi-3-mini, PerfCodeGen achieves runtime efficiency comparable to prompting powerful closed models like GPT-4. We achieve state-of-the-art runtime efficiency on benchmarks such as HumanEval, MBPP, and APPS, frequently surpassing the ground truth reference solutions with PerfCodeGen using GPT-3.5 and GPT-4. Additionally, we demonstrate the effectiveness of our approach in enhancing code quality across a range of open LLMs of varying sizes including Phi-3-mini, Llama 3 8B, Mixtral 8x7B, Command R, and Llama 3 70B.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑