大型语言模型(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.
Leveraging Large Language Models for Code Translation and Software Development in Scientific Computing
Institute for Clarity in Documentation(清晰文档研究所);Inria Paris-Rocquencourt(巴黎-罗克琴特研究所);Rajiv Gandhi University(拉贾·甘地大学);Tsinghua University(清华大学);Palmer Research Laboratories(帕勒尔研究实验室);Argonne National Laboratory(阿贡国家实验室)
Beyond Correctness: Benchmarking Multi-dimensional Code Generation for Large Language Models
University of Chinese Academy of Sciences(中国科学院大学);Institute of Software, Chinese Academy of Sciences(中国科学院软件研究所);Chinese Information Processing Laboratory(中文信息处理实验室);State Key Laboratory of Computer Science(计算机科学国家重点实验室);Key Laboratory of System Software, Chinese Academy of Sciences(中国科学院系统软件重点实验室)
QuadEnhancer: Leveraging Quadratic Transformations to Enhance Deep Neural Networks
School of Science and Engineering(科学与工程学院);The Chinese University of Hong Kong, Shenzhen(香港中文大学(深圳));Shenzhen International Center for Industrial and Applied Mathematics(深圳国际工业与应用数学中心);Shenzhen Research Institute of Big Data(深圳大数据研究院);School of Data Science(数据科学学院)
Beyond Correctness: Exposing LLM-generated Logical Flaws in Reasoning via Multi-step Automated Theorem Proving
Huazhong University of Science and Technology(华中科技大学);National University of Singapore(新加坡国立大学);Peking University(北京大学);Nanyang Technological University(南洋理工大学)