[Paper Review] In-context Reinforcement Learning with Algorithm Distillation
This paper introduces Algorithm Distillation (AD), a method that trains a causal transformer to predict actions from extended, across-episode learning histories of reinforcement learning (RL) agents, enabling in-context policy improvement without parameter updates. AD learns more data-efficient RL algorithms than the source RL algorithms by modeling policy improvement as a sequential prediction problem over full training trajectories.
We propose Algorithm Distillation (AD), a method for distilling reinforcement learning (RL) algorithms into neural networks by modeling their training histories with a causal sequence model. Algorithm Distillation treats learning to reinforcement learn as an across-episode sequential prediction problem. A dataset of learning histories is generated by a source RL algorithm, and then a causal transformer is trained by autoregressively predicting actions given their preceding learning histories as context. Unlike sequential policy prediction architectures that distill post-learning or expert sequences, AD is able to improve its policy entirely in-context without updating its network parameters. We demonstrate that AD can reinforcement learn in-context in a variety of environments with sparse rewards, combinatorial task structure, and pixel-based observations, and find that AD learns a more data-efficient RL algorithm than the one that generated the source data.
Motivation & Objective
- To enable in-context reinforcement learning where models improve through trial and error without fine-tuning.
- To model the process of RL algorithm training as a sequential prediction problem using long-horizon context.
- To distill not just fixed policies, but the entire policy improvement operator from RL training histories.
- To demonstrate that in-context RL can be achieved via imitation learning on offline RL learning histories.
- To show that the distilled algorithm can generalize and learn more efficiently than the source RL algorithm.
Proposed method
- Collect a large multi-task dataset of full learning histories from a source RL algorithm across many individual tasks.
- Represent each learning history as a sequence of state-action-reward tokens, preserving temporal and episodic structure.
- Train a causal transformer to autoregressively predict actions using the entire preceding learning history as context.
- Use a sequence modeling loss that conditions only on past states, actions, and rewards, not returns.
- Ensure context length is sufficiently large to capture policy improvement across multiple episodes.
- Apply the trained transformer in-context at inference: prompt with prior episode history and predict actions without updating weights.
Experimental results
Research questions
- RQ1Can a sequence model learn to improve policies in-context by attending to full learning histories?
- RQ2Does modeling RL training as a sequential prediction problem enable in-context exploration and temporal credit assignment?
- RQ3Can the distilled model generalize to new tasks and outperform the source RL algorithm in data efficiency?
- RQ4Is it possible to distill the policy improvement operator of an RL algorithm into a single neural network via imitation learning?
- RQ5How does the performance of the distilled algorithm compare to the source algorithm in terms of sample efficiency?
Key findings
- AD achieves in-context reinforcement learning without any parameter updates, relying solely on context from prior episodes.
- AD demonstrates in-context exploration and temporal credit assignment in partially observable environments like DMLab's Watermaze.
- AD learns a more data-efficient RL algorithm than the one used to generate the training data.
- The method generalizes across tasks with sparse rewards, combinatorial structure, and pixel-based observations.
- AD outperforms prior offline policy distillation methods that require fine-tuning or expert demonstrations for adaptation.
- The success of AD depends critically on sufficiently long context windows that span multiple episodes to capture policy improvement.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.