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

Ritika Rekhi, Bing Zhang, Md Arman Islam, Jaya Krishna Pasham, Yeswanth Chitturi +5 more
10/1/2026
cs.SEcs.AI

No confident code implementation found for this paper.

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{rekhi2026improving,
  title  = {Improving the Energy-Efficiency of the Code Generated by LLMs through Effective Prompting},
  author = {Ritika Rekhi and Bing Zhang and Md Arman Islam and Jaya Krishna Pasham and Yeswanth Chitturi and Akshay Paramesha and Isha Valiveti and Asif Imran and Bekir Turkkan and Tevfik Kosar},
  year   = {2026},
  eprint = {2610.02571},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2610.02571v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2610.02571.svg)](https://codeofpaper.com/paper/2610.02571)

Discussion