Large language models as surrogate models in evolutionary algorithms: A preliminary study

Hao Hao, Xiaoqun Zhang, Aimin Zhou

Introduction

Evolutionary Algorithms (EAs) are powerful tools for black-box optimization but often require a high number of fitness evaluations. In "expensive" optimization scenarios—such as aerodynamic design or drug discovery—each evaluation can be computationally or financially prohibitive. To mitigate this, Surrogate-Assisted Evolutionary Algorithms (SAEAs) employ cheaper approximation models (e.g., Gaussian Processes or Neural Networks) to guide the search. However, traditional surrogates require explicit training and often struggle with high-dimensional spaces or complex constraints.

This study explores the potential of Large Language Models (LLMs) to serve as zero-shot surrogate models. By leveraging their inherent pattern-recognition and in-context learning capabilities, LLMs can predict solution fitness directly from text-based prompts, bypassing the need for traditional model training.

Methodology: The LLM-assisted Evolutionary Algorithm (LAEA)

The proposed LAEA framework shifts the surrogate modeling paradigm from "train-then-predict" to "prompt-and-infer." The process involves several key stages to translate numerical optimization data into a format suitable for linguistic processing.

Integration of LLMs as surrogate models within the Evolutionary Algorithm framework.
  1. Data Preprocessing: Numerical coordinates and fitness values are normalized to a [0, 1] range and rounded (e.g., to three decimal places) to enhance readability for the LLM.
  2. Prompt Engineering: A structured text prompt is constructed containing a task description, historical examples (acting as the "training set" within the context window), and the new candidate solution to be evaluated.
  3. Task Modes: The LLM can operate in two modes: Regression, where it predicts the numerical fitness value, or Classification, where it categorizes solutions as "better" or "worse" based on a percentile threshold.
  4. Integration: The LLM's predictions are used during the selection phase of the EA to prioritize promising offspring for actual expensive evaluation.

Experimental Setup

The study benchmarks nine mainstream LLMs across four classic optimization functions: Ellipsoid, Rosenbrock, Ackley, and Griewank. These functions represent various challenges, including convexity, non-convexity, and multiple local minima. Tests were conducted in 2D, 5D, and 10D spaces.

Overview of the Large Language Models evaluated in the study.

The models evaluated include both proprietary systems like GPT-4 and open-source models such as Llama 3, Mixtral, and Phi-3, with varying levels of quantization as shown in the table above.

Key Insights and Results

The preliminary results indicate that LLMs are surprisingly capable surrogates:

  • Regression Performance: LLMs performed significantly better at regression than classification. The continuous nature of regression tasks appears to help the models better capture the underlying function distribution.
  • Competitive Accuracy: The LAEA variant using Llama3-8B achieved performance comparable to state-of-the-art traditional surrogates like Bayesian Optimization (BO).
  • Visual Intuition: In 2D visualizations, the "fitness landscapes" predicted by models like GPT-4 and Llama3-8B closely mirrored the actual mathematical topologies, demonstrating a form of "numerical intuition."
  • Impact of Quantization: 4-bit quantized models showed a slight decline in accuracy compared to full-precision models, suggesting that numerical sensitivity is affected by model compression.

Discussion and Future Work

While promising, using LLMs as surrogates presents unique challenges. Tokenizers often split numbers into multiple tokens, potentially disrupting the model's numerical understanding. Additionally, the finite context window limits the amount of historical data that can be provided, and transformers can exhibit sensitivity to the order of examples in a prompt.

Future research directions include fine-tuning LLMs specifically for numerical tasks, utilizing specialized high-speed inference hardware, and exploring the ability of LLMs to handle multi-modal or non-numerical optimization constraints that traditional surrogates cannot easily process.

Summary updated

BibTeX
@article{hao2024large,
  author = {Hao Hao and Xiaoqun Zhang and Aimin Zhou},
  title = {{Large language models as surrogate models in evolutionary algorithms: A preliminary study}},
  journal = {Swarm Evol. Comput.},
  year = {2024},
  doi = {10.1016/j.swevo.2024.101741},
}
Figure