FunBO: Discovering Acquisition Functions for Bayesian Optimization with FunSearch

Virginia Aglietti, Ira Ktena, Jessica Schrouff, Eleni Sgouritsa, Francisco Ruiz, Alan Malek, Alexis Bellot, Silvia Chiappa

Introduction

Bayesian Optimization (BO) is the gold standard for optimizing "expensive" black-box functions—such as tuning a machine learning model's hyperparameters or designing a new drug molecule, where every test incurs significant time or financial costs.

The core engine of BO is the Acquisition Function (AF), which decides where to sample next by balancing exploration (searching highly uncertain areas) and exploitation (focusing on known promising areas). While standard AFs like Expected Improvement (EI) have been used for decades, they are not universally optimal across all problem types. Recent attempts to "learn" AFs using neural networks often result in "black boxes" that are difficult to trust, hard to deploy, and prone to failing when faced with out-of-distribution problems.

To address this, researchers have introduced FunBO, a novel method that leverages Large Language Models (LLMs) to automatically write and evolve new acquisition functions. By treating algorithm design as a code-generation problem, FunBO discovers novel, human-readable Python strategies that outperform standard industry benchmarks.

The FunBO Approach

FunBO builds upon the FunSearch framework. Instead of training a neural network to act as an acquisition function, FunBO uses an LLM (specifically Google's Codey) to write explicit Python code for one.

The FunBO framework illustrating the evolutionary loop of generating, evaluating, and storing acquisition function programs.

The methodology follows a self-improving cycle of algorithmic evolution:

  1. Initial Seed: The process begins with a simple, baseline AF written in code (such as EI).
  2. Evolutionary Loop: The LLM is prompted to "improve" this code, generating a batch of new AF candidates.
  3. Evaluation: Each candidate is rigorously tested by running a full BO loop on a set of "training" functions. A custom scoring metric rewards AFs that find the global optimum both accurately and efficiently.
  4. Database & Selection: High-scoring programs are saved in a database. The best-performing functions are then sampled to create new prompts for the LLM, perpetuating the evolutionary cycle.

The key innovation of this approach is interpretability. The output is not an opaque weight matrix, but a concise Python function that human engineers can read, analyze, and seamlessly integrate into existing libraries like BoTorch.

Experimental Setup

The researchers evaluated FunBO across several rigorous benchmarks to test both specific and general capabilities:

  • OOD-Bench (Out-of-Distribution): Tests whether AFs discovered on simple 1D functions (like Ackley or Schwefel) can generalize to completely different, higher-dimensional problems (up to 6D).
  • ID-Bench (In-Distribution): Focuses on specific function classes like Branin, Goldstein-Price, and Hartmann.
  • HPO-ID: Real-world hyperparameter optimization tasks for models like SVMs and AdaBoost using the HyLAP project data.
  • GPs-ID: Synthetic functions sampled from Gaussian Process priors to test general mathematical robustness.

Key Insights and Discoveries

Unlike traditional genetic algorithms that rely on random mutations, LLMs act as creative mutators. They use their embedded knowledge of mathematics and programming to suggest sensible, sophisticated modifications to the code.

Example of the LLM prompt structure and the resulting human-readable Python code for a discovered acquisition function.

Because the AFs are generated as code, researchers can inspect exactly what the LLM discovered. For example, in one experiment, the LLM devised a strategy that squared the EI term and added a penalty for high uncertainty—a novel heuristic to prevent the algorithm from jumping too aggressively into unknown territory.

Surprisingly, FunBO demonstrated remarkable generalization. An AF evolved on a tiny set of 1D functions successfully outperformed standard methods on complex 6D functions it had never seen before, suggesting the LLM uncovered universal optimization heuristics.

Key Results

  • Superior Performance: FunBO consistently outperformed established general-purpose AFs (such as EI, UCB, and PofI) across almost all benchmarks.
  • Competitive with "Black Boxes": It achieved performance comparable to state-of-the-art neural-network-based AFs (like MetaBO) while remaining vastly simpler to deploy and interpret.
  • Zero-Regret Convergence: In many tasks, FunBO reached the global optimum significantly faster than standard methods, effectively reducing the computational cost of optimization.
  • Few-Shot Adaptation: FunBO demonstrated the ability to take an existing AF and "fine-tune" its code for a specific new problem using only 5 example instances, highlighting its flexibility.

Limitations and Future Work

The primary limitation of FunBO is the computational overhead during the "discovery" phase, as every candidate AF must be tested in a full BO loop. However, this is a one-time upfront cost; once an AF is discovered, executing its Python code is as fast as any standard method.

Currently, the fitness function focuses simply on the final result and speed, and the scope is limited to single-objective, noiseless optimization. Future work aims to incorporate more complex scoring metrics to guide specific convergence behaviors and extend the framework to handle constraints, noisy evaluations, and multi-objective problems.

Summary updated

BibTeX
@inproceedings{aglietti2025funbo,
  author = {Virginia Aglietti and Ira Ktena and Jessica Schrouff and Eleni Sgouritsa and Francisco Ruiz and Alan Malek and Alexis Bellot and Silvia Chiappa},
  title = {{FunBO: Discovering Acquisition Functions for Bayesian Optimization with FunSearch}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=XjbJR9374o},
}
Figure