arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2312.14949cs.SEcs.AIcs.HCcs.PF
收藏

开源 Python 库的 LLM 交互式优化——案例研究与泛化

LLM Interactive Optimization of Open Source Python Libraries -- Case Studies and Generalization

Deutsche Telekom AG(德国电信公司)

Andreas Florath

AI总结:

本文通过对 pillow 与 numpy 的交互式 LLM 代码优化案例,证明 ChatGPT-4 在人类专家参与下可带来最高 38 倍的性能提升,并探讨可复现性与泛化。

摘要:

随着 GPT-3 等大型语言模型(LLM)的出现,一个自然的问题是:这些模型在多大程度上可用于源代码优化。本文介绍了应用于知名开源 Python 库 pillow 和 numpy 的、方法学上严格的案例研究。我们发现,当代 LLM ChatGPT-4(2023 年 9 月和 10 月的状态)在优化能源和计算效率方面出人意料地熟练。然而,这仅发生在交互式使用、由人类专家参与回路的情况下。由于意识到实验者偏差,我们详细记录了定性方法,并提供了对话记录和源代码。我们首先详细描述了为优化 pillow 库中的 _getextrema 函数而与 LLM 对话的方法,并对性能提升进行了定量评估。为证明定性可复现性,我们报告了在 pillow 库另一个位置以及 numpy 库中一个代码位置上的进一步尝试,以展示在同一库内部和跨出库边界的泛化能力。在所有尝试中,性能提升都很显著(最高达 38 倍)。我们也没有遗漏对失败尝试的报告(没有失败尝试)。我们得出结论:LLM 是优化开源库代码的一种有前景的工具,但回路中的人类专家对于成功至关重要。尽管如此,我们仍惊讶于只需很少的迭代就能获得显著的性能提升,而这些提升对回路中的专家而言并不显而易见。我们希望引起人们对本研究定性性质的关注;更稳健的定量研究需要引入一个在代表性样本中选择专家的层级——我们邀请社区开展合作。

英文摘要:

With the advent of large language models (LLMs) like GPT-3, a natural question is the extent to which these models can be utilized for source code optimization. This paper presents methodologically stringent case studies applied to well-known open source python libraries pillow and numpy. We find that contemporary LLM ChatGPT-4 (state September and October 2023) is surprisingly adept at optimizing energy and compute efficiency. However, this is only the case in interactive use, with a human expert in the loop. Aware of experimenter bias, we document our qualitative approach in detail, and provide transcript and source code. We start by providing a detailed description of our approach in conversing with the LLM to optimize the _getextrema function in the pillow library, and a quantitative evaluation of the performance improvement. To demonstrate qualitative replicability, we report further attempts on another locus in the pillow library, and one code locus in the numpy library, to demonstrate generalization within and beyond a library. In all attempts, the performance improvement is significant (factor up to 38). We have also not omitted reporting of failed attempts (there were none). We conclude that LLMs are a promising tool for code optimization in open source libraries, but that the human expert in the loop is essential for success. Nonetheless, we were surprised by how few iterations were required to achieve substantial performance improvements that were not obvious to the expert in the loop. We would like bring attention to the qualitative nature of this study, more robust quantitative studies would need to introduce a layer of selecting experts in a representative sample -- we invite the community to collaborate.

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

↑