Predicting from Strings: Language Model Embeddings for Bayesian Optimization

Tung Nguyen, Qiuyi Zhang, Bangding Yang, Chansoo Lee, Jörg Bornschein, Yingjie Miao, Sagi Perel, Yutian Chen, Xingyou Song · DOI

Introduction

Bayesian Optimization (BO) is a powerful technique for optimizing "black-box" functions where the underlying mathematical relationship is unknown, such as tuning hyper-parameters for neural networks or optimizing chemical formulas. Traditionally, BO relies on Gaussian Processes (GPs) to model the objective function. However, GPs are notoriously rigid; they typically require fixed-length, tabular input features. This limitation makes it difficult to apply BO to complex, non-tabular search spaces like permutations, varying-length lists, or combinatorial structures without significant manual feature engineering.

Researchers from Google DeepMind and UCLA have introduced "Embed-then-Regress" (EtR), a framework that leverages the flexibility of Large Language Models (LLMs) to create a more universal regressor for optimization. By representing any candidate solution as a string, the framework can handle diverse search spaces using a single, unified architecture.

The Embed-then-Regress Framework

The core of the EtR approach is a simple yet effective multi-stage pipeline that converts structured data into actionable predictions.

Conceptual overview of the Embed-then-Regress framework, illustrating the mapping from string-based search spaces to embeddings for in-context regression.
  1. String Representation: Every candidate solution $x$ is converted into a string format (e.g., a JSON-like representation such as {"p0": 0.3, "p1": "cat_1"}). This allows the model to treat any input—whether numerical, categorical, or structural—as a sequence of tokens.
  2. Frozen Embedding: The string is processed by a frozen LLM encoder, specifically T5-XL. The resulting token representations are average-pooled into a fixed-length vector. Remarkably, the authors found that the LLM does not need to be fine-tuned on optimization data; its pre-existing knowledge of language and structure provides high-quality features for regression.
  3. In-Context Regressor: These vectors are fed into a Transformer Neural Process (TNP). Unlike the frozen LLM, the TNP is specifically trained to perform regression. It analyzes a "history" of previous trials (embeddings and their corresponding scores) to predict the performance of new candidates.
  4. Pretraining and Optimization: The regressor is pretrained on a massive scale using 1 million synthetic tasks from the BBOB (Black-box Optimization Benchmarking) suite. During active optimization, the model uses an Upper Confidence Bound (UCB) acquisition function to balance exploration and exploitation.

Empirical Performance

The model was rigorously evaluated across three domains: synthetic mathematical functions (BBOB), combinatorial optimization (e.g., Traveling Salesman, N-Queens), and real-world hyperparameter optimization (HPO) for models like ResNets and Vision Transformers.

Optimization performance (negative objective value vs. trials) on synthetic BBOB functions, comparing EtR against industry-standard baselines.

On standard synthetic tasks, EtR matched or outperformed Google Vizier, an industry-grade GP-based optimizer. In combinatorial spaces—where traditional GPs often struggle—the model significantly enhanced the performance of evolutionary algorithms by serving as an intelligent filter for proposed solutions. Furthermore, on 20 HPO surrogate tasks, the model achieved median log-efficiency comparable to state-of-the-art GP methods, demonstrating its viability for real-world engineering applications.

Key Insights and Future Directions

A major takeaway of this research is that LLM embeddings capture enough structural "common sense" to serve as universal features for optimization, even when the data bears little resemblance to natural language. The authors observed that regression accuracy scales monotonically with the size of the LLM embedder, suggesting that larger models provide increasingly sophisticated features.

While the current framework is limited by the context window of Transformers—capping the number of historical trials the model can remember—future work will explore more sophisticated pooling strategies and improved uncertainty quantification. The ultimate goal is a "universal regressor" that can be applied "plug-and-play" to any optimization task defined by string-based inputs, from chemical design to automated code generation.

Summary updated

BibTeX
@misc{nguyen2024predicting,
  author = {Tung Nguyen and Qiuyi Zhang and Bangding Yang and Chansoo Lee and Jörg Bornschein and Yingjie Miao and Sagi Perel and Yutian Chen and Xingyou Song},
  title = {{Predicting from Strings: Language Model Embeddings for Bayesian Optimization}},
  year = {2024},
  eprint = {2410.10190},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.10190},
}
Figure