An exploration of prompting LLMs to generate energy-efficient code
| Authors |
|
|---|---|
| Publication date | 2025 |
| Book title | GREENS 2025 : 2025 IEEE/ACM 9th International Workshop on Green and Sustainable Software |
| Book subtitle | Ottawa, Ontario, Canada, 29 April 2025 : proceedings |
| ISBN |
|
| ISBN (electronic) |
|
| Event | 9th IEEE/ACM International Workshop on Green and Sustainable Software, GREENS 2025 |
| Pages (from-to) | 31-38 |
| Number of pages | 8 |
| Publisher | Los Alamitos, California: IEEE Computer Society |
| Organisations |
|
| Abstract |
The increasing electricity demands of personal computers, communication networks, and data centers contribute to higher atmospheric greenhouse gas emissions, which in turn lead to global warming and climate change. Therefore the energy consumption of code must be minimised. Large language models can generate code, so we study the influence of prompting for energy-efficient code by examining the energy consumption of the generated code. We use three different Python code problems of varying difficulty levels. Prompt modification is done by adding the sentence "Give me an energy-optimised solution for this problem"or by providing two Python coding best practices. The large language models used are Code Llama-70b, Code Llama-70b-Instruct, Code Llama-70b-Python, DeepSeek-Coder-33b-base, and DeepSeek-Coder-33b-instruct. We find a decrease in energy consumption for a specific combination of prompt optimisation, LLM, and Python code problem. However, no single optimisation prompt consistently decreases energy consumption for the same LLM across the different Python code problems. |
| Document type | Conference contribution |
| Language | English |
| Published at |
https://doi.org/10.1109/GREENS66463.2025.00010
(Final published version)
|
| Other links | |
| Downloads |
An_exploration_of_prompting_LLMs_to_generate_energy-efficient_code
(Final published version)
|
| Permalink to this page | |
