Abstract
Reinforcement Learning (RL) agents typically suffer from extreme sample inefficiency, often learning from scratch through trial and error. While self-supervised pre-training has revolutionized Natural Language Processing and Computer Vision, its application in RL has been hindered by algorithmic complexity and a focus on short-term transitions. We introduce RePreM (Representation Pre-training with Masked Model), a framework that brings masked sequence modeling to RL. By pre-training a state encoder to predict masked states and actions within a trajectory using a Transformer, RePreM creates robust representations that capture long-term environmental dynamics. Our results demonstrate that RePreM significantly improves sample efficiency, achieving state-of-the-art performance on the Atari-100k benchmark and substantial gains in continuous control tasks.
Introduction
In traditional Reinforcement Learning, agents are often initialized "tabula rasa," requiring millions of interactions to understand basic environmental features and dynamics. This lack of prior knowledge leads to significant sample inefficiency. While unsupervised pre-training has provided a "BERT moment" for other domains, RL has struggled to find a similar universal pre-training primitive. Existing methods often rely on complex world models or hand-crafted data augmentations that focus on one-step transitions, failing to capture the long-horizon dependencies necessary for complex decision-making.
RePreM addresses these challenges by treating RL trajectories as sequences, similar to sentences in a language model. By masking and predicting elements within these sequences, the model learns a deep understanding of the underlying temporal and spatial structures of the environment.
Methodology
Masked Trajectory Modeling
RePreM operates on trajectories defined as sequences of states and actions: $(s_1, a_1, s_2, a_2, \dots)$. During pre-training, a portion of these states or actions is randomly masked. The model's objective is to reconstruct the representations of these masked elements based on the surrounding context.
Architecture
The framework utilizes a ResNet state encoder and an MLP action encoder to generate initial embeddings. These embeddings are processed by GTrXL (Gated Transformer-XL) blocks. GTrXL is specifically chosen for its stability in RL contexts, allowing the model to integrate information across long sequences (typically 50 steps) without the training instabilities often associated with standard Transformers.
Self-Supervised Objective
To avoid the computational expense and noise associated with raw pixel reconstruction, RePreM employs a SimCLR-style contrastive loss. The model learns to align the predicted embedding of a masked element with the actual embedding produced by the encoder, while simultaneously pushing it away from other embeddings in the sequence. This ensures the learned representations are both discriminative and predictive of environmental dynamics.
Downstream Integration
A key finding of the RePreM framework is the utility of fixed features. Once pre-trained, the state encoder is frozen. For specific downstream tasks, simple MLP layers for policy and value networks are appended to this fixed encoder. This prevents the "forgetting" or erasure of general knowledge that often occurs during the non-stationary updates of RL fine-tuning.
Experimental Setup
RePreM was evaluated across several rigorous benchmarks to test its efficiency and scalability:
- Atari-100k: A benchmark limiting agents to 100,000 interaction steps, testing extreme sample efficiency.
- DeepMind Control Suite (DMControl-100k): A testbed for continuous control tasks like Walker and Quadruped.
- Offline Datasets: The model was trained on diverse offline data, including random actions, early-stage agent data (Weak), and comprehensive history (Mixed), to evaluate its ability to learn from varied data quality.
Key Results and Insights
State-of-the-Art Performance
On the Atari-100k benchmark, RePreM (Large) achieved a Median Human Normalized Score (HNS) of 1.085. This significantly outperforms previous leading methods such as SPR (0.415) and SGI (0.753). Notably, the agent achieved superhuman performance on 15 out of 26 games within the strict 100k step limit.
Continuous Control and Dynamics
In the DeepMind Control Suite, RePreM provided a massive boost to the Soft Actor-Critic (SAC) algorithm. In the Walker-Walk task, performance improved from a score of 42 (learning from scratch) to 633 when using the RePreM pre-trained encoder. Furthermore, RePreM demonstrated superior accuracy in long-horizon state prediction, maintaining low error rates for up to 100 steps, confirming its ability to capture multi-step dynamics.
Scaling and Generalization
RePreM exhibits clear "scaling law" behavior; performance improves consistently as dataset size, data quality, and encoder capacity increase. Additionally, the model shows strong generalization capabilities, where an encoder pre-trained on a diverse set of games can be successfully transferred to an entirely unseen game, drastically accelerating the learning process.
Conclusion and Future Work
RePreM demonstrates that masked trajectory modeling is a powerful primitive for RL pre-training. By capturing long-term dynamics through a Transformer-based contrastive objective, it provides a robust foundation for downstream tasks.
Future research will focus on better utilizing the pre-trained action encoder, which is currently discarded during downstream tasks. Additionally, while the current method relies on offline datasets, exploring effective ways to implement masked pre-training in a purely online, streaming fashion remains a high-priority area for the development of RL foundation models.
Summary updated