TLDR: TOSFIT (Thompson Sampling via Fine-Tuning) is a new method that scales Bayesian optimization to large, unstructured discrete spaces by fine-tuning large language models (LLMs). It avoids the computational cost of maximizing acquisition functions by directly parameterizing the probability of a candidate yielding the maximum reward. By leveraging LLM’s prior knowledge and incrementally adapting them, TOSFIT significantly improves sample efficiency across diverse tasks like FAQ response refinement, protein search, and quantum circuit design, while maintaining computational efficiency.
In the realm of artificial intelligence, particularly when dealing with complex decision-making and optimization, a method called Bayesian optimization stands out. It’s a powerful framework used for optimizing expensive, black-box functions, especially when evaluations are costly or time-consuming. Imagine trying to find the best recipe for a new material or the most effective drug compound – Bayesian optimization helps navigate these vast possibilities efficiently.
However, a significant challenge arises when these optimization problems involve large, unstructured discrete spaces. Think of designing a protein sequence from 20 amino acids, where a sequence of just 100 amino acids creates a search space larger than the number of atoms in the observable universe. In such scenarios, traditional Bayesian optimization methods, which often rely on maximizing an ‘acquisition function’ to select the next best candidate, become computationally intractable because there are no gradients to guide the search efficiently.
A new approach, called Thompson Sampling via Fine-Tuning (TOSFIT), has been proposed to tackle this very problem. Developed by Nicolas Menet, Aleksandar Terzi´c, Michael Hersche, Andreas Krause, and Abbas Rahimi, TOSFIT offers a scalable alternative that eliminates the need for complex acquisition function maximization. Instead, it directly estimates the probability that a candidate will yield the maximum reward.
How TOSFIT Works
At its core, TOSFIT leverages the power of large language models (LLMs). These models come with a vast amount of prior knowledge embedded within them from their pre-training. TOSFIT takes these prompt-conditioned LLMs and incrementally adapts them towards the ‘posterior probability of maximality’ (PoM). Essentially, it fine-tunes the LLM to learn which candidates are most likely to be optimal, treating the LLM’s generations as direct samples from this probability distribution.
This method builds on an existing framework called Variational Bayesian Optimistic Sampling (VBOS) but introduces a crucial distinction: instead of starting from a uniform policy and optimizing towards the posterior PoM, TOSFIT initializes with a powerful pre-trained LLM. This allows it to start with a strong ‘belief’ about promising areas in the search space and then carefully refine that belief as new information (rewards from evaluated candidates) becomes available.
The theoretical underpinnings of TOSFIT are robust. The researchers derived a new regret bound for a variational formulation of Thompson Sampling. This bound matches the strong guarantees of its standard counterpart, indicating that TOSFIT can achieve optimal performance over time. The analysis also highlighted the critical importance of carefully adapting the LLM to the posterior probability of maximality, a principle that guides the algorithm’s design.
Key Advantages and Empirical Validation
TOSFIT offers several significant advantages:
- Scalability: It can efficiently handle combinatorially large unstructured discrete domains where traditional methods fail.
- Leveraging Prior Knowledge: It effectively uses the vast knowledge already present in pre-trained LLMs, accelerating the optimization process.
- Improved Sample Efficiency: By intelligently guiding the search, it finds better solutions with fewer evaluations.
- Computational Efficiency: The online fine-tuning has a negligible impact on computational overhead compared to unguided generation.
The method was rigorously tested on three diverse tasks:
- FAQ Response Refinement: Optimizing text responses for semantic alignment.
- Thermally Stable Protein Search: Designing amino acid sequences for high thermal stability, crucial for drug development.
- Quantum Circuit Design: Creating quantum circuits to prepare low-energy quantum states.
Across all these experiments, TOSFIT consistently outperformed baselines such as unguided generation, post-generation Thompson sampling, Actor Critic, and Soft Actor Critic. It demonstrated the ability to overcome performance plateaus that fixed generative models encounter and effectively explore the full solution space to discover higher-reward candidates. The research also showed that a strong initial policy (from pre-training and context) significantly accelerates optimization, and careful adaptation (with appropriate learning rates) is essential to retain this prior knowledge.
Furthermore, TOSFIT naturally extends to batched Bayesian optimization, a setting where multiple candidates can be evaluated simultaneously. This is particularly useful when observations are delayed or time-consuming, improving iteration efficiency even if it slightly reduces sample efficiency.
Also Read:
- Boosting Diffusion Language Model Performance with Memory-Efficient Reinforcement Learning
- Bridging AI Learning Methods: A New Approach to Scalable Task Adaptation
Conclusion
TOSFIT represents a significant step forward in applying Bayesian optimization to challenging discrete search problems. By combining the power of foundation models with principled Bayesian optimization, it offers a scalable and efficient solution for tasks ranging from natural language processing to scientific discovery. For more in-depth details, you can read the full research paper here.


