Skip to content
XAI-liacsPublic

About

Large Language Model Evolutionary Algorithm

Resources

Contributing

Stars

137 stars

Watchers

2 watching

Forks

Repository files navigation

LLaMEA: Large Language Model Evolutionary Algorithm for LLM-driven automated algorithm design

⭐ If you like this, please give the repo a star – it helps!

PyPI version PyPI downloads per month Python 3.11.5+ MIT license Tests Code coverage Maintained

Documentation DOI of the IEEE TEVC paper Zenodo DOI Humies 2025 Silver award Benchmark with BLADE Open In Colab uv Code style: black

The fully open alternative to Google DeepMind's AlphaEvolve for automated algorithm discovery. First released πŸ“… Nov 2024 β€’ MIT License β€’ 100 % reproducible β€’ πŸ₯ˆ Silver Humies 2025 at GECCO.

LLaMEA couples large-language-model reasoning with an evolutionary loop to invent, mutate and benchmark algorithms fully autonomously: the LLM writes code, your evaluation function scores it, and the feedback drives the next generation.

Tip

LLaMEA designs algorithms; BLADE benchmarks them. To compare LLaMEA (or a variant) with other LLM-driven design methods such as EoH, ReEvo, FunSearch or MCTS-AHD on standard problems, with logging, plots and a web app, run it through BLADE. See Running experiments with BLADE. Documentation: xai-liacs.github.io/LLaMEA.

Table of Contents

πŸ”₯ News

Introduction

LLaMEA (Large Language Model Evolutionary Algorithm) uses LLMs such as GPT, Gemini, Claude or local models (Ollama, LM Studio, MLX) to generate and refine algorithms, typically optimisation heuristics, but equally ML pipelines or any other code you can score. Candidates evolve on measured performance and runtime feedback, so no prior algorithm-design expertise is needed.

The LLaMEA framework: the LLM generates algorithms, they are evaluated, and the scores and errors feed the next prompt.

Key features

🧬 Evolution strategies (μ+λ) and (μ,λ) with random, tournament or roulette parent selection
πŸ”€ Operators Mutation and crossover prompts with fixed weights or adaptive selection (e.g. discounted UCB)
πŸŽ›οΈ LLaMEA-HPO In-the-loop hyper-parameter optimisation (SMAC) so the LLM focuses on structure
🎯 Multi-objective Pareto-based selection (non-dominated sorting + crowding) over named objectives
🌱 Diversity Fitness sharing, clearing, novelty search and MAP-Elites
πŸ” Explainable guidance LLaMEA-SAGE: XGBoost + TreeSHAP on code features steer mutations
βœ‚οΈ Diff mode SEARCH/REPLACE patches instead of full rewrites, saving tokens
⚑ Parallel & robust Parallel evaluation with timeouts, population-level evaluation, warm start

Use cases: problem-specific optimisation algorithms, new Bayesian optimisation algorithms for expensive problems, ML pipelines, photonic structure design, game agents, and more.

🧬 LLaMEA variants

The configurations from our papers are available as ready-made classes. They only change defaults, so any LLaMEA argument still works and overrides the preset.

Variant What it does Preset Paper
LLaMEA The base algorithm (5+5), mutation IEEE TEVC 2025
LLaMEA_HPO LLM writes the algorithm and its ConfigSpace; your evaluation tunes it (e.g. SMAC) HPO=True, (5+5), refine-or-redesign ACM TELO 2025
LLaMEA_BO Evolves complete Bayesian optimisation algorithms (4+16), crossover 0.6, budget 100, BO prompt arXiv:2505.21034
LLaMEA_MO Several objectives, NSGA-II-style selection, returns a Pareto front multi_objective=True, (5+10) –
LLaMEA_SAGE Mutations guided by explainable-AI analysis of code features feature_guided_mutation=True arXiv:2601.21511
from llamea import LLaMEA_BO, LLaMEA_MO, get_variant

optimizer = LLaMEA_BO(evaluate, llm)                   # paper defaults
optimizer = LLaMEA_BO(evaluate, llm, budget=200)       # override any argument
optimizer = LLaMEA_MO(evaluate_mo, llm, objectives=["Distance", "Fuel"],
                      task_prompt="...")
Variant = get_variant("hpo")                           # look up by name

🎁 Installation

pip install llamea

Important

Python 3.11.5 or higher is required, plus an API key for your LLM provider (or a local model via Ollama, LM Studio or MLX).

Optional extras:

pip install "llamea[feature-guidance]"   # XGBoost for LLaMEA_SAGE / feature_guided_mutation (~290 MB)
pip install llamea-lite                  # slim install without bundled LLM / HPO dependencies
pip install iohblade                     # BLADE, to benchmark LLaMEA against other methods
From source with uv
git clone https://github.com/XAI-liacs/LLaMEA.git
cd LLaMEA
uv sync                            # core
uv sync --dev --group examples     # tests and example dependencies

Some examples need SWIG (brew install swig / sudo apt-get install swig). The plasmonic photonics problem in benchmarks/tuto_global_optimization_photonics also needs pyGDM2 (uv pip install pyGDM2), which requires numpy<=2.3 and is therefore not part of any group.

πŸ’» Quick Start

Tip

Try the getting-started notebook in Open In Colab.

from llamea import LLaMEA, OpenAI_LLM

llm = OpenAI_LLM(api_key="...", model="gpt-6.2-sol")   # or Gemini_LLM, Anthropic_LLM, Ollama_LLM, ...

def evaluate(solution, logger=None):
    # solution.code holds the generated Python code, solution.name its class name.
    namespace = {}
    exec(solution.code, namespace)
    algorithm = namespace[solution.name](budget=1000, dim=5)
    score = ...                                   # run it on your problem
    solution.set_scores(score, feedback=f"The algorithm scored {score:.3f}.")
    return solution

optimizer = LLaMEA(evaluate, llm, n_parents=4, n_offspring=8, budget=100)
best = optimizer.run()
print(best.name, best.fitness)
print(best.code)

budget is the number of generated and evaluated candidates. LLaMEA maximises by default; pass minimization=True otherwise. Errors raised by the candidate code are best caught in evaluate and passed on with solution.set_scores(score, feedback, error=e), so the LLM can repair them.

πŸ§ͺ Running experiments with BLADE

BLADE (Benchmarking LLM-driven Automated Design and Evolution, GECCO '25) is our benchmarking platform for LLM-driven algorithm design. It runs LLaMEA, including any variant configuration, next to other methods on built-in problem suites (BBOB, MA-BBOB, SBOX-COST, photonics, AutoML, ...) with isolated evaluation, the same budget for every method, seeding, logging, plots and a results web app.

Use LLaMEA directly for your own problem and evaluation function; use BLADE to benchmark, compare and report.

pip install iohblade
iohblade init my-exp          # starter experiment.yml
iohblade check my-exp/experiment.yml
iohblade run my-exp/experiment.yml
# experiment.yml
experiment: {output_dir: results/my-exp, runs: 5, budget: 100}
llms:
  gemini: {provider: gemini, model: gemini-3.8-flash, api_key: "${env:GEMINI_API_KEY}"}
methods:
  - {type: llamea, name: "LLaMEA-{llm}", llm: gemini}
  - type: llamea                      # LLaMEA-HPO
    name: "LLaMEA-HPO-{llm}"
    llm: gemini
    params: {HPO: true, n_parents: 5, n_offspring: 5}
  - {type: random_search, name: "RS-{llm}", llm: gemini}
problems:
  - {type: bbob_sbox, name: SBOX-COST}   # supports HPO (SMAC)

When you run LLaMEA on its own it prints a one-line pointer to BLADE; set LLAMEA_NO_BLADE_HINT=1 to hide it. See the BLADE documentation for all problems and methods.

πŸ”§ Configuration

The most used arguments of LLaMEA:

Parameter Description
n_parents, n_offspring, elitism Population sizes and (ΞΌ+Ξ») (default) vs. (ΞΌ,Ξ») selection
budget Number of candidates to generate and evaluate
operators, operator_weight_updater Mutation/crossover prompts (Operator) and adaptive operator selection
parent_selection, tournament_size "random", "tournament" or "roulette"
role_prompt, task_prompt, example_prompt, output_format_prompt Prompt components
HPO Ask for a ConfigSpace next to the code (LLaMEA-HPO)
multi_objective, multi_objective_keys Pareto-based multi-objective mode
niching "sharing", "clearing", "novelty" or "map_elites", with related options
diff_mode SEARCH/REPLACE patches instead of full code
adaptive_mutation, adaptive_prompt, feature_guided_mutation Mutation-rate control, co-evolving task prompt, XAI guidance
evaluate_population f receives the whole offspring population
eval_timeout, max_workers, parallel_backend Evaluation time limit and parallelism

See the documentation for every parameter.

πŸ’‘ Examples

Script Shows
examples/minimum_example.py The smallest complete set-up
examples/black-box-optimization.py Metaheuristics for the 24 BBOB functions, scored by AOCC
examples/black-box-opt-with-HPO.py LLaMEA-HPO with SMAC tuning in the loop
examples/black-box-optimization-diff-mode.py Diff mode (SEARCH/REPLACE patches)
examples/crossover.py Mutation and crossover operators, tournament selection, discounted UCB
examples/multi_objective.py LLaMEA-MO on a vehicle-routing problem (distance and fuel)
examples/automl_example.py Evolving ML pipelines instead of optimisers
examples/warm-start-tests.py Resuming a run from its archive

Run any of them with uv run python examples/<script>.py after setting the model and API key in the script. benchmarks/ holds the set-ups of our papers (MA-BBOB, photonics, mini-Bragg).

To browse the LLM conversation of a run: uv run python logreader/app.py --logfile path/to/conversationlog.jsonl and open http://localhost:5001.

πŸ“š Publications

LLaMEA is developed by the XAI group of NACO at LIACS, Leiden University (project page, video).

Methodology

  • LLaMEA: A Large Language Model Evolutionary Algorithm for Automatically Generating Metaheuristics. IEEE Transactions on Evolutionary Computation 29(2), 2025. DOI
  • In-the-loop Hyper-Parameter Optimization for LLM-Based Automated Design of Heuristics (LLaMEA-HPO). ACM Transactions on Evolutionary Learning and Optimization, 2025. DOI
  • Controlling the Mutation in Large Language Models for the Efficient Evolution of Algorithms. EvoApplications (Springer LNCS), 2025. DOI
  • LLaMEA-BO: A Large Language Model Evolutionary Algorithm for Automatically Generating Bayesian Optimization Algorithms. arXiv:2505.21034
  • LLaMEA-SAGE: Guiding Automated Algorithm Design with Structural Feedback from Explainable AI. arXiv:2601.21511
  • LLM-Driven Evolutionary Generation of Multi-Objective Bayesian Optimization Algorithms. arXiv:2607.08791
  • Large Language Models and Evolutionary Computation: A Critical Review of Bidirectional Interaction, Automated Algorithm Design, and Co-adaptive Systems. Computer Science Review, 2026. Article

Benchmarking & analysis

  • BLADE: Benchmark Suite for LLM-driven Automated Design and Evolution of Iterative Optimisation Heuristics. GECCO '25 Companion. DOI Β· code
  • Code Evolution Graphs: Understanding Large Language Model Driven Design of Algorithms. GECCO '25. DOI
  • Behaviour Space Analysis of LLM-driven Meta-heuristic Discovery. arXiv:2507.03605
  • From Heuristic Selection to Automated Algorithm Design: LLMs Benefit from Strong Priors. arXiv:2603.02792

Applications

  • Optimizing Photonic Structures with Large Language Model Driven Algorithm Discovery. GECCO '25 Companion. DOI
  • Landscape-aware Automated Algorithm Design: An Efficient Framework for Real-world Optimization. arXiv:2602.04529
  • LLM Driven Design of Continuous Optimization Problems with Controllable High-level Properties. arXiv:2601.18846
  • Evolving Executable Pipeline Programs for AutoML with Language Models. arXiv:2608.16416

πŸ† Awards

  • πŸ₯ˆ Silver award, Humies @ GECCO 2025 (awards)
  • πŸ† Winner, Anytime Performance for Affine BBOB competition, GECCO 2025 (results)
  • πŸ† Winner, Anytime Algorithms for Many-affine BBOB Functions, GECCO 2024 (results)
  • πŸ₯‰ Bronze, IEEE CoG 2025 Planet Wars RTS competition (results)

πŸ” Reproducibility

Each paper has a Zenodo record with code, generated algorithms and logs:

🀝 Contributing

Contributions are welcome: report bugs or request features in GitHub Issues, or open a pull request. See CONTRIBUTING.md.

πŸͺͺ License

Distributed under the MIT License.

✨ Citation

If you use LLaMEA in your research, please cite:

@article{van2025llamea,
  author  = {van Stein, Niki and B{\"a}ck, Thomas},
  journal = {IEEE Transactions on Evolutionary Computation},
  title   = {LLaMEA: A Large Language Model Evolutionary Algorithm for Automatically Generating Metaheuristics},
  year    = {2025},
  volume  = {29},
  number  = {2},
  pages   = {331--345},
  doi     = {10.1109/TEVC.2024.3497793}
}
LLaMEA-HPO, mutation control and BLADE
@article{van2025intheloop,
  author  = {van Stein, Niki and Vermetten, Diederick and B{\"a}ck, Thomas},
  title   = {In-the-loop Hyper-Parameter Optimization for LLM-Based Automated Design of Heuristics},
  journal = {ACM Transactions on Evolutionary Learning and Optimization},
  year    = {2025},
  doi     = {10.1145/3731567}
}

@inproceedings{yin2025controlling,
  author    = {Yin, Haoran and Kononova, Anna V. and B{\"a}ck, Thomas and van Stein, Niki},
  title     = {Controlling the Mutation in Large Language Models for the Efficient Evolution of Algorithms},
  booktitle = {Applications of Evolutionary Computation},
  publisher = {Springer Nature Switzerland},
  year      = {2025},
  pages     = {403--417},
  doi       = {10.1007/978-3-031-90065-5_25}
}

For BLADE, see the BLADE citation (GECCO '25, doi:10.1145/3712255.3734347).

About

Large Language Model Evolutionary Algorithm

Resources

Contributing

Stars

137 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages