arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.18489cs.SEcs.AI
收藏

LLM4EFFI:利用大型语言模型提升代码效率与正确性

LLM4EFFI: Leveraging Large Language Models to Enhance Code Efficiency and Correctness

Zhejiang University(浙江大学);Stony Brook University(石溪大学)

Tong Ye, Weigang Huang, Xuhong Zhang, Tengfei Ma, Peiyu Liu, Jianwei Yin, Wenhai Wang

AI总结:

本研究提出LLM4EFFI框架,通过逻辑域算法探索与代码域实现优化分离,并辅以合成测试用例细化,使大模型生成兼顾效率与正确性的代码,在效率基准上达到新最优。

摘要:

大型语言模型(LLMs),特别是代码大型语言模型,在代码生成方面已展现出令人印象深刻的表现。当前研究主要关注生成代码的正确性,而效率问题仍较少被探索。近期工作侧重于修改代码的初始版本以提高其效率。然而,此类改进受限于初始代码的算法设计和整体逻辑,仅能带来渐进式的提升。相比之下,人类开发者在编写高质量代码时,通常先在逻辑层面设计若干潜在解决方案,评估各种算法及其复杂度,然后着手实现并优化该方案。在本研究中,我们引入了\ ool:\uline{L}arge \uline{L}anguage \uline{M}odel for Code \uline{Effi}ciency,一个新颖的框架,使LLMs能够生成兼顾效率与正确性的代码。具体而言,\ ool将效率优化过程划分为两个领域:逻辑领域的算法探索和代码领域的实现优化。随后,通过合成测试用例的细化过程来保证代码的正确性。这种先优先效率、再确保正确性的方法,为高效代码生成提供了一种新范式。实验表明,\ ool持续提升效率和正确性,在各种LLM骨干网络上均取得了代码效率基准上的最新最优性能。

英文摘要:

Large Language Models (LLMs), particularly Code LLMs, have demonstrated impressive performance in code generation. Current research primarily focuses on the correctness of generated code, while efficiency remains less explored. Recent works have focused on modifying the initial version of the code to improve its efficiency. However, such refinements are limited by the algorithmic design and overall logic of the initial code, resulting in only incremental improvements. In contrast, when human developers write high-quality code, they typically begin by designing several potential solutions at the logical level, evaluating various algorithms and their complexities, and then proceeding to implement and optimize the solution. In this study, we introduce \tool: \uline{L}arge \uline{L}anguage \uline{M}odel for Code \uline{Effi}ciency, a novel framework that enables LLMs to generate code that balances both efficiency and correctness. Specifically, \tool divides the efficiency optimization process into two domains: algorithmic exploration in the logic domain and implementation optimization in the code domain. The correctness of the code is then guaranteed through a synthetic test case refinement process. This approach, which prioritizes efficiency before ensuring correctness, offers a new paradigm for efficient code generation. Experiments demonstrate that \tool consistently improves both efficiency and correctness, achieving new state-of-the-art performance in code efficiency benchmarks across various LLM backbones.

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

↑