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

Temporal Consistency Improves Generalization in Contextual Offline Meta Reinforcement Learning

Mohammadreza Nakheai, Aidan Scannell, Kevin Luck, Joni Pajarinen

TL;DR

This paper demonstrates that jointly training a context encoder with a self-predictive world model using multi-step temporal consistency significantly improves generalization in contextual offline meta-reinforcement learning. By predicting future states and rewards directly within a latent space rather than reconstructing raw observations, the proposed method learns highly effective, disentangled task representations. This approach yields substantial performance gains in both zero-shot and few-shot adaptation across challenging continuous control benchmarks.

What Problem Does This Paper Address?

Offline Meta-Reinforcement Learning (OMRL) aims to leverage static, pre-collected datasets from various related tasks to train a policy that can quickly adapt to new, unseen tasks at test time. A dominant paradigm in OMRL is context encoding, where an encoder maps a brief history of recent transitions (the context) into a latent task representation $z$ to guide the policy.

However, learning an effective task representation without explicit supervision or task labels is incredibly difficult. Existing methods fall into two flawed camps:

  1. Contrastive learning methods excel at distinguishing between different tasks but often fail to capture the underlying task-specific transition dynamics.
  2. Reconstruction-based methods try to reconstruct raw observations or predict one-step transitions, which is often insufficient for capturing long-horizon, task-dependent dependencies and can lead to representation collapse or waste capacity on task-irrelevant details.

The authors address this gap by investigating how multi-step temporal consistency within a latent space can be used to learn high-quality, dynamics-aware task representations.

Methods

The authors introduce a Contextual World Model framework that unifies context-based OMRL with self-predictive representation learning. Instead of using pixel or state reconstruction, the architecture operates entirely within an abstract latent space:

  • Context Encoder ($E_\theta$): Maps a history of transitions to a task representation vector $z$.
  • Observation Encoder ($F_\phi$): Maps raw environment states $s_t$ to latent states $x_t$.
  • Latent Dynamics Model ($D_\phi$): Predicts the next latent state $\hat{x}_{t+1}$ given the current latent state $x_t$, action $a_t$, and the task representation $z$.
  • Reward Model ($R_\phi$): Predicts the expected reward $\hat{r}_t$ from the same latent components.

The core innovation is the Multi-Step Temporal Consistency (TC) Objective. The context encoder and world model are trained jointly over a prediction horizon $H$. The model minimizes the distance between its multi-step latent predictions and target latent states generated by an exponential moving average (EMA) target encoder. To maximize task discriminability, this TC loss is augmented with an InfoNCE contrastive loss.

For downstream control, a policy and value function are trained directly on these learned latent states $(x_t, z)$ using Implicit Q-Learning (IQL), which mitigates distribution shift issues inherent to offline datasets.

Contextual World Model Architecture

Datasets

The framework was evaluated across three diverse multi-task reinforcement learning benchmarks:

  • MuJoCo: Standard locomotion tasks including Ant-dir, Cheetah-speed, and Walker-speed.
  • Contextual DeepMind Control (DMC): Tasks introducing morphological and environmental variations, such as Finger-speed, Hopper-mass, Walker-friction, and joint Length-Speed (LS) variants (Cheetah-LS, Finger-LS, Walker-LS).
  • Meta-World: Robotic manipulation suites including the ML1, ML10, and ML45 protocols, which test generalization to entirely unseen environments and goals.

The evaluation included both in-distribution test tasks and out-of-distribution (OOD) test tasks (where task parameters like target speeds or lengths were extrapolated beyond the training ranges).

Key Insights and Ideas

  • The Power of Latent Multi-Step Prediction: Enforcing temporal consistency over multiple steps forces the context encoder to capture long-horizon, task-dependent dynamics. Because it predicts forward in latent space rather than pixel space, the network ignores high-frequency, task-irrelevant noise.
  • Disentanglement Without Labels: A striking finding is that temporal consistency naturally encourages disentangled representations. The latent dimensions align cleanly with true physical variation factors (like robot torso length or target speed) much better than pure reconstruction or contrastive baselines.
  • Complementary Objectives: Temporal consistency and contrastive learning are highly synergistic. TC ensures the representation captures underlying physics and transition dynamics, while contrastive learning ensures that distinct tasks remain well-separated in the latent space.
Figure 2: Disentanglement metrics (DCI, InfoMEC) for the Cheetah-length-speed (LS) environment. Temporal consistency disentangles the variation factors more effectively, while contrastive learning enhances task distinguishability. TC denotes training the context encoder solely with the temporal consistency objective, and AR denotes auto-regression. Averaged over 6 random seeds.
  • Task Error Dominates: Through an elegant error decomposition study, the authors isolated three sources of value error: abstraction error, world model error, and task inference error. They discovered that task inference error (the difficulty of identifying the task from context) is the dominant performance bottleneck, validating their focus on improving the context encoder.

Key Results

  • Superior Generalization: The combined approach (TC + InfoNCE) consistently outperformed strong baselines like FOCAL, CSRO, and UNICORN.
  • Meta-World Success: On the challenging ML10 benchmark, the proposed method achieved a 15.0% success rate on unseen test environments, compared to just 3.3% for CSRO and 5.0% for FOCAL. On ML45-OOD, it achieved a 24.0% success rate, outperforming all baselines.
  • Locomotion Performance: In zero-shot OOD generalization on Cheetah-speed, the method achieved an average return of 756.0, significantly higher than FOCAL (607.8) and CSRO (603.5).
  • Healthy Representations: Metric analysis showed that the context encoder maintained a high matrix rank and a very low ratio of dormant neurons, proving that the self-predictive loss effectively prevents representation collapse.

Limitations and Future Work

  • State-Only Evaluation: The current implementation was evaluated only on environments providing low-dimensional state vectors. While the theory supports it, modifying the observation encoder to handle high-dimensional visual inputs (pixels) remains an item for future engineering and validation.
  • Shared Action/State Spaces: The framework assumes that all tasks share identical state and action dimensions. Extending the architecture to handle varying action spaces or distinct robotic morphologies across tasks is an open research direction.
  • The Hard Generalization Gap: Although the method beats prior state-of-the-art techniques, generalizing to entirely unique environments (as seen in Meta-World test sets) remains incredibly difficult for all offline meta-RL algorithms, indicating that increasing training data diversity is still vital.

Summary updated

BibTeX
@misc{nakheai2026temporal,
  author = {Mohammadreza Nakheai and Aidan Scannell and Kevin Luck and Joni Pajarinen},
  title = {{Temporal Consistency Improves Generalization in Contextual Offline Meta Reinforcement Learning}},
  year = {2026},
  eprint = {2603.02935},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.02935},
}
Figure