Controlling the Mutation in Large Language Models for the Efficient Evolution of Algorithms

Haoran Yin, Anna V. Kononova, Thomas Bäck, Niki van SteinarXiv 2024

Abstract

The integration of Large Language Models (LLMs) with evolutionary computation (EC) has introduced a promising paradigm for automating the design of metaheuristic algorithms. However, existing frameworks, such as the Large Language Model Evolutionary Algorithm (LLaMEA), often lack precise control over mutation mechanisms, leading to inefficiencies in solution space exploration and potentially suboptimal convergence. This paper introduces a novel approach to mutation control within LLM-driven evolutionary frameworks, inspired by theory of genetic algorithms. Specifically, we propose dynamic mutation prompts that adaptively regulate mutation rates, leveraging a heavy-tailed power-law distribution to balance exploration and exploitation. Experiments using GPT-3.5-turbo and GPT-4o models demonstrate that GPT-3.5-turbo fails to adhere to the specific mutation instructions, while GPT-4o is able to adapt its mutation based on the prompt engineered dynamic prompts. Further experiments show that the introduction of these dynamic rates can improve the convergence speed and adaptability of LLaMEA, when using GPT-4o. This work sets the starting point for better controlled LLM-based mutations in code optimization tasks, paving the way for further advancements in automated metaheuristic design.

Introduction

In the field of Evolutionary Computation (EC), metaheuristic algorithms are traditionally hand-crafted by experts to solve complex optimization problems. The emergence of frameworks like LLaMEA (Large Language Model Evolutionary Algorithm) has enabled the automated evolution of these algorithms by using LLMs as mutation operators. However, a significant challenge remains: LLMs are often treated as black boxes. Without precise control, an LLM might introduce excessive changes that destroy functional logic or insufficient changes that lead to stagnation. This research explores how to "steer" the LLM's creativity by applying classical evolutionary theory to natural language prompts.

Methodology: The Evolutionary Loop

To address the lack of control, the researchers integrated a dynamic mutation rate into the LLaMEA framework. The process follows a (1+1) evolutionary strategy where the LLM acts as the generator of algorithmic variants.

The LLaMEA evolutionary loop incorporating LLM-driven mutation and performance evaluation.

The loop begins with an initial code instance. The LLM is then prompted to mutate this code based on a specific requested mutation rate. The resulting "child" algorithm is evaluated using the IOHexperimenter platform on the BBOB (Black-Box Optimization Benchmarking) suite. If the child outperforms the parent (measured by the Area Over the Convergence Curve - AOCC), it becomes the new parent for the next iteration. This cycle continues until the computational budget is exhausted.

Theory-Driven Mutation Control

The core innovation lies in applying the $fmut_\beta$ operator from evolutionary theory to the prompting process. This operator utilizes a heavy-tailed power-law distribution to determine mutation intensity.

Probability distributions for different β values in the heavy-tailed mutation operator, balancing exploration and exploitation.

As shown in the distribution plot, this approach favors many small, refining mutations (low mutation rates) while maintaining a non-negligible probability for large, transformative changes. This balance is crucial for escaping local optima while still allowing for fine-tuning. The researchers tested 11 different prompt styles to see if LLMs could adhere to these mathematical constraints, ranging from simple instructions to complex, context-aware prompts that calculated specific line-change targets.

Key Findings and Results

The experiments revealed a stark contrast between models:

  • GPT-3.5-turbo was found to be "mutation-blind." It consistently failed to follow specific rate instructions, often making sweeping changes regardless of the prompt's requested intensity.
  • GPT-4o demonstrated a sophisticated ability to adhere to target mutation rates, particularly when provided with detailed mathematical constraints (e.g., Prompt 5).

When using GPT-4o with these dynamic mutation prompts, the LLaMEA framework showed significantly improved convergence speeds and higher AOCC scores compared to the baseline version that lacked mutation control. This proves that theory-driven prompting can successfully translate abstract evolutionary concepts into concrete code modifications.

Conclusion and Future Work

This research demonstrates that classical genetic algorithm concepts can be successfully used to guide LLM behavior in code space. While the success is currently dependent on the model's reasoning capabilities (as seen with GPT-4o's superiority over GPT-3.5), it opens the door for more efficient automated algorithm design. Future work will explore the use of smaller, open-source models and more refined metrics for functional code changes beyond simple line-difference counts.

Summary updated

BibTeX
@misc{yin2024controlling,
  author = {Haoran Yin and Anna V. Kononova and Thomas Bäck and Niki van Stein},
  title = {{Controlling the Mutation in Large Language Models for the Efficient Evolution of Algorithms}},
  year = {2024},
  eprint = {2412.03250},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.03250},
}
Figure