Generating Energy-efficient code with LLMs
- URL: http://arxiv.org/abs/2411.10599v2
- Date: Sun, 22 Jun 2025 20:33:59 GMT
- Title: Generating Energy-efficient code with LLMs
- Abstract summary: We look at the influence of prompt modification on the energy consumption of the code generated.<n>The large language models used are CodeLlama-70b, CodeLlama-70b-Instruct, CodeLlama-70b-Python, DeepSeek-Coder-33b-base, and DeepSeek-Coder-33b-instruct.
- Score: 0.0
- License: http://creativecommons.org/licenses/by/4.0/
- 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 minimized. Code can be generated by large language models. We look at the influence of prompt modification on the energy consumption of the code generated. We use three different Python code problems of varying difficulty levels. Prompt modification is done by adding the sentence ``Give me an energy-optimized solution for this problem'' or by using two Python coding best practices. The large language models used are CodeLlama-70b, CodeLlama-70b-Instruct, CodeLlama-70b-Python, DeepSeek-Coder-33b-base, and DeepSeek-Coder-33b-instruct. We find a decrease in energy consumption for a specific combination of prompt optimization, LLM, and Python code problem. However, no single optimization prompt consistently decreases energy consumption for the same LLM across the different Python code problems.
Related papers
- Generating Energy-Efficient Code via Large-Language Models -- Where are we now? [2.561129176520328]
Large Language Models (LLMs) have led to their widespread adoption in development pipelines.<n>We empirically assess the energy efficiency of Python code generated by LLMs against human-written code and code developed by a Green software expert.
arXiv Detail & Related papers (2025-09-12T09:49:46Z) - Toward Green Code: Prompting Small Language Models for Energy-Efficient Code Generation [0.5486463492959637]
There is a growing concern about the environmental impact of large language models (LLMs) in software development.<n>This study investigates whether prompt engineering can improve the energy efficiency of SLMs in code generation.<n>We evaluate four open-source SLMs, StableCode-Instruct-3B, Qwen2.5-Coder-3B-Instruct, CodeLlama-7B-Instruct, and Phi-3-Mini-4K-Instruct, across 150 Python problems from LeetCode.
arXiv Detail & Related papers (2025-09-12T03:38:15Z) - Energy-Aware Code Generation with LLMs: Benchmarking Small vs. Large Language Models for Sustainable AI Programming [2.588812622437082]
We evaluate open-source Small Language Models (SLMs) trained explicitly for code generation against large Large Language Models (LLMs) and efficient human-written Python code.<n>We evaluate 150 coding problems from LeetCode, evenly distributed across three difficulty levels: easy, medium, and hard.<n>LLMs achieve the highest correctness across all difficulty levels, but SLMs are often more energy-efficient when their outputs are correct.
arXiv Detail & Related papers (2025-08-10T14:44:06Z) - An Empirical Study on the Performance and Energy Usage of Compiled Python Code [5.829253903555323]
Python is a popular programming language known for its ease of learning and extensive libraries.<n>There is limited analysis comparing their performance and energy efficiency.<n>Our study investigates how compilation impacts the performance and energy consumption of Python code.
arXiv Detail & Related papers (2025-05-05T04:01:56Z) - ChatGPT vs. DeepSeek: A Comparative Study on AI-Based Code Generation [0.0]
This research compares ChatGPT and DeepSeek for Python code generation using online judge coding challenges.
It evaluates correctness (online judge verdicts, up to three attempts), code quality (Pylint/Flake8), and efficiency (execution time/memory usage)
DeepSeek demonstrated higher correctness, particularly on algorithmic tasks, often achieving 'Accepted' on the first attempt.
arXiv Detail & Related papers (2025-01-30T16:14:48Z) - How Maintainable is Proficient Code? A Case Study of Three PyPI Libraries [3.0105723746073]
We investigate the risk level of proficient code inside a file.
We identify several instances of high proficient code that was also high risk.
We envision that the study should help developers identify scenarios where proficient code might be detrimental to future code maintenance activities.
arXiv Detail & Related papers (2024-10-08T04:45:11Z) - Refactoring to Pythonic Idioms: A Hybrid Knowledge-Driven Approach Leveraging Large Language Models [23.181371435793494]
Many Python users find it challenging to use Pythonic idioms.
Motivated by the determinism of rules and adaptability of LLMs, we propose a hybrid approach.
arXiv Detail & Related papers (2024-06-06T00:22:46Z) - A Controlled Experiment on the Energy Efficiency of the Source Code Generated by Code Llama [4.937787069991124]
83% of software developers use Large Language Models (LLMs) to generate code.
This paper assesses the energy efficiency of Code Llama with respect to human-written source code.
arXiv Detail & Related papers (2024-05-06T16:32:29Z) - Code Prompting Elicits Conditional Reasoning Abilities in Text+Code LLMs [65.2379940117181]
We introduce code prompting, a chain of prompts that transforms a natural language problem into code.
We find that code prompting exhibits a high-performance boost for multiple LLMs.
Our analysis of GPT 3.5 reveals that the code formatting of the input problem is essential for performance improvement.
arXiv Detail & Related papers (2024-01-18T15:32:24Z) - Code Llama: Open Foundation Models for Code [93.30115424203868]
We release Code Llama, a family of large language models for code based on Llama 2.
Code Llama reaches state-of-the-art performance among open models on several code benchmarks.
We release Code Llama under a permissive license that allows for both research and commercial use.
arXiv Detail & Related papers (2023-08-24T17:39:13Z) - WizardCoder: Empowering Code Large Language Models with Evol-Instruct [67.24653703564492]
We introduce WizardCoder, which empowers Code LLMs with complex instruction fine-tuning.
Our model surpasses all other open-source Code LLMs by a substantial margin.
arXiv Detail & Related papers (2023-06-14T15:18:48Z) - CodeT5+: Open Code Large Language Models for Code Understanding and
Generation [72.1638273937025]
Large language models (LLMs) pretrained on vast source code have achieved prominent progress in code intelligence.
CodeT5+ is a family of encoder-decoder LLMs for code in which component modules can be flexibly combined to suit a wide range of downstream code tasks.
We extensively evaluate CodeT5+ on over 20 code-related benchmarks in different settings, including zero-shot, finetuning, and instruction-tuning.
arXiv Detail & Related papers (2023-05-13T14:23:07Z) - AceCoder: Utilizing Existing Code to Enhance Code Generation [45.034292331340524]
Existing prompting techniques are designed for natural language generation and have low accuracy in code generation.
AceCoder contains two novel mechanisms (i.e., guided code generation and example retrieval) to solve these challenges.
Results show that AceCoder can significantly improve the performance of LLMs on code generation.
arXiv Detail & Related papers (2023-03-31T02:57:15Z) - PyGlove: Efficiently Exchanging ML Ideas as Code [81.80955202879686]
PyGlove represents ideas as symbolic rule-based patches, enabling researchers to write down the rules for models they have not seen.
This permits a network effect among teams: at once, any team can issue patches to all other teams.
arXiv Detail & Related papers (2023-02-03T18:52:09Z) - PAL: Program-aided Language Models [112.94785609781503]
We present Program-Aided Language models (PaL) to understand natural language problems.
PaL offloads the solution step to a programmatic runtime such as a Python interpreter.
We set new state-of-the-art results in all 12 benchmarks.
arXiv Detail & Related papers (2022-11-18T18:56:13Z)
This list is automatically generated from the titles and abstracts of the papers in this site.
This site does not guarantee the quality of this site (including all information) and is not responsible for any consequences.