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

Code Llama 生成源代码能效的受控实验

A Controlled Experiment on the Energy Efficiency of the Source Code Generated by Code Llama

Vrije Universiteit Amsterdam(阿姆斯特丹自由大学)

Vlad-Andrei Cursaru, Laura Duits, Joel Milligan, Damla Ural, Berta Rodriguez Sanchez, Vincenzo Stoico, Ivano Malavolta

AI总结:

本文通过 C++、JavaScript 和 Python 三个基准的受控实验评估 Code Llama 生成代码的能效,发现其能效高度依赖编程语言和具体问题,人工实现总体更节能,且显式要求节能或调整温度参数均不能保证能效提升。

摘要:

背景。如今,83% 的软件开发者使用大语言模型(LLMs)生成代码。LLMs 最近已成为提高软件开发者生产力、降低软件开发时间和成本的关键工具。从新手到专家的开发者不仅使用 LLM 工具检测和修复缺陷,还将生成的代码集成到其软件中。然而,迄今为止,尚无对 LLM 工具生成源代码能效的客观评估。Code Llama 于 2023 年 8 月发布,是最新的 LLM 工具之一。目标。本文提出一项实证研究,评估 Code Llama 相对于人工编写源代码的能效。方法。我们设计了一个实验,涉及三个分别用 C++、JavaScript 和 Python 实现的人工编写基准。我们要求 Code Llama 使用不同的提示和温度参数生成这些基准的代码。随后,我们执行两种实现并分析其能效。结果。研究表明,Code Llama 生成代码的能效高度依赖于所选择的编程语言和具体代码问题。同时,人工实现总体上往往更节能,但生成的 JavaScript 代码优于其人工对应实现。此外,明确要求 Code Llama 生成节能代码会导致能效相同或更差,而使用不同温度参数似乎不影响生成代码的能效。结论。根据我们的结果,使用 Code Llama 生成的代码并不能保证能效,即使被提示要求如此。因此,软件开发者应在将生成代码集成到正在开发的软件系统之前评估其能效。

英文摘要:

Context. Nowadays, 83% of software developers use Large Language Models (LLMs) to generate code. LLMs recently became essential to increase the productivity of software developers and decrease the time and cost of software development. Developers ranging from novices to experts use LLM tools not only to detect and patch bugs, but also to integrate generated code into their software. However, as of today there is no objective assessment of the energy efficiency of the source code generated by LLM tools. Released in August 2023, Code Llama is one of the most recent LLM tools. Goal. In this paper, we present an empirical study that assesses the energy efficiency of Code Llama with respect to human-written source code. Method. We design an experiment involving three human-written benchmarks implemented in C++, JavaScript, and Python. We ask Code Llama to generate the code of the benchmarks using different prompts and temperatures. Therefore, we execute both implementations and profile their energy efficiency. Results. Our study shows that the energy efficiency of code generated by Code Llama is heavily-dependent on the chosen programming language and the specific code problem at hand. Also, human implementations tend to be more energy efficient overall, with generated JavaScript code outperforming its human counterpart. Moreover, explicitly asking Code Llama to generate energy-efficient code results in an equal or worse energy efficiency, as well as using different temperatures seems not to affect the energy efficiency of generated code. Conclusions. According to our results, code generated using Code Llama does not guarantee energy efficiency, even when prompted to do so. Therefore, software developers should evaluate the energy efficiency of generated code before integrating it into the software system under development.

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

↑