Reining Generalization in Offline Reinforcement Learning via Representation Distinction

Yi Ma, Hongyao Tang, Dong Li, Zhaopeng Meng

The NeurIPS 2023 paper, "Reining Generalization in Offline Reinforcement Learning via Representation Distinction," offers a fresh perspective on one of the most persistent headaches in offline Reinforcement Learning (RL): overgeneralization.

TL;DR

The authors introduce Representation Distinction (RD), a simple yet powerful plug-in for offline RL algorithms that prevents the model from "hallucinating" high values for unknown actions. By forcing the neural network to learn distinct, orthogonal representations for data inside the training set versus out-of-distribution (OOD) actions, RD effectively blocks the leakage of optimism that usually leads to policy collapse.

The Challenge: Distribution Shift and Overgeneralization

In Offline RL, an agent learns from a static, pre-collected dataset without the luxury of interacting with the environment. The central challenge is distribution shift: as the agent tries to improve its policy, it inevitably considers actions that aren't in the dataset.

Standard neural networks are highly prone to overgeneralization. When they encounter an OOD state-action pair, they often assign it a value similar to nearby samples in the dataset. If those nearby samples have high rewards, the agent becomes "catastrophically optimistic" about OOD actions, chooses them during deployment, and fails.

While existing methods try to fix this by adding "pessimism" (manually lowering Q-values for OOD data), this paper argues that the root of the problem lies in the learned representations. If the internal features of a "good" known action and a "bad" unknown action look identical to the network, no amount of value-tuning will fully solve the problem.

Methods: Representation Distinction (RD)

The authors propose a framework called the Backup-Generalization Cycle to describe how value updates (backups) on known data spread to unknown data via the network's generalization.

The Backup-Generalization Cycle illustrates how value updates on known data spread to unknown data.

To control this cycle, they introduce Representation Distinction (RD).

The Core Technique: Orthogonality

RD acts as a regularizer on the penultimate layer of the Q-network (the representation $\Phi$). It minimizes the dot product between the representations of in-sample data and OOD data:

$$\mathcal{L}_{RD} \approx |\Phi(s, a_{in})^\top \Phi(s, a_{out})|$$

By pushing these representations toward orthogonality, the network is forced to treat them as fundamentally different entities, inhibiting the "leakage" of high value estimates.

Two-Stage Dynamic Adjustment

The authors realize that "too much" distinction can be detrimental. If the agent's policy eventually learns to mimic the best parts of the dataset, forcing those representations apart is counterproductive. To address this, they propose a two-stage approach:

  1. Policy-Dataset Inhibition: Early in training, the method distinguishes the dataset from the current policy.
  2. Policy-OOD Inhibition: Later in training, a synthetic OOD data generator creates "fake" actions guaranteed to have lower values. RD then distinguishes the current policy from these low-value OOD actions.

A tanh-based scheduler smoothly transitions between these two stages as training progresses.

Key Insights

  • Generalization is a Double-Edged Sword: In online RL, generalization accelerates learning. In offline RL, it is the primary source of overestimation error.
  • Representation as a Gatekeeper: A significant portion of the success of "pessimistic" algorithms (like CQL) actually stems from how they implicitly shape representations. RD makes this implicit benefit explicit and controllable.
  • The "Bumpy Landscape" Risk: Distinguishing similar samples too aggressively creates a "bumpy" Q-value landscape lacking robustness. The OOD data generator cleverly maintains a smooth value function while preventing overgeneralization.

Key Results

RD was evaluated on the standard D4RL benchmark (including Gym MuJoCo-v2 and Adroit-v1) as a plug-in for both "backbone" algorithms (simplified SAC and TD3) and established SOTA methods like CQL and TD3+BC.

Learning curves demonstrating the performance boost of SAC with RD compared to standard SAC on HalfCheetah tasks.
  • Performance Boost: Adding RD to TD3+BC and CQL resulted in significant performance gains across almost all D4RL tasks.
  • State-of-the-Art: Backbone algorithms equipped with RD (SAC-N-Unc + RD and TD3-N-Unc + RD) outperformed top-tier algorithms like IQL, EDAC, and Diffusion-QL on the MuJoCo and Adroit suites.
  • Latent Space Visualization: T-SNE plots showed that RD creates much cleaner clusters of "Expert" versus "Medium" data compared to standard methods, proving the efficacy of the representation distinction.

Limitations and Future Work

  • Action Spaces: The current work focuses entirely on continuous control tasks. Its efficacy in discrete action spaces remains to be explored.
  • Heuristic Scheduling: The transition between the two stages of RD relies on a tanh scheduler. An adaptive adjustment mechanism based on the current policy's overlap with the dataset could be a valuable future direction.
  • Computational Overhead: As a plug-in, RD requires calculating representations for extra OOD samples, adding a slight computational cost during training.

Summary updated

BibTeX
@inproceedings{ma2023reining,
  author = {Yi Ma and Hongyao Tang and Dong Li and Zhaopeng Meng},
  title = {{Reining Generalization in Offline Reinforcement Learning via Representation Distinction}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=mVywRIDNIl},
}
Figure