Reinforced In-Context Black-Box Optimization

Lei Song, Chen-Xiao Gao, Ke Xue, Chenyang Wu, Dong Li, Jianye Hao, Zongzhang Zhang, Chao Qian

Abstract

Black-Box Optimization (BBO) is a critical challenge in fields ranging from hyperparameter tuning to drug discovery. Traditional approaches rely on hand-crafted algorithms that often fail to leverage historical experience. We present RIBBO (Reinforced In-context Black-Box Optimization), an end-to-end framework that treats optimization as a sequence modeling task. By training a Causal Transformer on offline optimization histories and conditioning it on "Regret-To-Go" (RTG) tokens, RIBBO learns to automatically identify and execute high-performance search strategies across diverse problems without requiring manual algorithm selection.

Introduction

In many real-world scenarios, the mathematical formula for an objective function is unknown, necessitating Black-Box Optimization. While Bayesian Optimization (BO) and Evolutionary Algorithms (EA) are effective, they typically solve each problem from scratch. Recent meta-learning efforts have attempted to address this, but fully end-to-end models often require expensive online sampling or manual algorithm imitation at test time. RIBBO addresses these limitations by creating a universal optimizer that learns from offline data and autonomously determines the optimal search trajectory.

Methodology

RIBBO leverages the in-context learning capabilities of Causal Transformers, viewing optimization history as a sequence of triplets: $(x_t, y_t, R_t)$, where $x$ is the query point, $y$ is the function value, and $R$ is the Regret-To-Go (RTG).

Sequence Modeling and Regret-To-Go

Borrowing from the Decision Transformer architecture, RIBBO augments data with RTG tokens. $R_t$ represents the sum of future regrets from time $t$ to the end of the budget. Conditioning on a low RTG during training teaches the model to follow high-performing trajectories.

Overview of RIBBO data generation and the Causal Transformer architecture for training and inference.

Hindsight Regret Relabelling (HRR)

A key innovation is Hindsight Regret Relabelling (HRR) for the inference phase. Since the true optimum $y^*$ is unknown during live optimization, the exact RTG cannot be calculated. HRR begins with a target RTG of 0 and "relabels" the history dynamically. As new points are evaluated, the model updates the RTG of all previous steps to maintain mathematical consistency and ensure the sequence remains within the transformer's training distribution.

Experimental Setup

The model was evaluated on a diverse set of benchmarks:

  • BBOB (Black-Box Optimization Benchmarks): 24 synthetic functions representing various mathematical challenges.
  • HPO-B: Large-scale hyperparameter optimization for SVM and XGBoost models.
  • Rover Trajectory Planning: A robot control task involving 2D navigation.

To train the model, offline data was generated using seven distinct algorithms, including Random Search, CMA-ES, Eagle Strategy, and GP-EI.

Results and Discussion

RIBBO consistently outperformed individual behavior algorithms and other end-to-end models like OptFormer across BBOB and XGBoost tasks.

Visualization of search trajectories on the Branin function and the performance impact of the RTG update strategy (HRR).

Key Insights

  • In-Context Identification: The transformer uses previous queries to identify task difficulty and the optimal algorithm to imitate.
  • Performance Dialing: Conditioning on RTG allows users to effectively "dial in" performance; setting RTG to 0 encourages the model to emulate the best possible versions of training algorithms.
  • Robustness and Generalization: RIBBO demonstrated "cross-distribution generalization," performing well on mathematical functions unseen during training. Visualization of search trajectories (e.g., on the Branin function) shows the model successfully identifying landscapes and focusing queries on high-value areas more effectively than its training algorithms.

Conclusion and Future Work

RIBBO represents a significant step toward universal black-box optimizers. While it excels in complex landscapes, it may be overkill for very simple, low-dimensional problems. Future work will focus on scaling RIBBO to higher-dimensional spaces and incorporating complex constraints into the in-context learning framework.

Summary updated

BibTeX
@inproceedings{song2025reinforced,
  author = {Lei Song and Chen-Xiao 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