Amortized Bayesian Experimental Design with In-Context Knowledge Conditioning
Authors: Zhanghu Zhao, Daolang Huang, Xinyi Wen, Samuel Kaski
Organizations: ELLIS Institute Finland · Department of Computer Science, Aalto University, Finland · Department of Computer Science, University of Helsinki, Finland · Department of Computer Science, University of Manchester, UK
Amortized Bayesian experimental design (BED) enables real-time design strategies by shifting acquisition cost offline, but existing methods remain tied to the prior and task distribution they were trained on and cannot exploit additional information available at deployment. We introduce in-context amortized BED with unified knowledge encoding (IMBUE), a BED framework that admits external knowledge at deployment through a unified in-context interface. IMBUE accepts two forms of such knowledge without retraining, namely user-specified prior knowledge and observations from previous instances of the experiment. Both are encoded as additional input tokens and processed in-context with the accumulated observations by a shared Transformer, and a learned reliability filter scores each external token against the observations and excludes inconsistent ones. Across four benchmarks, IMBUE accelerates early-stage information acquisition when the external knowledge is reliable, and remains close to the no-external baseline when it is not.
Figures & tables
Figure 1: Overview of Imbue . Left : Existing amortized BED policies fail to encode additional information available at deployment. Middle : Imbue enables in-context adaptation at deployment by encoding external knowledge as additional input tokens, together with a reliability filter that excludes unreliable information. Right : Imbue accelerates early information acquisition when external information is reliable, and remains robust to misleading information.
Figure 2: Architecture of Imbue . Auxiliary previous-instance data and the user-prior histogram are encoded as in-context tokens and screened by the reliability filter (right). Retained tokens are then combined with context, query, and target tokens in the shared Transformer layers.
Figure 3: CES with K=5 previous instances drawn from the relevant or irrelevant regime. sPCE (mean ± 95% confidence interval (CI)) over T=10 steps across 2,000 rollouts.
Figure 4: Location Finding. sPCE ( ↑ ) over T=20 steps, mean ± 95% CI across 2,000 rollouts.
K=0
K=1
K=5
Method
—
Relevant
Irrelevant
Relevant
Irrelevant
Random
9.05±0.26
—
—
—
—
DAD *
11.52±0.17
7.38±0.21
7.37±0.21
5.16±0.21
5.40±0.21
RL-BOED *
14.34±0.13
4.54±0.20
4.74±0.21
2.56±0.15
2.84±0.17
ALINE *
13.37±0.15
13.27±0.15
11.10±0.22
13.07±0.15
10.16±0.24
Imbue
13.46±0.15
13.63±0.14
13.42±0.15
13.93±0.12
13.14±0.16
Table 1: CES. sPCE (mean ± 95% CI, 2,000 rollouts) under K previous instances. At K=0 nothing is concatenated, so the K=0 entries of the starred methods are the standard DAD, RL-BOED, and ALINE without any in-context knowledge.
K=0
K=5
Method
—
Relevant
Biased
Irrelevant
ALINE *
13.37±0.15
13.07±0.15
11.26±0.21
10.16±0.24
ALINE-aux
13.19±0.15
13.52±0.13
12.72±0.16
12.23±0.18
Imbue w/o filter
13.39±0.15
13.99±0.12
13.10±0.15
12.97±0.16
Imbue
13.46±0.15
13.93±0.12
13.23±0.15
13.14±0.16
Retrieve-then-condition
—
13.29±0.14
—
12.69±0.17
Table 2: Staged ablation on CES with K=5 previous instances. sPCE (mean ± 95% CI, 2,000 rollouts). Biased instances are a deployment shift absent from training (Appendix E.6 ).
Figure 5: Mixed previous-instance input on four 1D GP active learning benchmarks. Final RMSE ( ↓ , mean ± 95% CI over 100 rollouts). With K=5 instances, the x -axis varies the number that are irrelevant from 0 to 5 .
Figure 6: Psychometric task. Joint RMSE on (θthreshold,θslope) ( ↓ ) over T=30 steps, mean ± 95% CI across 500 rollouts.
Appendix figures & tables32 assets
Supplementary material from the paper’s appendix.
Appendix
Symbol
Meaning
Problem setup ( Section 3.1 )
θ∈Θ⊆RL
Latent parameters of the system; L is the parameter dimension
θ⋆
Ground-truth parameters of a training rollout, drawn from the prior; unknown at deployment
x∈X , y
Design and outcome; p(y∣θ,x) is the likelihood
T , Dt
Horizon of the experiment, and history {(xi,yi)}i=1t after t rounds with D0=∅
Z
Inference target: Z=θ (parameter-oriented) or Z=y⋆ at test inputs x⋆∼p⋆ (prediction-oriented)
Appendix
Table 3: Notation used in the main text.
Figure 7: Attention masks of Imbue ’s shared Transformer layers for the previous-instance channel (left, in-context tokens r1,…,rK ) and the prior channel (right, in-context tokens e1prior,…,eLprior ). Rows index queries and columns index keys, ordered as in-context tokens, context tokens (xi,yi) , query tokens xmq , and target tokens ζl . Shaded squares indicate allowed attention.
Location Finding
CES
GP active learning
Psychometric
Experiment setup
Rollout length T
20
10
15
30
Parameter dimension L
4
5
—
4
Target type Z
θ
θ
y⋆
θ
Training schedule
Training-time candidate pool size Nqtrain
200
200
200
200
Appendix
Table 4: Benchmark-specific hyperparameters for Imbue .
Figure 8: Illustrative examples of randomly sampled prior histograms, shown on a generic support [0,2] ; the Location Finding experiments use the support [0,1] .
Figure 9: Distribution of prior reliability labels on the Location Finding task. Training (left) versus the four evaluation regimes (right), shown as normalized densities on a log y -axis. The training distribution covers the full range, while each evaluation regime concentrates in the expected region.
Task
Parameter
rlmin
rlmax
CES
χ
0.05
1
w1
0
1
w2
0
1
w3
0
1
logu
−8
8
Psychometric
θthreshold
−3
3
Appendix
Table 5: Normalization ranges [rlmin,rlmax] used to construct reliability labels for previous instances.
Parameter
Location Finding
CES
Critics
2
2
Random subsets
2
2
Training epochs
105
105
Discount factor γ
0.9
0.9
Target update rate
10−3
5×10−3
Policy learning rate
10−4
3×10−4
Appendix
Table 6: Hyperparameters for RL-BOED [ 15 ] on the two BED tasks.
Parameter
Location Finding
CES
GP active learning
Psychometric
Transformer layers
3
3
3
3
Attention heads
4
4
4
4
GMM components
10
10
10
10
Batch size
200
200
200
200
Candidate pool size Nqeval
2,000
2,000
500
200
Total epochs E
105
2×105
2.5×105
1.2×105
Appendix
Table 7: Hyperparameters for ALINE [ 17 ] .
Figure 10: Examples of synthetic 1D GP functions used to train Imbue , each drawn from the kernel and hyperparameter prior described above with noisy point evaluations.
Figure 11: The three analytic 1D benchmark functions with the output scaling used at evaluation. The horizontal axes retain their native input coordinates.
Figure 12: Examples of previous instances supplied during training. Each panel shows one target function (black dashed line) and up to three instances A1,A2,A3 (colored points), with filled circles for the relevant regime and crosses for the irrelevant regime.
Figure 13: Location Finding trajectory: prior contours, true sources (stars), and queries colored by step; the yellow square marks the final query.
Figure 14: sPCE ( ↑ ) on Location Finding: Imbue under strong, weak, uniform, and miscalibrated priors, and baseline ALINE (mean ± 95% CI over 2,000 rollouts).
Figure 15: Reliability filter output αj for the prior tokens on Location Finding, mean ± 95% CI over 100 rollouts, shown as a function of experiment step t . Each curve corresponds to one of the four prior conditions in Figure 14 . The dotted line marks τ=0.5 .
Figure 16: Marginal posterior distributions estimated by Imbue on the CES task after T=10 steps. Dashed lines mark the true parameter values.
Figure 17: Effect of the number of previous instances K on CES. sPCE (mean ± 95% CI, 2,000 rollouts).
Figure 18: CES with previous-instance observations. Stepwise sPCE (mean ± 95% CI, 2,000 rollouts) over experiment steps t=1,…,10 . Panels vary the number of previous instances supplied at deployment, K=0 , K∈{1,5} relevant, or K∈{1,5} irrelevant.
K=0
K=1
K=5
ns
—
Rel.
Irrel.
Rel.
Irrel.
1
13.42±0.15
13.73±0.13
13.37±0.16
13.92±0.12
13.22±0.16
2 ( Imbue )
13.46±0.15
13.63±0.14
13.42±0.15
13.93±0.12
13.14±0.16
4
13.41±0.15
13.58±0.14
13.33±0.16
13.82±0.12
13.09±0.16
Appendix
Table 8: Effect of the number of summary slots ns in the per-instance encoder gaux on CES. sPCE (mean ± 95% CI, 2,000 rollouts).
Figure 19: Sequential design strategy of Imbue on a 1D synthetic GP function over T=15 steps. Each panel shows the ground-truth function (orange dashed), the predictive mean (blue solid) with 95% predictive band (shaded), the accumulated context (orange dots), and the next queried design (red dashed vertical line).
Figure 20: Extended baseline comparison on four 1D GP active learning benchmarks (RMSE ↓ , mean and 95% CI over 100 rollouts).
Figure 21: RMSE at each experimental step on four 1D GP benchmarks ( ↓ , mean and 95% CI over 100 rollouts). Rows index the benchmark, and columns show the composition of the K=5 previous instances as relevant/irrelevant (the leftmost column is the K=0 baseline).
Method
Synthetic 1D
Forrester
Higdon
Gramacy & Lee
GP-RS
0.332±0.020
0.343±0.029
0.305±0.024
0.300±0.022
GP-US
0.408±0.024
0.381±0.020
0.397±0.023
0.399±0.027
GP-VR
1.236±0.037
1.242±0.020
1.240±0.027
1.216±0.033
GP * ( K=5 rel.)
0.556±0.068
0.640±0.036
0.648±0.050
0.649±0.087
ALINE
0.047±0.000
0.049±0.003
0.049±0.003
0.048±0.003
Imbue ( K=0 )
0.049±0.004
0.047±0.000
0.047±0.000
0.047±0.000
Appendix
Table 9: Total inference time for rollouts of 15 steps on four GP benchmarks (mean ± standard deviation in seconds, 10 runs).
Figure 22: Psychometric model: joint RMSE on (θthreshold,θslope) ( ↓ ) over T=30 steps (mean ± 95% CI, 500 rollouts). Panels compare no instances ( K=0 ) with K∈{1,5} relevant or irrelevant instances. QUEST+ and Psi-marginal use no previous instances; their curves are repeated across panels for reference. The Imbue (w/o filter) curves are discussed in Appendix E.5 .
Figure 23: Filter ablation on Location Finding and CES. sPCE mean ± 95% CI over 2,000 rollouts for the full Imbue (w/ filter) and the variant retrained without reliability filter (w/o filter).
Figure 24: Binary versus soft gating on CES. sPCE (mean ± 95% CI over 2,000 rollouts, T=10 steps) under the five previous-instance configurations of Table 1 .
Figure 25: Sensitivity sweeps on Location Finding, sPCE (mean ± 95% CI over 2,000 rollouts). Top row , varying the training mixture parameter pgood∈{0.5,0.7,0.9} , with 0.7 as the default used in the main results. Bottom row , varying the filter loss weight λ3∈{0.1,1} , with 1 as the default.
Step t
Relevant
Biased (shift)
Irrelevant
2
0.818±0.004
0.677±0.012
0.479±0.010
10
0.906±0.002
0.621±0.016
0.246±0.008
Appendix
Table 10: Mean reliability score α over instance tokens on CES with K=5 instances (mean ± 95% CI, 2,000 rollouts).
Condition
sPCE
K=0
13.46±0.15
K=5 relevant, Gaussian noise (in-dist.)
13.93±0.12
K=5 relevant, Student- t noise (shift)
14.00±0.12
K=5 irrelevant, Gaussian noise (in-dist.)
13.14±0.16
K=5 irrelevant, Student- t noise (shift)
13.32±0.16
Appendix
Table 11: CES with K=5 instances whose outcomes carry Student- t noise ( ν=3 , scale 3σCES ) instead of the Gaussian noise used in training. sPCE at T=10 (mean ± 95% CI, 2,000 rollouts).
Prior
t=2
t=5
t=11
t=20
Strong (in-dist.)
2.26±0.07
5.77±0.11
10.49±0.11
13.03±0.06
Uniform (in-dist.)
1.72±0.06
4.25±0.09
9.10±0.12
12.83±0.07
Miscalibrated (in-dist.)
1.56±0.05
3.90±0.08
8.43±0.11
12.61±0.07
Truncated (shift)
1.46±0.05
3.89±0.08
8.54±0.11
12.56±0.07
Boundary (shift)
1.76±0.06
4.27±0.09
9.12±0.11
12.77±0.06
Appendix
Table 12: Location Finding under priors that assign zero mass to the bin containing θ⋆ . sPCE (mean ± 95% CI, 2,000 rollouts) at four experiment steps, alongside the three in-distribution prior types.
Condition
Pool
Nqeval=200
500
1,000
2,000
4,000
8,000
K=0
Uniform
13.03
13.23
13.40
13.46
13.54
13.58
Sobol
13.15
13.35
13.48
13.58
13.69
13.70
K=1 rel.
Uniform
13.25
13.48
13.61
13.63
13.75
13.81
Sobol
13.47
13.62
13.74
13.84
13.90
13.96
K=5 rel.
Uniform
13.60
13.79
13.90
13.93
13.98
14.02
Sobol
13.59
13.73
13.90
13.93
13.98
14.00
Appendix
Table 13: CES. sPCE at T=10 as a function of the candidate design pool Nqeval and construction, with the trained policy fixed ( 2,000 rollouts; 95% CIs are approximately ±0.14 ). The main-text setting is Nqeval=2,000 with uniform pools.
Prior
Pool
Nqeval=200
500
1,000
2,000
4,000
8,000
Strong
Uniform
11.91
12.81
13.05
13.03
13.13
13.07
Sobol
12.19
12.93
13.12
13.13
13.10
13.09
Weak
Uniform
11.88
12.64
12.84
12.89
12.99
12.94
Sobol
12.07
12.81
12.95
12.94
12.98
12.95
Uniform
Uniform
11.79
12.50
12.69
12.83
12.80
12.79
Sobol
11.99
12.64
12.71
12.80
12.78
12.79
Appendix
Table 14: Location Finding. sPCE at T=20 as a function of the candidate design pool Nqeval and construction, with the trained policy fixed ( 2,000 rollouts; 95% CIs are approximately ±0.06 ). The main-text setting is Nqeval=2,000 with uniform pools.
Configuration
CES
Location Finding
No in-context tokens
2.55±0.003
—
In-context tokens, w/o filter
3.62±0.003
2.56±0.002
In-context tokens + filter (full)
4.57±0.005
3.28±0.003
Appendix
Table 15: Per-step inference latency of Imbue by module (ms per step, mean ± standard deviation over 10 runs; NVIDIA H100, batch size 1 , Nqeval=2,000 ). On CES the in-context input is K=5 instances; on Location Finding it is the prior histogram.
Bayesian experimental design (BED) is a principled framework for data-efficient design of sequential experiments. However, existing BED methods are unable to adapt to dynamic constraints inherent in real-world tasks due to budget limitations, varying costs, or physical constraints that restrict how designs evolve over time. In this paper, we introduce a novel approach to BED that enables constrained optimization of experimental designs by combining offline pre-training of an amortized policy and a posterior network with online multi-step lookahead planning using scenario trees. We empirically demonstrate that our method yields substantially more informative design sequences than existing methods across a range of constrained BED tasks, while incurring only a modest additional computational overhead.
Yujia Guo, Daolang Huang, Xinyu Zhang +3
ELLIS Institute Finland · Department of Computer Science, Aalto University, Finland · Department of Computer Science, University of Manchester, UK
Bayesian experimental design (BED) has traditionally been based on maximising expected uncertainty reductions from prior to posterior. A major shortfall of this approach is that it leads to doubly intractable objectives that are difficult to optimise, while customising them to particular downstream tasks of interest can also be difficult. Following first principles decision theory, we demonstrate that BED can alternatively be formulated in terms of an expected future loss (EFL) on downstream actions, providing a simple and naturally task-driven framework. Critically, we then show that all such EFLs can be rearranged into singly intractable objectives that can be jointly optimised with respect to both the design policy and a downstream action policy using stochastic gradients, an approach we refer to as ACTION-BED. This formulation further sidesteps the need for any explicit posterior or marginal likelihood estimation and is naturally implicit, requiring only the ability to sample from the joint model over model parameters and data, and evaluate the downstream loss function. It thus allows design policies to be learned more effectively, efficiently, and simply than existing methods, while providing easy customisation to different downstream tasks and losses.
Standard Bayesian experimental design (BED) methods assume the experimenter alone will act on the data, choosing the best action given their own beliefs and goals. In practice, data are often acted on by external parties whose procedures the experimenter cannot change and may not know, particularly when the data are released publicly. To extend BED to such settings, we introduce usage-aware experimental design, a framework in which an adaptive design policy is trained to minimise the usage risk: the experimenter's expected loss when one or more external rules act on the collected data. These rules may be non-Bayesian or black-box, and when several may apply, we either average over them or take the worst case. We show that, unlike in standard BED, more informative data can be harmful under such rules, so the usage risk cannot in general be expressed as an expected uncertainty reduction; our framework thus strictly generalises standard BED. We then use it to tackle a range of problems that are difficult to address with existing approaches.