Abstract
Recent breakthroughs in In-Context Reinforcement Learning (ICRL) have demonstrated that Transformers can learn to solve novel tasks by conditioning on a history of past interactions, effectively bypassing the need for gradient updates during meta-test time. A prominent approach, Algorithm Distillation (AD), trains models to imitate the learning trajectories of standard reinforcement learning (RL) algorithms. However, these models often inherit the suboptimality and slow convergence of their source algorithms. This paper introduces Distillation for In-Context Planning (DICP), a framework that shifts the paradigm from model-free imitation to in-context model-based planning. By learning environment dynamics and rewards alongside policy behavior, DICP enables Transformers to use look-ahead planning to outperform the very algorithms they were trained to mimic.
Introduction
In-Context Reinforcement Learning (ICRL) leverages the sequential modeling capabilities of Transformers to perform meta-learning. By treating an RL algorithm's learning history as a sequence, a Transformer can be trained to predict the next action, effectively distilling the algorithm's behavior into its weights. While effective, this "Algorithm Distillation" (AD) approach has a fundamental limitation: the resulting model is constrained by the performance of the source algorithm. Standard RL algorithms, such as PPO or SAC, update their policies gradually to ensure stability, meaning the distilled Transformer often repeats the same exploratory mistakes found in the early stages of the training data, even when the necessary information to solve the task is already present in its context window.
The DICP Framework
To overcome the "gradualness" of distilled policies, the researchers developed Distillation for In-Context Planning (DICP). DICP transforms the Transformer from a passive imitator into an active planner by incorporating three key components:
1. In-Context Dynamics Learning
Instead of focusing solely on action prediction, the DICP model is trained to simultaneously predict the next state, the reward, and the "return-to-go." By modeling the environment's physics and reward structure directly from the sequence of past experiences, the model learns "how the world works" independently of "how the source algorithm behaves." This allows the agent to decouple environment understanding from the suboptimal policy of the teacher.
2. Planning via Model Predictive Control (MPC)
During inference, the model does not simply output the most likely next action. Instead, it utilizes its learned dynamics as a "world model" to simulate various future trajectories. This is implemented via a planning subroutine where the model performs look-ahead search within its latent space to identify the path that maximizes expected rewards.
3. Search Algorithms
The framework is adaptable to different action spaces:
- Discrete Tasks: Uses Beam Search to explore high-reward sequences in grid-world environments.
- Continuous Tasks: Employs a Greedy Search strategy with multiple samples to navigate dense reward landscapes in robotic simulations.
DICP is designed as a modular wrapper and was successfully integrated with three existing architectures: Algorithm Distillation (AD), Decision-Pretrained Transformer (DPT), and In-Context Decision Transformer (IDT).
Experimental Evaluation
The researchers evaluated DICP across two diverse benchmarks to test its versatility and efficiency:
- Darkroom Variants: These 2D discrete grid-world environments (including Darkroom, Dark Key-to-Door, and Darkroom-Permuted) require an agent to locate a goal with limited visibility. These tests highlighted the model's ability to "jump ahead" of the source algorithm's learning curve.
- Meta-World (ML1 & ML10): A suite of continuous control tasks involving complex robotic manipulation, such as opening doors and picking up objects. These benchmarks tested the framework's scalability to high-dimensional state spaces.
Key Results and Insights
Superior Performance and Sample Efficiency
DICP-IDT achieved state-of-the-art (SOTA) success rates on the Meta-World ML1 and ML10 benchmarks. Most notably, the framework demonstrated massive gains in sample efficiency. While traditional meta-RL methods often require between 10 million and 300 million environment interactions to reach peak performance, DICP reached SOTA levels using only 200,000 interactions.
Outperforming the Teacher
A critical finding was that DICP models consistently achieved higher episode rewards faster than their model-free counterparts. By reasoning through simulated futures, the agent can identify optimal actions that the original RL algorithm (the teacher) would only discover after many more steps of trial and error. This confirms that dynamics learning is a more robust foundation for ICRL than simple policy imitation.
Source-Agnostic Improvements
The benefits of DICP were observed regardless of whether the training data was generated by PPO or SAC. This suggests that model-based planning is a general-purpose enhancement for in-context learners, providing a consistent performance boost over model-free baselines.
Limitations and Future Directions
Despite its performance gains, DICP introduces a higher computational cost during deployment. Because the model must simulate multiple potential futures before taking an action, it requires significantly more FLOPs (Floating Point Operations) than model-free approaches.
Additionally, the current implementation relies on a relatively short planning horizon. Future research may explore adaptive planning strategies—where the look-ahead horizon is adjusted based on the model's uncertainty—and the integration of expert demonstrations to further accelerate the learning process.
Conclusion
Distillation for In-Context Planning represents a significant step forward for meta-reinforcement learning. By equipping Transformers with the ability to plan using a learned world model, DICP overcomes the inherent limitations of algorithm distillation, offering a path toward agents that are not only faster to learn but also capable of exceeding the performance of the algorithms that trained them.
Summary updated