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

Abstract

Offline meta-reinforcement learning (OMRL) utilizes pre-collected offline datasets to enhance the agent's generalization ability on unseen tasks. However, the context shift problem arises due to the distribution discrepancy between the contexts used for training (from the behavior policy) and testing (from the exploration policy). The context shift problem leads to incorrect task inference and further deteriorates the generalization ability of the meta-policy. In this paper, we propose a novel approach called Context Shift Reduction for OMRL (CSRO) to address the context shift problem with only offline datasets. The key insight of CSRO is to minimize the influence of policy in context during both the meta-training and meta-test phases. During meta-training, we design a max-min mutual information representation learning mechanism to diminish the impact of the behavior policy on task representation. In the meta-test phase, we introduce the non-prior context collection strategy to reduce the effect of the exploration policy. Experimental results demonstrate that CSRO significantly reduces the context shift and improves the generalization ability, surpassing previous methods across various challenging domains.

Introduction

Offline Meta-Reinforcement Learning (OMRL) aims to train agents on pre-collected datasets to enable rapid adaptation to new tasks without expensive real-world interaction. A core component of this process is context-based inference, where the agent observes a small set of transitions (the "context") to identify the current task.

However, OMRL faces a significant challenge known as Context Shift. During training, the context is sampled from a fixed "behavior policy" used to collect the dataset. At test time, the context is generated by the agent's own "exploration policy." If the task representation accidentally encodes the "style" of the behavior policy rather than the underlying task dynamics or rewards, the agent will fail to generalize when the exploration style changes. This discrepancy leads to incorrect task inference and poor performance.

Methodology: The CSRO Framework

To address this, we propose Context Shift Reduction for OMRL (CSRO). The framework operates in two distinct phases to strip policy-specific noise from task representations.

The CSRO framework: Meta-training uses max-min mutual information to learn policy-agnostic representations, while meta-testing employs a non-prior exploration strategy.

1. Meta-Training: Max-Min Mutual Information

The goal is to learn a task representation $z$ that is "policy-agnostic." CSRO employs a dual objective:

  • Maximize Mutual Information (MI): Ensure $z$ captures essential task-specific information (e.g., goal location or reward structure).
  • Minimize Mutual Information (MI): Ensure $z$ does not "leak" information about the behavior policy. By minimizing the MI between the representation and the behavior policy using the Contrastive Log-ratio Upper Bound (CLUB) estimator, the encoder is forced to ignore the "how" (actions) and focus on the "what" (outcomes).

2. Meta-Testing: Non-prior Context Collection

Standard meta-RL agents often start with a "prior" belief. If this prior is biased by the offline training distribution, the agent's initial steps may be skewed, reinforcing an incorrect task belief. CSRO introduces a non-prior strategy: the agent initially explores the environment randomly to gather an unbiased "first look" at the task before refining its belief and policy.

Experiments and Results

We evaluated CSRO on several continuous control benchmarks, including Point-Robot (2D navigation) and the MuJoCo Physics Suite (Half-Cheetah, Ant, Humanoid, Walker). These tasks involve variations in reward functions (e.g., target velocity) or physical dynamics (e.g., mass and friction).

Visualization of the Point-Robot task showing the discrepancy between offline training datasets and the contexts/trajectories encountered during meta-testing.

Key Findings

  • Performance: CSRO consistently outperformed state-of-the-art baselines like FOCAL and OffPearl. In the Point-Robot environment, CSRO achieved an average return of -6.4, significantly better than FOCAL (-11.8) and OffPearl (-17.0).
  • Robustness: In dynamics-based tasks like Walker-Rand-Params, CSRO reached a return of 344.2, surpassing the next best baseline, CORRO (312.5).
  • Representation Quality: Visualization of the learned task representations confirmed that CSRO produces tighter, more distinct clusters for different tasks, indicating a cleaner and more discriminative representation.

Discussion and Limitations

While CSRO effectively reduces context shift, it faces challenges in sparse reward environments. In such cases, random exploration is unlikely to encounter a reward signal, making the non-prior strategy less effective. Additionally, while random exploration reduces bias, it is not the most efficient way to gather information. Future work may focus on learning informative yet unbiased exploration policies and reducing the computational overhead associated with mutual information bounds like CLUB.

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