Improving the Energy-Efficiency of the Code Generated by LLMs through Effective Prompting
- Source
- arxiv.org
- Author
- Ritika Rekhi, Bing Zhang, Md Arman Islam, Jaya Krishna Pasham, Yeswanth Chitturi, Akshay Paramesha, Isha Valiveti, Asif Imran, Bekir Turkkan, Tevfik Kosar
- Date

Context
Changing the instructions given to an AI model can reduce the energy used by the code it writes, but by amounts that vary widely by model and language. An arXiv paper submitted October 1, 2026 evaluated 21 prompting strategies for energy-efficient code, selected 8, and tested them on 10 and proprietary models against a baseline prompt, generating Python and C++.
The abstract reports energy reductions of up to 25% for Python and 17% for C++ across the evaluated models. Per model, Python reductions reached up to 50% for Granite-4.0-H-Small and 39% for Anthropic's Claude 4.5 Haiku, while C++ reductions reached up to 56% for Granite but only up to 7% for Qwen3-Coder-480B-A35B-Instruct. The authors conclude that effectiveness varies by model and language.
The abstract does not say how the overall figures were aggregated, how energy was measured, or whether the generated code stayed correct. Only the abstract was available, so those details need the full paper.
- The authors screened 21 prompting strategies for energy-efficient code, then tested 8 of them across 10 open-weight and proprietary LLMs on Python and C++ against a baseline prompt.
- Across models, the selected prompts cut energy use of the generated code by up to 25% for Python and up to 17% for C++, measured relative to the baseline prompt.
- Effects vary sharply by model and language: Python reductions reached 50% for Granite-4.0-H-Small and 39% for Claude 4.5 Haiku, while the best C++ result for Qwen3-Coder-480B was only 7%, so no single prompt is a universal fix.
- open weights — A model whose trained parameters are published for anyone to download and run — unlike API-only models you can access but never possess.
- LLM — A large language model — the neural network behind tools like Claude and ChatGPT, trained on huge amounts of text to predict what comes next.
articleDo Influence Tactics Matter? Investigating Prompt Framing Effects in LLM Code GenerationAlex Deaconu, Anubhav Gupta, Manaal Basha, Nicholas Haydu, Gema Rodr\'iguez-P\'erez
articleA Study on the Impact of Natural Language Differences in Prompts on Automatic Code Generation Using LLMsHaruka Tokumasu, Masanari Kondo, Alexander Serebrenik, Dong Wang, Kei Koyanagi, Kotaro Noguchi, Naoyasu Ubayashi, Yasutaka Kamei
articleHow Do Prompt Variations Affect Energy Consumption in On-Device LLMs?Wei Hu, Xiaolong Tu, Dawei Chen, Yitao Chen, Kyungtae Han, Haoxin Wang
Checking sign-in…
Loading comments…