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

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Ye, Tong, Huang, Weigang, Zhang, Xuhong, Ma, Tengfei, Liu, Peiyu, Yin, Jianwei, Wang, Wenhai
Format: Preprint
Veröffentlicht: 2025
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866913707297079296
author Ye, Tong
Huang, Weigang
Zhang, Xuhong
Ma, Tengfei
Liu, Peiyu
Yin, Jianwei
Wang, Wenhai
author_facet Ye, Tong
Huang, Weigang
Zhang, Xuhong
Ma, Tengfei
Liu, Peiyu
Yin, Jianwei
Wang, Wenhai
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2502_18489
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle LLM4EFFI: Leveraging Large Language Models to Enhance Code Efficiency and Correctness
Ye, Tong
Huang, Weigang
Zhang, Xuhong
Ma, Tengfei
Liu, Peiyu
Yin, Jianwei
Wang, Wenhai
Software Engineering
Artificial Intelligence
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.
title LLM4EFFI: Leveraging Large Language Models to Enhance Code Efficiency and Correctness
topic Software Engineering
Artificial Intelligence
url https://arxiv.org/abs/2502.18489