Context Shift Reduction for Offline Meta-Reinforcement Learning

Yunkai Gao, Rui Zhang, Jiaming Guo, Fan Wu, Qi Yi, Shaohui Peng, Siming Lan, Ruizhi Chen, Zidong Du, Xing Hu, Qi Guo, Ling Li, Yunji Chen

TL;DR

Researchers have developed CSRO (Context Shift Reduction for OMRL), a framework that fixes the "context shift" problem in offline meta-reinforcement learning. By using mutual information optimization to strip away the "signature" of the data-collection policy and implementing a smarter exploration strategy at test time, CSRO allows agents to generalize to new tasks far more effectively than previous methods.

What Problem Does This Paper Address?

Offline Meta-Reinforcement Learning (OMRL) is the quest to build agents that can learn from a fixed dataset of past experiences and then quickly adapt to entirely new, unseen tasks. To do this, agents use "context"—a small snippet of transitions—to infer what task they are currently performing.

The "Context Shift" problem occurs because of a fundamental mismatch:

  1. During Training: The context comes from a behavior policy (the specific way the historical data was collected).
  2. During Testing: The context comes from the agent’s own exploration policy.
Illustration of the context shift problem showing differences between training datasets and test contexts.

If the behavior policy always moved in a specific way (e.g., always circling clockwise), the agent’s task-inference module might accidentally learn that "circling clockwise" is part of the task definition itself. When the agent is tested and explores differently, it gets confused, leading to an "identity crisis" where it can't figure out the task, causing performance to plummet.

Methods

The authors propose CSRO, which attacks this shift from two angles:

Overview of the CSRO framework during Meta-Training and Meta-Test phases.

1. Max-Min Mutual Information (Meta-Training)

To ensure the task representation ($z$) only contains information about the task and not the policy that collected the data, they use a dual-objective loss function:

  • Maximize Task Info: Uses distance metric learning to ensure representations of the same task are close together and different tasks are far apart.
  • Minimize Policy Info: Uses CLUB (Contrastive Log-ratio Upper Bound) to minimize the mutual information between the task representation and the state-action pairs. This effectively "bleaches" the behavior policy's unique style out of the representation.

2. Non-prior Context Collection (Meta-Testing)

Standard methods usually start a new task by sampling a "prior" representation. If this prior is biased, the agent's first exploratory steps will be biased too, creating a feedback loop of bad data. CSRO introduces a non-prior strategy: the agent initially explores the environment randomly and independently for a few steps. This provides an unbiased "first look" that allows for more accurate task inference before the meta-policy takes over.

Datasets

The researchers evaluated CSRO on several challenging benchmarks:

  • Point-Robot: A 2D navigation task where the goal moves along a semicircle.
  • MuJoCo Suite: Including Half-Cheetah-Vel and Ant-Goal (reward function changes) and Hopper/Walker-Rand-Params (physics/dynamics changes like mass and friction).
  • Sparse-Point-Robot: A version of the robot task where rewards are only given very close to the goal, used specifically to test the limits of the exploration strategy.

Key Insights and Ideas

  • Representation Invariance: The core "aha" moment is that a good task representation should be invariant to how the data was gathered. If you can't tell which policy collected the data by looking at the representation, the representation is more likely to be purely about the task itself.
  • The Danger of Priors: In offline settings, the "prior" distribution of tasks is often inextricably linked to the behavior policy. By ditching the prior in favor of initial random exploration, the agent avoids "inheriting" the biases of the training data.
  • Adversarial-like Training: The use of CLUB creates a setup where the context encoder is pushed to hide policy information while the variational distribution estimator tries to find it, resulting in a robust, policy-neutral encoding.

Key Results

CSRO consistently outperformed state-of-the-art baselines (like FOCAL, OffPearl, and CORRO) across all tested domains:

  • Performance Gains: In the Point-Robot environment, CSRO achieved an average return of -6.4, significantly better than FOCAL (-11.8) and OffPearl (-17.0).
  • Robustness to Shift: While other methods see their performance drop by 2x or 3x when moving from "clean" offline context to "noisy" online exploration context, CSRO maintains much higher stability.
  • Clustering Quality: t-SNE visualizations show that CSRO creates much tighter, more distinct clusters for different tasks compared to other methods, proving that its representations are cleaner and more discriminative.

Limitations and Future Work

  • Sparse Rewards: The authors acknowledge that CSRO struggles in environments with very sparse rewards. Because the "non-prior" strategy relies on random exploration to get an initial signal, if the reward is too hard to find, the agent learns nothing during those critical first steps.
  • Backbone Dependency: While CSRO is framework-agnostic, this study used BRAC as the backbone. Performance might vary with different offline RL algorithms (like CQL or IQL).
  • Future Direction: Integrating more sophisticated exploration behaviors (beyond simple random exploration) that are still "policy-neutral" could help bridge the gap in sparse-reward scenarios.

Reference: Gao, Y., et al. (2023). Context Shift Reduction for Offline Meta-Reinforcement Learning. 37th Conference on Neural Information Processing Systems (NeurIPS 2023).

Summary updated

BibTeX
@inproceedings{gao2023context,
  author = {Yunkai Gao and Rui Zhang and Jiaming Guo and Fan Wu and Qi Yi and Shaohui Peng and Siming Lan and Ruizhi Chen and Zidong Du and Xing Hu and Qi Guo and Ling Li and Yunji Chen},
  title = {{Context Shift Reduction for Offline Meta-Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=TStMZH3Xqx},
}
Figure