Policy-conditioned Environment Models are More Generalizable

Ruifeng Chen, Xiong-Hui Chen, Yihao Sun, Siyuan Xiao, Minhui Li, Yang YuICML 2024

Introduction

Environment models in offline reinforcement learning (RL) often fail when evaluating new policies due to the "distribution shift" between training data and the target policy. To address this, researchers introduce Policy-Conditioned Models (PCM). By treating environment modeling as a meta-learning task and using policy representations to adapt the dynamics model on-the-fly, PCM achieves significantly better generalization and more accurate policy evaluation.

The Challenge of Distribution Shift in Off-Policy Evaluation

In model-based RL, learning a "world model"—a mathematical simulator predicting the next state and reward given a current state and action—is highly valuable for Off-Policy Evaluation (OPE). OPE allows us to estimate the quality of a new policy without deploying it in the real world.

However, the "Achilles' heel" of this approach is distribution shift. A model trained on data from specific "behavior policies" (e.g., a robot walking slowly) often yields highly inaccurate predictions when simulating an unseen "target policy" (e.g., the robot running). Standard models, termed Policy-Agnostic Models (PAM), attempt to fit all training data into a single global transition function. Given limited model capacity, this global fit averages out the nuances of distinct behaviors, resulting in a large "value gap" between predicted and actual policy performance.

Comparison between Policy-Agnostic and Policy-Conditioned Models

Proposed Method: Policy-Conditioned Models (PCM)

To overcome the limitations of PAM, the authors propose PCM learning. Instead of learning a single transition function $T(s'|s, a)$, PCM learns a model conditioned on the policy itself: $T(s'|s, a, z)$, where $z$ represents the policy being evaluated.

Key Components

  1. Policy Encoder: A 3-layer Gated Recurrent Unit (GRU) processes a short history of trajectories (states and actions) to encode them into a latent vector $z$. This vector captures the behavioral "style" or "context" of the policy.
  2. Adaptive Dynamics Model: A 4-layer MLP takes the current state, action, and the policy embedding $z$ to predict the next state. This allows the model to specialize its physics predictions based on the specific behavior it is simulating.
  3. Policy Decoder (Regularizer): To ensure the embedding $z$ retains useful behavioral information, a secondary task reconstructs the policy's actions from the embedding.
  4. Meta-Learning Perspective: By conditioning on $z$, the PCM effectively acts as a meta-dynamics model. It learns how the world's dynamics appear to shift under different behavioral contexts rather than forcing a single, rigid worldview.

Key Insights: Diversity and Adaptation

A core intuition behind PCM is a "divide and conquer" approach. For instance, the physics of a bipedal robot "jumping" differ significantly from "running." While a standard model blurs these into an average transition, PCM divides the state-action space by policy, simplifying the learning task for each local region.

Value gap comparison across varying dataset diversity levels

Surprisingly, PCM performs better when the offline dataset is more diverse. While diversity typically complicates global modeling, it provides PCM with more "meta-contexts" to learn from, enhancing its adaptability to unseen target policies. Theoretically, the authors prove that the value gap can be decomposed into training error and generalization error. PCM introduces an "adaptation gain" term that actively reduces generalization error by aligning the model more closely with the target policy's distribution.

Experimental Results

The researchers evaluated PCM across standard continuous control environments (MuJoCo) and the DOPE Benchmark (including tasks from D4RL and RL Unplugged), utilizing custom datasets with varying levels of diversity.

  • State-of-the-Art in OPE: PCM outperformed existing methods (like FQE, DICE, and Doubly Robust) on the DOPE benchmark by a large margin. In terms of absolute error, PCM was often 2-3x more accurate than standard models.
  • Better Policy Selection: In Offline Policy Selection (OPS)—picking the best policy from a set of candidates—PCM achieved an average performance gain of 71.7%, compared to just 11.5% for the standard policy-agnostic model.
  • Robust Control: When applied to Model Predictive Control (MPC), PCM-based planners achieved cumulative rewards nearly identical to the "true" environment dynamics, whereas standard models frequently failed to complete the tasks.

Limitations and Future Work

While highly effective, PCM has limitations. The theoretical proofs rely on an "infinite sample" assumption for each behavior policy; in reality, sparse data for specific behaviors can introduce estimation noise. Additionally, the RNN-based encoder adds computational overhead compared to simpler MLPs.

Furthermore, in certain long-term policy optimization scenarios, an inaccurate but optimistic model might encourage better exploration than a perfectly accurate one—a nuance PCM does not currently address. Future work will focus on discovering more efficient policy representation schemes to further enhance generalization to radically different, out-of-distribution behaviors.

Summary updated

BibTeX
@inproceedings{chen2024policy,
  author = {Ruifeng Chen and Xiong-Hui Chen and Yihao Sun and Siyuan Xiao and Minhui Li and Yang Yu},
  title = {{Policy-conditioned Environment Models are More Generalizable}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=g9mYBdooPA},
}
Figure