Evolution Transformer: In-Context Evolutionary Optimization

Robert Tjarko Lange, Yingtao Tian, Yujin Tang

TL;DR

The Evolution Transformer (EvoTF) is a novel causal Transformer architecture that learns to perform black-box optimization entirely in-context. By distilling classical evolutionary algorithms or bootstrapping its own performance from scratch via self-referential learning, EvoTF successfully generalizes to unseen optimization landscapes and robustly outperforms traditional hand-crafted baselines.

Figure 1: Left. Evolution Transformer overview. The model encodes three different types of information (solution space, fitness & search distribution). The resulting per-search dimension embedding is processed by an update network using parameter sharing. The Evolution Transformer is trained by generating optimization trajectories from teacher BBO algorithms and minimizing the KL divergence between student and teacher search distribution updates. Right. Aggregated results on 8 Brax tasks and 5 individual runs (see SI, Figure 10). We report the interquartile mean and optimality gap after normalizing by the task-specific OpenAI-ES [32] performance. Evolution Transformer robustly outperforms Evolutionary Optimization baselines.

What Problem Does This Paper Address?

Traditional Evolutionary Strategies (ES) for black-box optimization are typically derived from loose biological analogies (like mutation and selection). While effective, these hand-crafted algorithms struggle to dynamically adapt to specific problem landscapes or fully leverage the sequential history of an ongoing optimization trajectory.

To fix this, researchers have turned to meta-optimization—using data to discover optimization principles. However, previous attempts either lacked the capability to model long-term sequential dependencies or failed to incorporate crucial inductive biases inherent to evolutionary algorithms. Specifically, an ideal black-box optimizer should be population-order invariant (the order of candidate solutions in a generation shouldn't change the outcome) and dimension-order equivariant (the optimization shouldn't depend on an arbitrary ordering of the search dimensions).

Methods

The authors introduce the Evolution Transformer (EvoTF), a causal Transformer architecture tailored for evolution strategies.

Architecture & Inductive Biases

EvoTF processes three types of information per generation: candidate solutions, their corresponding fitness scores, and search distribution statistics (like momentum). To enforce the necessary inductive biases, the architecture utilizes a decoupled embedding scheme:

  • Solution & Fitness Perceivers: Cross-attention mechanisms compress population data into fixed-shape latent vectors, ensuring population-order invariance regardless of population size.
  • Dimension-Batched Processing: The model batches operations over individual search dimensions using shared parameters, guaranteeing dimension-order equivariance.

The combined embeddings are then fed into standard Multi-Head Self-Attention (MHSA) Transformer blocks across time, outputting autoregressive updates ($\Delta\mu, \Delta\sigma$) to the search distribution.

Figure 2: Evolution Transformer. We construct features resembling information from solution evaluations and the search distribution. They are processed by self-attention and Perceiver modules to obtain four separate embeddings. The stacked per-dimension embeddings are processed by standard Transformer encoder blocks. An MLP outputs the distribution update predictions. The model is invariant to the order of the population members and equivariant to the search dimension order.

Training Paradigms

  1. Evolutionary Algorithm Distillation (EAD): A supervised approach where EvoTF learns to clone existing "teacher" algorithms (e.g., OpenAI-ES, Sep-CMA-ES) by minimizing the Kullback-Leibler (KL) divergence between the student and teacher search distribution updates.
  2. Self-Referential EAD (SR-EAD): A training method from scratch that eliminates the need for a teacher. EvoTF generates its own trajectories via random parameter perturbations, filters the best-performing runs, and distills them to bootstrap its own learning progress.

Datasets

The model is trained and evaluated across several distinct task families:

  • BBOB (Black-Box Optimization Benchmarking): A standard synthetic benchmark suite containing functions with diverse landscape characteristics (e.g., Sphere, Rosenbrock, Rastrigin) used for both training and holdout evaluation.
  • Neuroevolution Tasks: Downstream evaluation tasks including a 14x14 MNIST CNN classification problem and a Pendulum MLP control task.
  • Brax Continuous Control: Eight challenging continuous control environments (e.g., Ant, HalfCheetah, Hopper, Walker2d) evaluated using a population size of $N=128$.

Key Insights and Ideas

  • True In-Context Optimization: At test time, EvoTF's weights are frozen. It performs optimization purely by processing the history of the current trajectory within its context window, adapting its strategy on the fly.
  • Emergent Mathematical Properties: Without explicit programming, the distilled EvoTF automatically captures fundamental ES properties like unbiasedness on random fitness functions, translation invariance, and scale self-adaptation on linear functions.
  • Landscape Awareness via Attention: Visualizing the internal attention maps revealed that EvoTF alters its behavior based on the problem structure. For separable landscapes (like the Sphere function), it focuses attention dimension-by-dimension. For non-separable landscapes (like the Rosenbrock function), it splits attention across dimensions, effectively sharing evaluation information.

Key Results

  • Successful Distillation: EvoTF successfully cloned highly distinct teacher algorithms (SNES, Hill Climbing, Sep-CMA-ES, OpenAI-ES), rapidly minimizing KL loss during training.
  • Baseline Outperformance: When evaluated on the Brax continuous control benchmarks, an SNES-distilled EvoTF robustly outperformed traditional evolutionary optimization baselines in terms of Interquartile Mean (IQM) and Optimality Gap.
  • Generalization: Models trained on simple 5-dimensional synthetic BBOB functions successfully generalized to optimize neural networks with thousands of parameters on unseen tasks like the Brax Ant environment.
Figure 3: Evolutionary Algorithm Distillation allows EvoTF to distill teacher algorithms. Top. KL distillation loss with different Transformer modules. Middle. Evaluation on a 14x14 MNIST CNN Classification task throughout distillation. Bottom. ’S+F’ uses only the Solution and Fitness Perceiver. ’S+F+D’ also uses the Distribution Attention and ’S+F+D+CD’ uses all network modules. Evaluation on a Pendulum MLP Control task throughout distillation. Results are averaged across 3 independent runs.

Limitations and Future Work

  • Memory Constraints: Processing long sequences across high-dimensional search spaces creates a massive memory footprint on hardware accelerators. The authors had to use a sliding context window ($K=5$), which limits the model's long-term memory.
  • Instability in Self-Referential Learning: While SR-EAD proved that teacherless training is possible, it exhibited instability on certain tasks (like the Pendulum control problem), where performance dropped after initial improvements.
  • Mechanistic Understanding: Although attention maps provide some clues, a complete mechanistic understanding of how the Transformer executes these black-box updates remains an open research question.

Future directions include exploring alternative sequence architectures like State Space Models (SSMs) to alleviate context length limitations and expanding benchmarks to more diverse task sets.

Summary updated

BibTeX
@inproceedings{lange2024evolution,
  author = {Robert Tjarko Lange and Yingtao Tian and Yujin Tang},
  title = {{Evolution Transformer: In-Context Evolutionary Optimization}},
  booktitle = {GECCO Companion},
  year = {2024},
  url = {https://openreview.net/forum?id=uc9j2BhSlR},
}
Figure