Introduction
Bayesian Optimization (BO) is a powerful strategy for optimizing expensive, black-box reward functions—ranging from drug discovery to quantum circuit design. Traditionally, BO maintains a surrogate model (like a Gaussian Process) and uses an acquisition function to determine the next candidate to evaluate. While effective in continuous spaces where gradient ascent can be used, BO struggles in large, unstructured discrete spaces. In domains like protein engineering, where the number of possible amino acid sequences is astronomical, searching for the maximum of an acquisition function becomes computationally intractable.
The ToSFiT Framework
To overcome this bottleneck, this paper introduces Thompson Sampling via Fine-Tuning (ToSFiT). Rather than explicitly maximizing an acquisition function, ToSFiT treats the generation process of a Large Language Model (LLM) as a form of Thompson sampling. By fine-tuning the LLM to approximate the "Probability of Maximality" (PoM), the model learns to directly output high-reward candidates.
The ToSFiT process follows four main steps:
- Initialization: An LLM is prompted with task-specific instructions, establishing a strong prior.
- Generation: The LLM generates a batch of candidates, acting as Thompson samples.
- Evaluation & GP Update: Candidates are evaluated by the real reward function. A constant-time Gaussian Process (GP) updates its posterior belief using candidate embeddings.
- Fine-Tuning: The LLM's weights are updated using a Variational Bayesian Optimistic Sampling (VBOS) objective, nudging the model to match the GP's updated posterior.
Theoretical Foundations and Insights
A key theoretical contribution is the derivation of a novel cumulative regret bound for VBOS. The authors show that ToSFiT matches the strong guarantees of standard Thompson sampling, scaling with the information gain rather than the size of the discrete space.
Furthermore, the authors identify the "Careful Fine-Tuning" principle. In massive discrete spaces, it is vital that the model does not drift too far from its pre-trained policy. Using small learning rates and variance-reduced advantage functions (like RLOO/GRPO) allows the model to retain its general-purpose prior while specializing in high-reward regions.
Experimental Results
ToSFiT was evaluated across three diverse tasks:
- FAQ Response Refinement: Optimizing semantic alignment using Qwen3.
- Protein Search: Designing thermally stable sequences using ProtGPT2.
- Quantum Circuit Design: Generating Qiskit code for low-energy states using Qwen2.5-Coder.
In all cases, ToSFiT demonstrated superior sample efficiency, finding higher-reward candidates with fewer evaluations than evolutionary search or in-context BO baselines. Additionally, because it avoids explicit acquisition maximization, ToSFiT is highly computationally efficient, maintaining low latency even as the number of observations grows.
Conclusion and Future Work
ToSFiT represents a significant step forward in making Bayesian Optimization scalable for discrete domains. By shifting the computational burden from searching a space to sampling from a neural network, it enables efficient optimization in previously unreachable domains. Future work includes exploring task-adaptive embeddings and reducing the compute overhead of full-parameter fine-tuning through methods like LoRA.
Summary updated