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

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Ilager, Shashikant, Briem, Lukas Florian, Brandic, Ivona
Format: Preprint
Publié: 2025
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866916658683052032
author Ilager, Shashikant
Briem, Lukas Florian
Brandic, Ivona
author_facet Ilager, Shashikant
Briem, Lukas Florian
Brandic, Ivona
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2501_11006
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle GREEN-CODE: Learning to Optimize Energy Efficiency in LLM-based Code Generation
Ilager, Shashikant
Briem, Lukas Florian
Brandic, Ivona
Distributed, Parallel, and Cluster Computing
Artificial Intelligence
Performance
Software Engineering
C.4; D.0; E.4; I.7
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.
title GREEN-CODE: Learning to Optimize Energy Efficiency in LLM-based Code Generation
topic Distributed, Parallel, and Cluster Computing
Artificial Intelligence
Performance
Software Engineering
C.4; D.0; E.4; I.7
url https://arxiv.org/abs/2501.11006