Reinforced In-Context Black-Box Optimization

Lei Song, Chenxiao Gao, Ke Xue, Chenyang Wu, Dong Li, Jianye Hao, Zongzhang Zhang, Chao Qian · OpenReview

Abstract

Black-Box Optimization (BBO) has found successful applications in many fields of science and engineering. Recently, there has been a growing interest in meta-learning particular components of BBO algorithms to speed up optimization and get rid of tedious hand-crafted heuristics. As an extension, learning the entire algorithm from data requires the least labor from experts and can provide the most flexibility. In this paper, we propose RIBBO, a method to reinforce-learn a BBO algorithm from offline data in an end-to-end fashion. RIBBO employs expressive sequence models to learn the optimization histories produced by multiple behavior algorithms and tasks, leveraging the in-context learning ability of large models to extract task information and make decisions accordingly. Central to our method is to augment the optimization histories with regret-to-go tokens, which are designed to represent the performance of an algorithm based on cumulative regret over the future part of the histories. The integration of regret-to-go tokens enables RIBBO to automatically generate sequences of query points that satisfy the user-desired regret, which is verified by its universally good empirical performance on diverse problems, including BBO benchmark functions, hyper-parameter optimization and robot control problems.

Introduction

Black-Box Optimization (BBO) is a fundamental challenge in science and engineering, critical for tasks ranging from drug discovery to tuning machine learning hyperparameters. In these scenarios, the objective function lacks a closed-form expression, and evaluation is often expensive and time-consuming. Traditional approaches, such as Bayesian Optimization (BO) or Evolutionary Algorithms (EA), rely on expert-designed heuristics. While effective, these methods typically start from scratch for each new problem and fail to exploit latent structures across tasks.

Reinforced In-context Black-Box Optimization (RIBBO) addresses these limitations by treating BBO as a sequence modeling task. By utilizing a Transformer architecture augmented with "regret-to-go" tokens, RIBBO learns to optimize complex functions by observing the histories of existing algorithms, eventually outperforming its training "teachers."

Methodology

RIBBO frames the optimization process as a sequence of triplets: query point $x$, function value $y$, and performance token $R$.

Overview of the RIBBO framework, showing (a) the data generation process with regret-to-go tokens and (b) the training and inference pipeline using a Causal Transformer.

The framework consists of several key components:

  • Causal Transformer Backbone: A GPT-style architecture processes optimization histories, leveraging in-context learning to identify task characteristics and adapt strategies dynamically.
  • Regret-To-Go (RTG) Tokens: Inspired by Decision Transformers, training data is labeled with RTG tokens representing cumulative future regret (the gap between current values and the global optimum). This allows the model to associate specific query patterns with performance outcomes.
  • Hindsight Regret Relabelling (HRR): Since the global optimum is unknown during inference, RIBBO sets the target regret to zero and updates history tokens as better points are discovered. This mechanism focuses the model on continuous improvement.

Experimental Setup

RIBBO was evaluated across diverse benchmarks:

  • BBOB (Black-Box Optimization Benchmarking): 24 synthetic functions representing various landscapes (e.g., separable, multi-modal).
  • HPO-B: Real-world hyper-parameter optimization for SVM and XGBoost models.
  • Rover Trajectory Planning: A robot control task requiring optimal pathfinding for a planetary rover.
  • Behavior Data: Training data was sourced from seven algorithms, including Random Search, CMA-ES, and GP-EI, providing a rich library of optimization behaviors.

Results and Discussion

RIBBO demonstrates a unique ability to "filter" training data. By conditioning on low RTG, it learns to ignore inferior strategies (like Random Search) and mimic high-performance behaviors. The Transformer uses initial query points to "diagnose" the function landscape, allowing a single model to switch between strategies resembling Evolutionary Algorithms or Bayesian Optimization as needed.

Key findings include:

  • Universal Performance: RIBBO achieved superior or equivalent results compared to specialized behavior algorithms on nearly all tasks.
  • Generalization: The model generalized effectively to unseen functions, indicating it learned fundamental optimization principles rather than simple curve memorization.
  • Superiority over Behavior Cloning: RIBBO significantly outperformed standard Behavior Cloning (BC) baselines by "cherry-picking" the best strategies through RTG conditioning.

Conclusion and Future Work

While RIBBO shows strong empirical performance, some limitations remain. The current model is restricted to fixed-dimensional continuous search spaces; extending it to heteroscedastic spaces is a priority. Additionally, on very simple problems, the Transformer's overhead can lead to slightly lower performance than basic heuristics. Future work will also focus on providing a formal mathematical analysis of the in-context optimization process performed by the Transformer.

Summary updated

BibTeX
@inproceedings{song2025reinforced,
  author = {Lei Song and Chenxiao Gao and Ke Xue and Chenyang Wu and Dong Li and Jianye Hao and Zongzhang Zhang and Chao Qian},
  title = {{Reinforced In-Context Black-Box Optimization}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.24963/ijcai.2025/994},
}
Figure