Harnessing Large Language Models to Compile Task-Relevant Context into Bayesian Optimisation
Authors: Zhongwei Yu, Sourabh Roy, Bin Cao, Xue Yan, Anjie Liu, Jun Wang
Organizations: The Hong Kong University of Science and Technology (Guangzhou) · University College London (UCL) · Institute of Automation, Chinese Academy of Sciences
Incorporating rich task-relevant context, such as domain knowledge and external observations, is a key capability yet remains challenging for Bayesian optimisation (BO). Recently, practitioners have started to use large language models (LLMs) to generate and execute BO programs through coding harnesses. In such emerging practices, the posterior belief is shaped not only by Bayesian inference but also by LLM-generated model and data artefacts, offering a flexible route for task context to enter BO as executable code. To study whether and how LLMs can be harnessed to compile diverse contextual signals for BO, we formulate LLM-compiled BO as generalised-context decision making. We propose HarBO, a BO-specialised harness that compiles generalised context into the core artefacts of standard BO through a validated multi-stage workflow. Our theory analyses the regret under imperfect compilation and the effect of adding new context. Across synthetic functions and real-world benchmarks, we find that LLM harnesses can effectively compile context into standard BO, achieving competitive performance with specialised LLM-embedding-based and direct LLM-in-the-loop BO methods. General coding harnesses can be effective in familiar domains such as hyperparameter optimisation, but fall short in unfamiliar, context-rich domains. Together, these results establish LLM harnesses as a promising, but not automatically reliable, route for making rich task context usable in BO.
Figures & tables
Figure 1: From human-specified BO to LLM-compiled BO, where the domain practitioner delegates the optimisation task to a harness-based coding agent through interactive conversation.
Figure 2: The staged workflow of HarBO. The context is decomposed into epistemic cep , aleatory ctal , history Ht , and optional instruction δt . These components are compiled through the belief channel (stages Z, D, GP, and R) and the utility channel (stage Acq), and then a decision xt is selected by the core Bayesian engine.
Figure 3: In-process comparison against baselines.
Figure 4: Context ablations in the nine in-process environments.
Figure 5: Agentic campaigns compared with in-process HarBO and Vanilla GP-UCB.
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
Method
A
B
C
D
E
H
HM
Dock
O-Suzuki
Metric
y^∗
y^∗
y^∗
RT/T
RT/T
100y^∗
100(RT/T)
y^∗
y^∗
HarBO
13.83±0.03
14.07±0.13
14.00±0.18
6.08±1.16
7.44±0.87
−5.34±0.02
2.09±0.58
11.06±0.51
98.41±1.96
HarBO (transfer)
–
–
–
–
–
−5.47±0.14
–
–
–
HarBO (no prior)
12.60±1.58
12.81±2.69
7.75±4.00
8.39±1.54
9.51±1.06
−9.57±5.17
1.98±0.58
10.28±1.31
97.47±0.93
HarBO (no category mapping)
–
–
–
–
–
–
–
–
97.24±0.83
HarBO (no pilots)
–
13.90±0.12
–
–
7.57±1.23
–
–
–
–
Appendix
Table 1: In-process results across the nine environments.
Method
A
B
C
D
E
H
HM
Dock
O-Suzuki
HarBO (DSV4F high)
318±82
648±474
612±141
848±120
459±105
537±123
609±220
2190±836
278±78
HarBO (DSV4F low)
128±8
139±22
179±7
200±18
198±26
85±18
223±23
2354±903
71±10
HarBO (DSV4F none)
78±7
104±20
133±2
125±2
176±24
74†
138†
1612†
36±5
HarBO (GPT-4o-mini none)
106±19
87†
190†
238†
–
–
–
–
32±3
CAKE
726±128
783±64
854±198
893±186
531±92
2420±462
1109±344
–
787±73
LGBO
111±2
129±3
136±10
156±8
124±4
127±4
135±16
–
114±3
Appendix
Table 2: Wall time by environment and method (seconds).
Method
A
B
C
D
E
H
HM
Dock
O-Suzuki
HarBO (DSV4F high)
166,905
363,010
375,473
431,451
374,427
331,125
435,997
268,672
197,710
HarBO (DSV4F low)
58,173
61,119
114,476
185,467
198,700
67,949
201,925
61,407
75,547
HarBO (DSV4F none)
14,264
28,677
28,837
58,208
102,611
6,559
56,286
8,826
42,806
HarBO (GPT-4o-mini none)
23,819
14,003
20,958
39,745
–
–
–
–
38,166
CAKE
639,458
707,457
643,056
653,209
777,828
864,220
928,093
–
881,789
LGBO
403,837
449,885
406,256
416,420
488,461
548,720
601,924
–
604,647
Appendix
Table 3: Aggregate LLM token consumption across successful campaigns by environment and method.
Method
Reasoning
LLM calls
Total tokens
Wall time (s)
R T/T
HarBO (ours)
high
53
94,701
624
8.36
CAKE
–
80
155,877
495
13.44
CAKE
high
81
600,079
4,742
14.08
CAKE
low
80
473,696
3,766
13.54
LGBO
–
47
97,425
119
13.04
LGBO
high
48
371,182
2,587
12.46
Appendix
Table 4: Reasoning-cost comparison on scenario E ( T=50 , seed 0).
Method / variant
A
D
E
H
HM
Dock
Metric
y^∗
RT/T
RT/T
100y^∗
RT/T
y^∗
Agentic (skill)
14.02±0.10
5.33±1.09
6.73±0.76
−5.41±0.16
0.037±0.012
11.30±0.48
Agentic (noskill)
13.70±0.43
7.69±0.34
8.24±0.33
−5.37±0.03
0.036±0.007
10.72±0.59
Agentic (transfer)
–
–
–
−5.39±0.02
–
–
Agentic (no-ref)
–
–
–
–
–
11.08±0.21
Agentic (no-ref, noskill)
–
–
–
–
–
10.86±0.64
Appendix
Table 5: Agentic campaigns and in-process references.
Model
Thinking
A
B
C
D
E
H
HM
Dock
O-Suzuki
DeepSeek-V4-Flash-0731
high
0/5
0/5
0/5
0/5
0/5
0/5
0/5
0/5
0/5
DeepSeek-V4-Flash-0731
low
0/5
0/5
0/5
0/5
0/5
0/5
0/5
1/5
0/5
DeepSeek-V4-Flash-0731
none
2/5
0/5
3/5
3/5
2/5
4/5
4/5
4/5
2/5
gpt-4o-mini
none
2/5
4/5
4/5
4/5
5/5
5/5
5/5
5/5
2/5
Appendix
Table 6: Actual terminal failures by model and thinking configuration.
Model
Thinking
A
B
C
D
E
H
HM
Dock
O-Suzuki
DeepSeek-V4-Flash-0731
high
0/5
1/5
2/5
1/5
0/5
1/5
3/5
1/5
0/5
DeepSeek-V4-Flash-0731
low
2/5
1/5
3/5
3/5
2/5
1/5
4/5
3/5
2/5
DeepSeek-V4-Flash-0731
none
2/5
0/5
3/5
3/5
4/5
4/5
5/5
5/5
5/5
gpt-4o-mini
none
5/5
5/5
5/5
5/5
5/5
5/5
5/5
5/5
5/5
Appendix
Table 7: Runs containing at least one validation error by model and thinking configuration.
Model
Thinking
A
B
C
D
E
H
HM
Dock
O-Suzuki
DeepSeek-V4-Flash-0731
high
0
2
2
1
0
1
7
1
0
DeepSeek-V4-Flash-0731
low
3
1
4
5
2
1
8
5
2
DeepSeek-V4-Flash-0731
none
4
0
6
6
6
8
10
8
7
gpt-4o-mini
none
7
14
10
19
16
10
10
10
8
Appendix
Table 8: Total validation errors by model and thinking configuration.
Scenario
DSV4F (high)
DSV4F (low)
DSV4F (none)
GPT-4o-mini (none)
A
13.83 (5/5)
13.97 (5/5)
14.04 (3/5)
13.84 (3/5)
B
14.07 (5/5)
13.42 (5/5)
13.53 (5/5)
13.82 (1/5)
C
14.00 (5/5)
12.03 (5/5)
13.75 (2/5)
14.11 (1/5)
D ( RT/T )
6.08 (5/5)
7.17 (5/5)
7.69 (2/5)
14.07 (1/5)
E ( RT/T )
7.44 (5/5)
7.79 (5/5)
9.57 (3/5)
– (0/5)
H
−0.053 (5/5)
−0.088 (5/5)
−0.061 (1/5)
– (0/5)
Appendix
Table 9: Successful-seed performance by model and reasoning setting.
Figure 6: Model and reasoning-intensity ablation trajectories.
Bayesian Optimization (BO) is widely used for optimizing expensive black-box functions, yet it typically reduces each expensive experiment to an input and its objective value, discarding much of the information the experiment produces. Such auxiliary information can include training curves in hyperparameter optimization, expert notes and images in scientific experimentation, or known facts about the specific optimization problem. Leveraging the ability of large language models (LLMs) to process diverse and unstructured information, we introduce two methods: AuxBO-Evolve, which uses auxiliary information to evolve beliefs over the location of the optimum, and AuxBO-Vicinity, which uses it to locally guide the acquisition function. Across synthetic tasks, hyperparameter optimization benchmarks, and a nuclear fusion task with unstructured scientist-written logs, our methods consistently improve optimization performance and outperform standard BO and existing LLM-based approaches. We further find that LLMs provide more effective probabilistic guidance when modeling likely maximizer locations rather than objective values pointwise. Overall, our results demonstrate that exploiting rich information beyond standard (x,y) interactions can substantially improve BO performance.
Efe Mert Karagözlü, Rohit Sonker, Tejus Gupta +2
School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213
Large language model (LLM)-guided Bayesian optimization (BO) uses past observations to guide search, but proposed directions and their revision can remain implicit. We propose Feedback-Guided Search State (FGSS), a structured hypothesis-management interface connecting language-based guidance to observed evidence, executable parameter interventions, and comparative support updates. An LLM reflector proposes and revises hypotheses; a deterministic curator validates them and maintains identities and test records. The evolving state guides candidate construction and priorities. Instantiated on LLAMBO, FGSS-BO retains its surrogate and default expected improvement selection, with a bounded testing policy. On two retrospective protocol/media tasks with nearest-neighbor response oracles, it attains higher sample mean final best and search AUC than the matched LLAMBO baseline and evaluated non-LLM baselines. Prose-reflection and EI-only controls show mixed component effects. Six direct-training hyperparameter-optimization tasks show task-dependent transfer, strongest on diabetes SVM; exact-grid and reaction controls examine other settings. FGSS exposes hypotheses, their execution, and cross-round revisions for inspection while supporting search gains in selected settings.
Hao Chen, Ziyang Ling, Ronald X. Xu +1
School of Biomedical Engineering, University of Science and Technology of China, Suzhou, China · School of Engineering Science, University of Science and Technology of China, Suzhou, China
Optimization of LLM training and inference configurations, such as hyperparameters, data mixtures, and prompts, is critical to performance, but it is often approached heuristically in practice, leading to potentially suboptimal outcomes. By framing them as noisy, expensive, and derivative-free optimization problems, Bayesian optimization (BO) and other black-box optimization (BBO) methods offer a promising yet underexplored direction for principled, sample-efficient methods. However, LLM training and inference costs are prohibitively high for most of the BBO research community, and new methods are often only evaluated on synthetic test functions and small-scale datasets that fail to capture the challenges of modern LLM optimization problems. This impedes the development of BBO methods and makes it difficult to assess their effectiveness on modern LLM tasks. We introduce BoLT, the first LLM-centric benchmark that democratizes LLM research for the BBO community. BoLT is released at https://github.com/chewwt/bolt. BoLT covers broad and well-motivated LLM optimization problems, involving multi-fidelity, multi-objective, heteroscedastic noise, and high-dimensional search spaces. Each problem in BoLT is grounded in real experimental data and made fully reproducible and accessible through lightweight surrogate models fitted to the results of thousands of real LLM experiments. We benchmark BoLT against an extensive range of BO and BBO methods, showing that selected BO methods consistently outperform others across tasks and highlighting gaps in existing BBO methods on LLM tasks, underscoring the need to modernize benchmarks for the BBO community.
Ruth Wan Theng Chew, Zhiliang Chen, Apivich Hemachandra +1