LLM Interactive Optimization of Open Source Python Libraries -- Case Studies and Generalization
Abstract: With the advent of 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.
- “ChatGPT 4” Accessed: 2023-09-16 URL: https://chat.openai.com
- Uchechukwu Awada, Keqiu Li and Yanming Shen “Energy Consumption in Cloud Computing Data Centers” In International Journal of Cloud Computing and Services Science (IJ-CLOSER) 3, 2014 DOI: 10.11591/closer.v3i3.6346
- “Data Centres and Data Transmission Networks” Accessed: 2023-11-24 URL: https://www.iea.org/energy-system/buildings/data-centres-and-data-transmission-networks
- “Technical debt and agile software development practices and processes: An industry practitioner survey” In CoRR abs/2104.14761, 2021 arXiv: https://arxiv.org/abs/2104.14761
- “Identification and Measurement of Technical Debt Requirements in Software Development: a Systematic Literature Review” In CoRR abs/2105.14232, 2021 arXiv: https://arxiv.org/abs/2105.14232
- “Technical Debt, Agile, and Sustainability” Accessed: 2023-11-24 URL: https://learn.greensoftware.foundation/
- “A Case for Sustainability and Environment Friendliness in Software Development and Architecture Decisions by Taking Energy-Efficient Design Decisions”, 2023 arXiv:2311.01680 [cs.SE]
- “Large Language Models for Software Engineering: A Systematic Literature Review”, 2023 arXiv:2308.10620 [cs.SE]
- “Using Transfer Learning for Code-Related Tasks” In IEEE Transactions on Software Engineering 49.4, 2023, pp. 1580–1598 DOI: 10.1109/TSE.2022.3183297
- Zimin Chen, Sen Fang and Martin Monperrus “Supersonic: Learning to Generate Source Code Optimizations in C/C++”, 2023 arXiv:2309.14846 [cs.SE]
- “Learning Performance-Improving Code Edits”, 2023 arXiv:2302.07867 [cs.SE]
- “Sparks of Artificial General Intelligence: Early experiments with GPT-4”, 2023 arXiv:2303.12712 [cs.CL]
- “Analysis of ChatGPT on Source Code”, 2023 arXiv:2306.00597 [cs.SE]
- “Evaluating Large Language Models Trained on Code” In CoRR abs/2107.03374, 2021 arXiv: https://arxiv.org/abs/2107.03374
- “Learning Performance-Improving Code Edits” In arXiv preprint arXiv:2302.07867, 2023
- Jonathan H Choi and Daniel Schwarcz “Ai assistance in legal analysis: An empirical study” In Available at SSRN 4539836, 2023
- Peter Lee, Sebastien Bubeck and Joseph Petro “Benefits, limits, and risks of GPT-4 as an AI chatbot for medicine” In New England Journal of Medicine 388.13 Mass Medical Soc, 2023, pp. 1233–1239
- “Navigating the jagged technological frontier: Field experimental evidence of the effects of AI on knowledge worker productivity and quality” In Harvard Business School Technology & Operations Mgt. Unit Working Paper, 2023
- “Experimental evidence on the productivity effects of generative artificial intelligence” In Available at SSRN 4375283, 2023
- “The impact of ai on developer productivity: Evidence from github copilot” In arXiv preprint arXiv:2302.06590, 2023
- “pipexec - Build a network of processes and connecting pipes” Accessed: 2023-11-29 URL: https://github.com/flonatel/pipexec
- “rmToo - Open Source Requirements Management Tool” Accessed: 2023-11-29 URL: https://github.com/florath/rmtoo
- “Pillow: ImageStat Module” Accessed: 2023-09-19 URL: https://pillow.readthedocs.io/en/stable/reference/ImageStat.html
- Deutsche Telekom “Deutsche Telekom Promtathon” Accessed: 2023-09-16 URL: https://www.linkedin.com/feed/update/urn:li:activity:7108471295427719168/
- “Synapse CoR” Accessed: 2023-11-29 URL: https://github.com/ProfSynapse/Synapse_CoR
- “ImageNet Large Scale Visual Recognition Challenge” In International Journal of Computer Vision (IJCV) 115.3, 2015, pp. 211–252 DOI: 10.1007/s11263-015-0816-y
- “Python timeit library: repeat” Accessed: 2023-09-17, see timeit.Timer.repeat URL: https://docs.python.org/3/library/timeit.html
- “Python timeit library” Accessed: 2023-09-17 URL: https://docs.python.org/3/library/timeit.html
- “Optimize ImageStat.Stat._getextrema function” Accessed: 2023-12-05 URL: https://github.com/python-pillow/Pillow/pull/7593/
- “Optimize ImageStat.Stat._getcount function” Accessed: 2023-12-05 URL: https://github.com/python-pillow/Pillow/pull/7599/
- “Performance improvement of polyutils.as_series” Accessed: 2023-12-05 URL: https://github.com/numpy/numpy/pull/25299
- “Source Code for the paper ”LLM Interactive Optimization of Open Source Python Libraries - Case Studies and Generalization”” Accessed: 2023-11-27 URL: https://github.com/florath/LLMInteractiveOptOfPythonLibs
- “Pillow/src/PIL/ImageStats.py” Line 52, Accessed: 2023-09-16 URL: https://github.com/python-pillow/Pillow/blob/main/src/PIL/ImageStat.py
- “Numpy” Accessed: 2023-09-17 URL: https://numpy.org/
- “Fixedint” Accessed: 2023-09-17 URL: https://github.com/nneonneo/fixedint
- “Python Generators” Accessed: 2023-09-17 URL: https://wiki.python.org/moin/Generators
- “Numpy source code” Line 67, Accessed: 2023-09-20 URL: https://github.com/numpy/numpy/blob/main/numpy/polynomial/polyutils.py
- “Google Bard” Accessed: 2023-09-16 URL: https://bard.google.com
- “Stylish Article” Accessed: 2023-11-01 URL: https://www.latextemplates.com/template/stylish-article
Paper Prompts
Sign up for free to create and run prompts on this paper using GPT-5.
Top Community Prompts
Collections
Sign up for free to add this paper to one or more collections.