Generating Energy-efficient code with LLMs

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Cappendijk, Tom, de Reus, Pepijn, Oprescu, Ana
Natura: Preprint
Pubblicazione: 2024
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866918067072663552
author Cappendijk, Tom
de Reus, Pepijn
Oprescu, Ana
author_facet Cappendijk, Tom
de Reus, Pepijn
Oprescu, Ana
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2411_10599
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Generating Energy-efficient code with LLMs
Cappendijk, Tom
de Reus, Pepijn
Oprescu, Ana
Software Engineering
Artificial Intelligence
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.
title Generating Energy-efficient code with LLMs
topic Software Engineering
Artificial Intelligence
url https://arxiv.org/abs/2411.10599