# Improving the Energy-Efficiency of the Code Generated by LLMs through Effective Prompting

DevFeed: [Improving the Energy-Efficiency of the Code Generated by LLMs through Effective Prompting](<https://devfeed.tech/articles/improving-the-energy-efficiency-of-the-code-generated-by-llms-through-effective-prompting-99841.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2610.02571>)

Author: Ritika Rekhi, Bing Zhang, Md Arman Islam, Jaya Krishna Pasham, Yeswanth Chitturi, Akshay Paramesha, Isha Valiveti, Asif Imran, Bekir Turkkan, Tevfik Kosar

Published: 2026-10-26T04:00:00Z

Content type: article

Language: en

Sources: [arXiv: Artificial Intelligence](<https://devfeed.tech/sources/arxiv-artificial-intelligence.md>), [arXiv: Software Engineering](<https://devfeed.tech/sources/arxiv-software-engineering.md>)

Topics: [Green Software](<https://devfeed.tech/topics/green-software.md>), [Sustainable Computing](<https://devfeed.tech/topics/sustainable-computing.md>), [Prompt Engineering](<https://devfeed.tech/topics/prompt-engineering.md>), [Code quality](<https://devfeed.tech/topics/code-quality.md>), [Claude](<https://devfeed.tech/topics/claude.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [ai-assisted-programming](<https://devfeed.tech/tags/ai-assisted-programming.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [code](<https://devfeed.tech/tags/code.md>), [code-generation](<https://devfeed.tech/tags/code-generation.md>), [cs-ai](<https://devfeed.tech/tags/cs-ai.md>), [cs-se](<https://devfeed.tech/tags/cs-se.md>), [effective-prompting](<https://devfeed.tech/tags/effective-prompting.md>), [efficiency](<https://devfeed.tech/tags/efficiency.md>), [energy](<https://devfeed.tech/tags/energy.md>), [energy-efficiency](<https://devfeed.tech/tags/energy-efficiency.md>), [evaluation](<https://devfeed.tech/tags/evaluation.md>), [llms](<https://devfeed.tech/tags/llms.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [prompting](<https://devfeed.tech/tags/prompting.md>), [python](<https://devfeed.tech/tags/python.md>), [software](<https://devfeed.tech/tags/software.md>), [strategies](<https://devfeed.tech/tags/strategies.md>)

## AI overview

The study reports that prompting can reduce the energy use of LLM-generated code, though results vary by model and language. It evaluated eight selected strategies against a baseline across 10 open-weight and proprietary models, generating Python and C++ code. Across models, reductions reached 25% for Python and 17% for C++; reported model-specific peaks included 50% for Granite-4.0-H-Small in Python and 57% for the same model in C++. The abstract gives no details about individual prompting strategies or measurement methods.

## Source excerpt

arXiv:2610.02571v2 Announce Type: replace-cross Abstract: As AI-assisted programming becomes increasingly mainstream, the environmental impact of AI-generated software has emerged as an important consideration. This motivates evaluating LLM-generated code beyond functional correctness by considering execution efficiency and energy consumption. However, despite substantial advances in code generation, frontier LLMs are rarely evaluated based on the energy efficiency of the code they produce. In this work, we conduct a comprehensive evaluation of 21 prompting strategies for energy-efficient code generation and identify 8 strategies for evaluation across 10 widely used open-weight and proprietary LLMs. We evaluate their effectiveness for both Python and C++ code generation relative to a baseline prompt. Across the evaluated models, the selected prompting strategies achieved energy reductions of up to 25% for Python and 17% for C++ code generation. At the model level, Python energy reductions reached up to 50% for Granite-4.0-H-Small, 39% for Claude 4.5 Haiku, and 28% for MiniMax M3, while C++ reductions reached up to 57% for Granite-4.0-H-Small and 6.4% for Qwen3-Coder-480B-A35B-Instruct. These results demonstrate that prompting strategies can substantially influence the energy consumption of LLM-generated code, although their effectiveness varies across models and programming languages. Our findings highlight the importance of incorporating energy efficiency into the evaluation and optimization of LLM-based code generation and provide practical insights into designing prompts for more sustainable AI-assisted programming.