[Paper Review] Towards Objective-Tailored Genetic Improvement Through Large Language Models
This paper proposes integrating large language models (LLMs) as objective-tailored mutators in Genetic Improvement (GI) to generate optimized, correct code variants based on natural language specifications. By using LLMs to create target-specific mutations and validating them through GI's fitness evaluation, the approach improves both optimization effectiveness and code correctness, demonstrating significant synergy between LLMs and GI in optimizing Fibonacci implementations.
While Genetic Improvement (GI) is a useful paradigm to improve functional and nonfunctional aspects of software, existing techniques tended to use the same set of mutation operators for differing objectives, due to the difficulty of writing custom mutation operators. In this work, we suggest that Large Language Models (LLMs) can be used to generate objective-tailored mutants, expanding the possibilities of software optimizations that GI can perform. We further argue that LLMs and the GI process can benefit from the strengths of one another, and present a simple example demonstrating that LLMs can both improve the effectiveness of the GI optimization process, while also benefiting from the evaluation steps of GI. As a result, we believe that the combination of LLMs and GI has the capability to significantly aid developers in optimizing their software.
Motivation & Objective
- To address the limitation of traditional GI, which uses generic mutation operators unsuited to specific optimization objectives.
- To explore whether LLMs can generate objective-tailored code mutations that improve fitness functions like execution time or memory usage.
- To investigate the synergy between LLMs and GI, where LLMs enhance mutation diversity and GI ensures correctness and optimization.
- To reduce manual developer effort in optimizing software by automating objective-specific code improvements.
Proposed method
- Using LLMs (e.g., code-davinci-002) to generate code mutations based on natural language prompts specifying optimization goals such as time or memory efficiency.
- Formulating prompts that include comments marking original inefficient code and desired efficient output, guiding the LLM to produce targeted improvements.
- Applying GI’s evolutionary pipeline: compiling, executing, and evaluating LLM-generated mutants using a fitness function (e.g., execution time).
- Validating LLM-generated code through automated testing and fitness evaluation to ensure correctness and improvement over the original.
- Using the same genetic operators (e.g., insertion, deletion, swapping) as in traditional GI, but replacing random mutations with LLM-driven, objective-aware mutations.
- Combining LLMs’ ability to generate semantically natural and correct code with GI’s rigorous evaluation to filter out incorrect or non-improving variants.
Experimental results
Research questions
- RQ1Can LLMs generate objective-specific code mutations that improve software fitness functions such as execution time or memory usage?
- RQ2How does LLM-generated mutation compare to traditional GI mutation operators in terms of correctness and optimization effectiveness?
- RQ3Can the GI evaluation pipeline enhance the reliability of LLM-generated code by filtering incorrect or suboptimal variants?
- RQ4To what extent does the synergy between LLMs and GI improve the overall quality and correctness of generated software optimizations?
- RQ5Can natural language prompts effectively guide LLMs to produce correct and efficient code improvements for well-known algorithmic problems like Fibonacci computation?
Key findings
- LLMs successfully generated correct, efficient implementations of the Fibonacci function, replacing exponential-time recursion with O(n) iterative solutions.
- LLMs produced memory-optimized versions using only two variables, reducing space complexity from O(n) to O(1), demonstrating objective-specific mutation capability.
- All LLM-generated variants were correct and met the specified optimization goals, indicating high reliability for well-known problems within the model’s training distribution.
- The integration of LLMs with GI enables objective-tailored mutations while ensuring correctness through automated fitness evaluation.
- The approach reduces reliance on hand-crafted mutation operators and enables scalable, developer-friendly software optimization.
- The synergy between LLMs and GI enhances both the diversity of mutations and the reliability of results, suggesting a promising path toward automated software improvement.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.