arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2411.10599cs.SEcs.AI
收藏

使用LLMs生成节能代码

Generating Energy-efficient code with LLMs

Informatics Institute Universiteit van Amsterdam Amsterdam, The Netherlands(信息学院荷兰阿姆斯特丹大学)

Tom Cappendijk, Pepijn de Reus, Ana Oprescu

AI总结:

本研究通过修改提示词(如添加节能指令或最佳实践)测试五种LLM在三个Python问题上的代码生成能耗,发现特定组合可降低能耗,但无统一提示词对所有问题有效。

摘要:

个人电脑、通信网络和数据中心日益增长的电力需求导致了更高的大气温室气体排放,进而引发全球变暖和气候变化。因此,必须最小化代码的能耗。代码可以由大型语言模型生成。我们研究了提示词修改对生成代码能耗的影响。我们使用了三个难度不同的Python代码问题。提示词修改通过添加句子“给我一个针对此问题的节能优化解决方案”或使用两种Python编码最佳实践来实现。使用的大型语言模型包括CodeLlama-70b、CodeLlama-70b-Instruct、CodeLlama-70b-Python、DeepSeek-Coder-33b-base和DeepSeek-Coder-33b-instruct。我们发现,对于特定的提示词优化、LLM和Python代码问题的组合,能耗有所降低。然而,对于同一LLM,在不同的Python代码问题上,没有单一的优化提示词能持续降低能耗。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑