arXiv:2610.01269cs.LGOct 2026

Manuscript Offprint

arXiv:2610.01269

IQS-BO: In-Context Query Selection for Bayesian Optimisation

Luca Geminiani, Nadja Klein

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Bayesian Optimisation (BO) is a powerful framework for the optimisation of expensive black-box functions, but typically requires refitting a surrogate and maximising an acquisition function at every evaluation step. In-context approaches based on Prior-data Fitted Networks (PFNs) amortise part of this cost by pre-training transformers on functions drawn from synthetic priors. PFNs4BO amortises the surrogate but still relies on a numerically maximised acquisition function, while FIBO performs BO fully in-context by sampling optimiser locations from a learned density, which fixes the decision rule and admits no surrogate. Learned acquisition functions score a finite candidate set with a trained network, but, lacking a label for the query, learn the score by reinforcement learning on previously solved tasks. We propose IQS-BO, a PFN that learns the query decision by supervised learning on synthetic priors. In a single forward pass, IQS-BO predicts the probability that each candidate maximises the objective over the set, and we show that the minimiser of its objective is the posterior probability of this event. The model can be pre-trained without a surrogate for fully in-context BO, or take the predictions of a fixed probabilistic surrogate as additional input, amortising only the decision step. Our method proposes queries at a fraction of the cost of acquisition-based methods, while either matching or outperforming standard BO with Gaussian processes (GPs) and available in-context methods on synthetic and real-world benchmarks. Finally, we propose a mixture prior for pre-training PFNs which combines samples from GPs with functions exhibiting warped inputs, isolated narrow optima, or plateaus that are poorly modeled by stationary kernels common in GP surrogates. We show that pre-training on this prior can lead to improved optimisation performance.

1 INTRODUCTION

Bayesian optimisation (BO) (Jones et al., 1998; Shahriari et al., 2016; Garnett, 2023) aims to maximise an expensive black-box function, and has proven particularly beneficial when objective evaluations are costly and only a limited number of evaluations is available. Given an initial dataset, BO typically alternates between fitting a probabilistic surrogate and selecting the next evaluation point by maximising an acquisition function. Both steps are repeated for every new observation: the surrogate must adapt as the dataset grows, while the acquisition function is a non-convex objective whose optimisation often requires dedicated sampling, restart, and numerical optimisation procedures (Wilson et al., 2018).

In-context methods can reduce per-round costs by pre-training transformer architectures on functions drawn from priors from which sampling is efficient (Müller et al., 2022). Existing methods differ in which part of the BO process they amortize (Figure 1).

PFNs4BO (Müller et al., 2023) amortizes the surrogate with a Prior-data Fitted Network (PFN) which returns the posterior predictive of each input in a single forward pass. Surrogate fitting is no longer required, since the model adapts to new observations in context, but an acquisition function must still be specified and numerically maximised at every round. Moreover, the acquisition function requires a closed form on the PFN's output.

FIBO (de Carvalho et al., 2025) removes the surrogate fit as well as the choice and maximisation of the acquisition function. A pre-trained PFN encoder embeds the observations, and a normalizing flow conditioned on that embedding models the distribution of the optimum's location which is sampled

Preprint. Under review.

Figure

Traditional BO

PFNs4BO

FIBO

IQS-BO (Fully In-Context)

IQS-BO (With Surrogate)

Figure 1: One optimisation round of traditional BO, PFNs4BO (Müller et al., 2023), FIBO (de Carvalho et al., 2025) and IQS-BO with and without a surrogate. DkD_k: observations after kk evaluations, xk+1x_{k+1}: next query, CkC_k: candidates drawn from DkD_k, α\alpha: acquisition function, J∗J^*: index of the best candidate. Red: fitted or optimised every round. Green: one forward pass of a pre-trained network. Red-to-green: fixed surrogate of either kind. Blue: sampling without learning. Grey: quantities passed between steps.

directly to obtain proposals. The learned object is a density over the search space, and the authors show that sampling from it amounts to Thompson sampling under the pre-training prior. The method is especially suitable for high-throughput optimisation, since a batch of any size can be drawn almost for free as a set of i.i.d. draws, but implies a fixed query selection policy.

Relevant to our work, learned acquisition functions replace the analytic rule by a network that scores a finite candidate set. NAP (Maraval et al., 2023) uses a transformer neural process that reads the observations and candidates and returns a score for each, learning a surrogate and the acquisition rule jointly. POLAR (Huang et al., 2026) learns a similar score on top of the representations of a pretrained predictive model. Since the best point to query is unknown on real data, both learn the score from rewards, by reinforcement learning or policy gradient on rollouts over solved tasks.

To the best of our knowledge, no method learns the query decision by supervised learning on synthetic priors. Under such priors the training label is free, since each pre-training function can be evaluated at every candidate, so the best one is known and query selection becomes a classification problem. This is the basis for In-context Query Selection for Bayesian Optimisation (IQS-BO).

Concretely, IQS-BO trains a transformer that reads the observations and a candidate set and predicts, for each candidate, the probability that it has the largest function value in the set. The network is trained with a cross-entropy loss, whose minimiser is the posterior probability that each candidate is the best. At deployment, IQS-BO queries the candidate with the highest predicted probability, which approximates the Bayes-optimal choice among the candidates under the pre-training prior.

The proposed framework admits two implementations. First, the network can be trained directly on the observations, without a surrogate. This yields a model for fully in-context BO that, like FIBO, requires neither surrogate fitting nor acquisition function optimisation at deployment. Second, the network can take as additional input the predictions of a fixed probabilistic surrogate. We show this with a released PFNs4BO model and with a Gaussian process whose hyperparameters are fitted to each synthetic task during pre-training and refitted at every iteration during inference.

Empirically, IQS-BO, pre-trained for a fixed input dimension and batch size, (i) outperforms PFNs4BO pre-trained on the same prior and deployed via acquisition-function maximisation with L-BFGS-B, with gains increasing as both context size and batch size grow; (ii) matches or outperforms GP-based BO, FIBO and NAP across real and synthetic benchmarks in three and four dimensions; and (iii) excels in batch optimisation, reaching a better performance than FIBO at every batch size while maintaining comparable computational cost and proposing evaluations one to three orders of magnitude faster than PFNs4BO and GP-based baselines.

Finally, we propose and evaluate a pre-training prior that augments GP samples with function families that are poorly captured by fixed-kernel GPs. We show that PFN-based models pre-trained on this prior achieve better optimisation performance than on priors that only include GP samples. The gains are largest when the initial context is small and become less pronounced as the context grows.

Preprint. Under review.

References (80)