Emergence of In-Context Reinforcement Learning from Noise Distillation

Ilya Zisman, Vladislav Kurenkov, Alexander Nikulin, Viacheslav Sinii, Sergey Kolesnikov

Transformers have shown remarkable abilities to adapt to new tasks "in-context" without updating their weights. In Reinforcement Learning (RL), this means an agent can improve its performance in a new environment simply by observing its recent history of states, actions, and rewards. However, training these In-Context RL (ICRL) models is notoriously difficult due to a strict "data wall."

The Data Wall in In-Context RL

Current methods for training ICRL agents face significant data acquisition hurdles:

  1. Algorithm Distillation (AD) requires "learning histories"—the comprehensive logs of thousands of separate RL agents being trained from scratch. This is computationally expensive and often impractical.
  2. Decision Pretrained Transformers (DPT) require data generated by optimal expert policies, which are frequently impossible to obtain for complex, real-world tasks.

This raises a critical question: Can we "fake" the learning process? Is it possible to generate data that mimics an agent improving over time without actually running expensive RL training loops or relying on perfect experts?

Introducing $AD^\varepsilon$: Noise-Induced Curriculum

To bypass these limitations, researchers introduce $AD^\varepsilon$ (Algorithm Distillation with epsilon-noise). Instead of training an RL agent from scratch or relying on an expert, $AD^\varepsilon$ takes a single, potentially suboptimal demonstrator policy and applies a noise-induced curriculum.

Comparison of AD, DPT, and the proposed AD-epsilon method

The process works as follows:

  • The Curriculum: Trajectories are generated where the agent initially takes purely random actions ($\varepsilon = 1.0$). Over many episodes, this injected noise is gradually decreased until the agent strictly follows the demonstrator policy ($\varepsilon = 0.0$).
  • Synthetic Learning Histories: This sequence of "random-to-competent" trajectories perfectly mimics the behavior of an agent actively learning a task.
  • Distillation: A causal Transformer (like GPT-2) is then trained to predict the next action given this history. Because the training data is ordered by increasing performance, the Transformer learns the "policy improvement operator"—essentially learning the process of how to get better at a task.

Key Insights and Performance

The method was evaluated across three distinct environments: Dark Room (a 2D grid-world), Key-to-Door (a complex grid-world requiring sequential subgoals), and Watermaze (a challenging 3D environment with pixel-based observations).

Performance of AD-epsilon across Dark Room, Key-to-Door, and Watermaze environments

The results reveal several profound insights into how Transformers learn RL tasks:

  • Learning is an Order, Not a Process: Transformers do not necessarily need to observe a real learning algorithm. They simply need to see trajectories ordered from "bad" to "good." The emergence of ICRL is largely a result of the model learning to map historical performance gains to future action improvements.
  • Outperforming the Data: You don't need an expert. If you have a mediocre policy, you can still create a noise curriculum. In the Dark Room environment, the $AD^\varepsilon$ agent achieved a +120% improvement over the best suboptimal policy in the dataset, effectively distilling the underlying logic to outperform its own demonstrator.
  • Generalization and Efficiency: The models successfully generalized to unseen goals in all environments, proving they perform genuine in-context adaptation rather than mere memorization. Furthermore, $AD^\varepsilon$ performs on par with standard Algorithm Distillation but without the massive computational overhead of training thousands of source RL agents.

Limitations and Future Directions

While powerful, $AD^\varepsilon$ has limitations. The authors note a "subgoal bottleneck": if the demonstrator policy is too poor and never manages to complete a necessary subgoal (like picking up the key in Key-to-Door), the noise distillation fails. The model cannot invent a solution to a problem it has never seen solved. Additionally, like all Transformer-based methods, the agent is constrained by its context window length.

Future work will explore more complex noise types beyond simple $\varepsilon$-greedy strategies (such as Gaussian noise for continuous control) and test the method on larger-scale environments to further push the boundaries of synthetic data generation for In-Context RL.

Summary updated

BibTeX
@inproceedings{zisman2024emergence,
  author = {Ilya Zisman and Vladislav Kurenkov and Alexander Nikulin and Viacheslav Sinii and Sergey Kolesnikov},
  title = {{Emergence of In-Context Reinforcement Learning from Noise Distillation}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=Y8KsHT1kTV},
}
Figure