NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Contextual Latent World Models for Offline Meta Reinforcement Learning

Mohammadreza Nakheai, Aidan Scannell, Kevin Sebastian Luck, Joni Pajarinen · DOI

Abstract

Offline meta-reinforcement learning seeks to learn policies that generalize across related tasks from fixed datasets. Context-based methods infer a task representation from transition histories, but learning effective task representations without supervision remains a challenge. In parallel, latent world models have demonstrated strong self-supervised representation learning through temporal consistency. We introduce contextual latent world models, which condition latent world models on inferred task representations and train them jointly with the context encoder. This enforces task-conditioned temporal consistency, yielding task representations that capture task-dependent dynamics rather than merely discriminating between tasks. Our method learns more expressive task representations and significantly improves generalization to unseen tasks across MuJoCo, Contextual-DeepMind Control, and Meta-World benchmarks.

Introduction

Reinforcement Learning (RL) agents often struggle with generalization; a policy optimized for one environment may fail when physical parameters or goals shift slightly. Meta-RL addresses this by training agents to adapt to new tasks using limited experience. However, standard Meta-RL requires extensive online interaction, which is often impractical or unsafe in real-world settings.

Offline Meta-RL (OMRL) offers a solution by learning from fixed, pre-collected datasets. The prevailing approach involves a context encoder that processes transition histories to produce a latent task representation $z$. The policy then conditions its actions on $z$. A critical bottleneck in OMRL is the quality of these representations. Existing methods often rely on contrastive learning or one-step reconstruction, which may fail to capture the long-term dynamics and reward structures essential for robust generalization to unseen tasks.

Methods: Self-Predictive Contextual OMRL (SPC)

To overcome these limitations, we propose Self-Predictive Contextual OMRL (SPC). SPC integrates context-based meta-learning with latent world models to enforce task-conditioned temporal consistency.

1. Contextual Latent World Model

Unlike traditional methods that treat task inference and world modeling as separate stages, SPC employs a world model (comprising an encoder, dynamics model, and reward model) that is explicitly conditioned on the task representation $z$. This architecture ensures that the latent space reflects task-specific physics and transition rules.

The SPC architecture: A context encoder $E_\theta$ extracts task representation $z$, which conditions a latent world model trained via temporal consistency.

2. Joint Training and Temporal Consistency

The core innovation of SPC is the joint training of the context encoder and the world model. By optimizing a multi-step temporal consistency loss, the context encoder is forced to generate representations that enable the world model to accurately predict future latent states over extended horizons. This "self-predictive" signal ensures that $z$ captures the underlying dynamics of the task rather than just surface-level discriminative features.

3. Discrete Latent Space via FSQ

SPC utilizes Finite Scalar Quantization (FSQ) to map continuous observations into a discrete latent space. This allows the dynamics model to utilize cross-entropy classification losses instead of standard Mean Squared Error (MSE) regression. Discretization helps the model better handle the multimodal nature of RL environments, where multiple future outcomes may be plausible given a single action.

4. Policy Optimization

Following the representation learning phase, the agent is trained using Implicit Q-Learning (IQL). IQL is particularly effective for offline data as it avoids the overestimation of out-of-distribution actions, allowing the policy to stay within the support of the training dataset while maximizing expected returns.

Experimental Results

We evaluated SPC against state-of-the-art baselines, including FOCAL, CSRO, and DORA, across three major benchmarks: MuJoCo, Contextual-DeepMind Control (DMC), and Meta-World.

Performance and Generalization

SPC consistently outperformed all baselines in both zero-shot and few-shot adaptation scenarios. In the Meta-World ML1 benchmark, SPC achieved a 90% success rate on challenging tasks like "Button-press-topdown-wall," where competing methods struggled to exceed 35%.

Aggregate performance across benchmarks. SPC (maroon) achieves the highest Interquartile Mean (IQM) and the lowest Optimality Gap compared to baselines.

Representation Quality

Analysis using Disentanglement, Completeness, and Informativeness (DCI) metrics revealed that SPC's latent representations align more closely with actual physical factors of variation (e.g., gravity, limb length) than those of other methods. This confirms that the temporal consistency loss successfully encourages the context encoder to capture the "physics" of the environment.

Discussion and Conclusion

SPC demonstrates that dynamics-aware task representations are superior to purely discriminative ones for offline meta-RL. By forcing the context encoder to support long-term state prediction, SPC learns representations that are both expressive and robust.

While SPC shows remarkable generalization within task families, future work is needed to address the "environment gap"—generalizing across entirely different robotic morphologies. Additionally, extending this framework to high-dimensional pixel-based inputs remains a promising direction for scaling contextual world models to more complex real-world applications.

Summary updated

BibTeX
@misc{nakheai2026contextual,
  author = {Mohammadreza Nakheai and Aidan Scannell and Kevin Sebastian Luck and Joni Pajarinen},
  title = {{Contextual Latent World Models for Offline Meta Reinforcement Learning}},
  year = {2026},
  eprint = {2603.02935},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.02935},
}
Figure