EffiLearner: Enhancing Efficiency of Generated Code via Self-Optimization

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Huang, Dong, Dai, Jianbo, Weng, Han, Wu, Puzhen, Qing, Yuhao, Cui, Heming, Guo, Zhijiang, Zhang, Jie M.
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866915280988405760
author Huang, Dong
Dai, Jianbo
Weng, Han
Wu, Puzhen
Qing, Yuhao
Cui, Heming
Guo, Zhijiang
Zhang, Jie M.
author_facet Huang, Dong
Dai, Jianbo
Weng, Han
Wu, Puzhen
Qing, Yuhao
Cui, Heming
Guo, Zhijiang
Zhang, Jie M.
contents Large language models (LLMs) have shown remarkable progress in code generation, but their generated code often suffers from inefficiency, resulting in longer execution times and higher memory consumption. To address this issue, we propose \textbf{EffiLearner}, a self-optimization framework that utilizes execution overhead profiles to improve the efficiency of LLM-generated code. EffiLearner first generates code using an LLM, then executes it locally to capture execution time and memory usage profiles. These profiles are fed back to the LLM, which then revises the code to reduce overhead. To evaluate the effectiveness of EffiLearner, we conduct extensive experiments on the EffiBench, HumanEval, and MBPP with 16 open-source and 6 closed-source models. Our evaluation results demonstrate that through iterative self-optimization, EffiLearner significantly enhances the efficiency of LLM-generated code. For example, the execution time (ET) of StarCoder2-15B for the EffiBench decreases from 0.93 (s) to 0.12 (s) which reduces 87.1% the execution time requirement compared with the initial code. The total memory usage (TMU) of StarCoder2-15B also decreases from 22.02 (Mb*s) to 2.03 (Mb*s), which decreases 90.8% of total memory consumption during the execution process. The source code of EffiLearner was released in https://github.com/huangd1999/EffiLearner
format Preprint
id arxiv_https___arxiv_org_abs_2405_15189
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle EffiLearner: Enhancing Efficiency of Generated Code via Self-Optimization
Huang, Dong
Dai, Jianbo
Weng, Han
Wu, Puzhen
Qing, Yuhao
Cui, Heming
Guo, Zhijiang
Zhang, Jie M.
Software Engineering
Computation and Language
Large language models (LLMs) have shown remarkable progress in code generation, but their generated code often suffers from inefficiency, resulting in longer execution times and higher memory consumption. To address this issue, we propose \textbf{EffiLearner}, a self-optimization framework that utilizes execution overhead profiles to improve the efficiency of LLM-generated code. EffiLearner first generates code using an LLM, then executes it locally to capture execution time and memory usage profiles. These profiles are fed back to the LLM, which then revises the code to reduce overhead. To evaluate the effectiveness of EffiLearner, we conduct extensive experiments on the EffiBench, HumanEval, and MBPP with 16 open-source and 6 closed-source models. Our evaluation results demonstrate that through iterative self-optimization, EffiLearner significantly enhances the efficiency of LLM-generated code. For example, the execution time (ET) of StarCoder2-15B for the EffiBench decreases from 0.93 (s) to 0.12 (s) which reduces 87.1% the execution time requirement compared with the initial code. The total memory usage (TMU) of StarCoder2-15B also decreases from 22.02 (Mb*s) to 2.03 (Mb*s), which decreases 90.8% of total memory consumption during the execution process. The source code of EffiLearner was released in https://github.com/huangd1999/EffiLearner
title EffiLearner: Enhancing Efficiency of Generated Code via Self-Optimization
topic Software Engineering
Computation and Language
url https://arxiv.org/abs/2405.15189