Abstract
The performance of Bayesian Optimization (BO) is fundamentally tied to the choice of the Gaussian Process (GP) kernel, which encodes prior assumptions about the objective function's structure. Traditionally, practitioners rely on fixed, generic kernels or computationally expensive automated searches. This paper introduces Context-Aware Kernel Evolution (CAKE), a framework that leverages Large Language Models (LLMs) as genetic operators to adaptively evolve custom kernels based on observed data. By combining LLM-driven evolutionary search with a novel ranking mechanism, BAKER (BIC-Acquisition Kernel Ranking), the proposed method significantly outperforms traditional fixed and automated baselines across diverse benchmarks, including hyperparameter optimization and high-stakes engineering design.
Introduction
Bayesian Optimization is the premier strategy for optimizing expensive, black-box functions, such as hyperparameter tuning for deep neural networks or the physical design of hardware components. At its core, BO employs a surrogate model—typically a Gaussian Process—to model the objective function. The kernel of this GP is its most critical component, defining properties like smoothness, periodicity, and linearity.
A mismatch between the kernel and the true underlying function leads to poor convergence and inefficient sampling. While automated kernel search exists, it often requires significant expert knowledge or is too slow for practical use. We identify a "few-shot learning" challenge: discovering the optimal kernel structure from a limited number of observations. To address this, we present CAKE, which utilizes the reasoning capabilities of LLMs to automate and optimize kernel design.
Methodology
The proposed framework consists of two primary components: CAKE for kernel generation and BAKER for kernel selection.
Context-Aware Kernel Evolution (CAKE)
CAKE treats kernel design as an evolutionary process where an LLM (specifically GPT-4o-mini) serves as the genetic operator. Unlike traditional evolutionary algorithms that use stochastic mutations, CAKE leverages the LLM's domain knowledge through several mechanisms:
- Crossover: The LLM receives two high-performing "parent" kernels and synthesizes a "child" kernel that inherits their strengths.
- Mutation: The LLM modifies an existing kernel to better capture nuances in the data.
- In-Context Learning: The LLM is prompted with the actual history of observed data points. By "reasoning" through the data using Chain-of-Thought prompting, the LLM identifies patterns such as global trends or local oscillations to suggest appropriate kernel components (e.g., combining a Linear kernel for trends with a Periodic kernel for cycles).
BIC-Acquisition Kernel Ranking (BAKER)
Evolutionary search produces a population of candidate kernels. BAKER selects the most promising kernel for the next BO iteration by balancing two metrics:
- Bayesian Information Criterion (BIC): Measures how well the kernel fits the existing data while penalizing over-complexity.
- Expected Improvement (EI): Evaluates the potential of the kernel to find a better global optimum in the next query point.
Experimental Evaluation
The researchers evaluated CAKE across three diverse and challenging domains:
- HPOBench: A massive benchmark of 60 tasks involving hyperparameter optimization for machine learning models (Logistic Regression, SVM, Random Forest, XGBoost, and MLP) across 12 OpenML datasets.
- Controller Tuning: Two classic reinforcement learning-style tasks: Robot Pushing (tuning a 14-dimensional controller) and Lunar Lander (a 12-dimensional task).
- Photonic Chip Design: A high-stakes engineering task involving five competing objectives (Q-factor, wavelength, etc.) to optimize the physical parameters of a photonic crystal.
Key Insights
- LLMs as "Kernel Scientists": LLMs possess enough transferable domain knowledge about mathematics and Gaussian Processes to suggest meaningful kernel combinations (like
Linear * Periodic) that reflect the underlying data physics. - Interpretability: Unlike "Deep GP" models which are black boxes, CAKE produces symbolic kernel expressions. The LLM can explain why it chose a specific structure (e.g., "The Linear kernel captures the overall upward trend, while the SE kernel handles local fluctuations").
- The Power of Reasoning: Ablation studies showed that providing the LLM with the actual optimization history (the "Context" in CAKE) and allowing it to perform Chain-of-Thought reasoning were the most critical factors for success.
Results
CAKE + BAKER demonstrated superior performance across all benchmarks:
- Superior Accuracy: On the HPOBench tasks, CAKE achieved the highest average rank across all 60 tasks, consistently beating established methods like Automated BO (ABO) and Compositional Kernel Search (CKS).
- 10x Speedup: In the photonic chip design task, CAKE found a high-performing configuration in fewer than 40 trials—a tenfold speedup compared to standard baseline methods.
- Robustness in the "Cold Start": CAKE was particularly effective in the early stages of optimization when data is most scarce, which is exactly where traditional BO usually struggles.
Limitations and Future Work
While CAKE introduces a small amount of computational latency (approximately 8 seconds per iteration for LLM inference), the authors argue this is a worthy trade-off if the objective function itself takes minutes or hours to run. Current limitations include a dependency on external APIs and a kernel grammar limited to basic algebraic operations. Future work could expand this to more complex operators like convolution or warping and explore applications beyond BO, such as in Support Vector Machines or Kernel PCA.
Summary updated