arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.11006cs.DCcs.AIcs.PFcs.SE
收藏

GREEN-CODE:学习优化基于大语言模型的代码生成中的能效

GREEN-CODE: Learning to Optimize Energy Efficiency in LLM-based Code Generation

University of Amsterdam(阿姆斯特丹大学);TU Wien(维也纳技术大学)

Shashikant Ilager, Lukas Florian Briem, Ivona Brandic

AI总结:

针对大语言模型推理资源消耗高的问题,提出GREEN-CODE框架,通过强化学习智能体实现推理动态早退,平衡准确率、延迟与能耗,在两个开源模型和两个数据集上验证可降能耗23%-50%且不显著影响准确率。

摘要:

大语言模型(Large Language Models, LLMs)正逐渐成为日常生活中不可或缺的一部分,在各类自然语言处理(Natural Language Processing, NLP)任务中展现出巨大潜力。除NLP领域外,LLM正越来越多地被用于软件开发任务,例如代码补全、修改、漏洞修复以及代码翻译。软件工程师广泛使用GitHub Copilot和Amazon Q等工具,以高准确率简化工作流程并实现任务自动化。尽管人们常强调LLM训练的资源与能源密集程度,但随着时间推移,推理过程的资源消耗可能更高,因为它是一个调用量极大的持续过程。因此,开发资源高效的LLM推理替代方案对可持续发展至关重要。本研究提出GREEN-CODE,一种面向LLM的能源感知代码生成框架。GREEN-CODE在LLM推理过程中执行动态早退机制。我们训练了一个强化学习(Reinforcement Learning, RL)智能体,该智能体学习平衡准确率、延迟与能源消耗之间的权衡关系。我们在两个开源LLM——Llama 3.2 3B和OPT 2.7B上,使用JavaCorpus和PY150数据集对所提方法进行了评估。结果表明,该方法在代码生成任务中可平均降低23%-50%的能源消耗,且不会显著影响准确率。

英文摘要:

Large Language Models (LLMs) are becoming integral to daily life, showcasing their vast potential across various Natural Language Processing (NLP) tasks. Beyond NLP, LLMs are increasingly used in software development tasks, such as code completion, modification, bug fixing, and code translation. Software engineers widely use tools like GitHub Copilot and Amazon Q, streamlining workflows and automating tasks with high accuracy. While the resource and energy intensity of LLM training is often highlighted, inference can be even more resource-intensive over time, as it's a continuous process with a high number of invocations. Therefore, developing resource-efficient alternatives for LLM inference is crucial for sustainability. This work proposes GREEN-CODE, a framework for energy-aware code generation in LLMs. GREEN-CODE performs dynamic early exit during LLM inference. We train a Reinforcement Learning (RL) agent that learns to balance the trade-offs between accuracy, latency, and energy consumption. Our approach is evaluated on two open-source LLMs, Llama 3.2 3B and OPT 2.7B, using the JavaCorpus and PY150 datasets. Results show that our method reduces the energy consumption between 23-50 % on average for code generation tasks without significantly affecting accuracy.

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

↑