TL;DR
ToSFiT (Thompson Sampling via Fine-Tuning) is a novel framework that scales Bayesian Optimization (BO) to massive, unstructured discrete spaces—like protein sequences or quantum circuits—by fine-tuning Large Language Models (LLMs). Instead of the computationally expensive process of searching for the "best" next candidate using an acquisition function, ToSFiT trains an LLM to directly generate candidates proportional to their probability of being the global optimum.
The Challenge of Discrete Spaces
Bayesian Optimization is the gold standard for finding the global maximum of "black-box" functions that are expensive to evaluate, such as wet-lab protein testing. Traditionally, BO works by building a surrogate model (like a Gaussian Process) and then maximizing an acquisition function to pick the next point to test.
In continuous spaces, we can use gradients to efficiently find this next point. However, in unstructured discrete spaces—such as the space of all possible 100-amino-acid proteins, which contains more combinations than there are atoms in the universe—there are no gradients. To find the absolute "best" next candidate, you would theoretically have to check every single possibility, which is intractable. Existing workarounds, like searching over a small random subset or using evolutionary algorithms, often lack theoretical guarantees or fail to leverage the rich "prior knowledge" already baked into pre-trained LLMs.
The ToSFiT Framework
The authors introduce ToSFiT, which reframes Thompson Sampling (a popular BO strategy) as a generative task.
- Probability of Maximality (PoM): Thompson Sampling essentially picks points based on the probability that they are the optimal choice. ToSFiT uses an LLM to directly parameterize this distribution.
- Variational Objective: Building on Variational Bayesian Optimistic Sampling (VBOS), ToSFiT avoids standard RL objectives that solely maximize expected reward. Instead, it includes an "adaptive exploration bonus" derived from the LLM’s own log-probabilities. This prevents the model from collapsing into a single "safe" answer (exploitation) and encourages it to explore uncertain regions.
- Fine-Tuning vs. In-Context Learning: Unlike previous methods that stuff previous results into the LLM's prompt—eventually hitting context window limits and slowing down—ToSFiT updates the model weights directly.
- Gradient Stability: The framework uses the RLOO (Reinforce Leave-One-Out) baseline to stabilize training. The authors prove that their standardized RLOO approach is mathematically equivalent to GRPO, the reinforcement learning algorithm recently popularized by DeepSeek.
- Theoretical Regret Bound: The paper derives a new, tighter regret bound $O(\sqrt{T \gamma_T})$ that accounts for the correlation between different points in the search space (via the "maximal information gain" $\gamma_T$), matching the strong guarantees of classical Thompson Sampling.
Key Insights and Ideas
- LLMs as Priors: A pre-trained LLM serves as a world-class "prior" for these complex spaces. ToSFiT doesn't start from scratch; it uses the LLM's internal knowledge of protein structures or code syntax and "nudges" it toward the posterior distribution of the specific task.
- The "Careful Adaptation" Principle: Theoretical analysis suggests that fine-tuning too aggressively causes the model to "forget" the prior, causing regret bounds to fail. Success requires starting with a strong prompt-conditioned prior and adapting it cautiously.
- Diversity is Built-In: Standard RL (Actor-Critic) often suffers from "mode collapse," repeatedly suggesting the same few good points. Because ToSFiT is grounded in the PoM, it naturally maintains high generation entropy, ensuring a diverse batch of candidates.
Experimental Validation
The authors evaluate ToSFiT on three complex, high-dimensional optimization tasks:
- FAQ Response Refinement: Optimizing LLM-generated text to align with a hidden ground-truth semantic target (using Qwen3 models).
- Protein Search: Designing amino acid sequences with high thermal stability (using ProtGPT2). The search space here is $20^{100}$.
- Quantum Circuit Design: Generating Qiskit code to prepare low-energy quantum states (using Qwen2.5-Coder). This requires navigating valid code syntax while optimizing for physical properties.
Key Results: * State-of-the-Art Sample Efficiency: Across all tasks, ToSFiT found better solutions with fewer evaluations than evolutionary search, standard RL, or "Post-Generation" Thompson Sampling. * Computational Efficiency: In the Protein Search task, ToSFiT was significantly faster than in-context methods like FIBO. While FIBO’s cost scales quadratically with the number of rounds, ToSFiT’s cost per round remains constant. * Scaling: The method works across model sizes (0.6B to 8B parameters). While larger models helped significantly in natural language tasks, the benefit was smaller in specialized domains like protein design, suggesting that "novel discovery" often requires moving beyond the training data manifold.
Limitations and Future Work
- Fixed Kernels: The current implementation uses fixed feature maps (embeddings) for the Gaussian Process. Learning these features jointly with the LLM fine-tuning could further improve performance.
- GP Complexity: Using a linear GP for efficiency ($O(d^2)$ memory) might limit the expressiveness of the reward surrogate compared to deep neural networks or ensembles.
- Weight Updates: Fine-tuning requires backpropagation, which is computationally heavier than simple prompting. Exploring "in-context conditioning" as a lighter alternative to weight adaptation remains a promising future path.
Summary updated