Contrastive Value Learning: Implicit Models for Simple Offline RL

Bogdan Mazoure, Benjamin Eysenbach, Ofir Nachum, Jonathan Tompson

Abstract

Model-based reinforcement learning (RL) methods are appealing in the offline setting because they allow an agent to reason about the consequences of actions without interacting with the environment. While conventional model-based methods learn a 1-step model, predicting the immediate next state, these methods must be plugged into larger planning or RL systems to yield a policy. Can we model the environment dynamics in a different way, such that the learned model directly indicates the value of each action? In this paper, we propose Contrastive Value Learning (CVL), which learns an implicit, multi-step dynamics model. This model can be learned without access to reward functions, but nonetheless can be used to directly estimate the value of each action, without requiring any TD learning. Because this model represents the multi-step transitions implicitly, it avoids having to predict high-dimensional observations and thus scales to high-dimensional tasks. Our experiments demonstrate that CVL outperforms prior offline RL methods on complex robotics benchmarks.

The Challenge of Offline Reinforcement Learning

Offline RL is notoriously difficult because agents must learn from a fixed dataset without environment interaction. This leads to two main challenges:

  1. Distribution Shift: Standard model-free methods (like Q-learning) use temporal difference (TD) learning, which "bootstraps" estimates. In offline settings, this often leads to massive overestimation of actions not present in the dataset.
  2. Model Complexity: Traditional model-based methods try to predict the next state (e.g., the next frame in a video). Predicting high-dimensional observations like images is computationally expensive and prone to compounding errors when unrolled over long horizons.

The authors ask: Can we model environment dynamics such that the model directly indicates the value of an action, without predicting pixels or using TD learning?

Methodology: Contrastive Value Learning

CVL shifts the paradigm from "backing up" rewards (Q-learning) to "propagating forward" predictions.

A comparison of Q-learning (backing up rewards) vs. CVL (propagating forward likelihoods).

Instead of a generative model that "draws" the next state, CVL learns a density ratio—an implicit function that tells you how likely you are to visit a future state $s'$ given a current state-action pair $(s, a)$. This occupancy model is trained via contrastive learning (InfoNCE), distinguishing between "positive" future states reached in the data and "negative" states sampled randomly. This avoids the need to reconstruct high-dimensional images.

To find the Q-value, the agent takes a reward-weighted average of these future state likelihoods. To make this computationally efficient, the authors use Random Fourier Features (RFF) to linearize the model. This allows them to maintain a "memory bank" of future features, turning a complex integral into a simple dot product.

Experimental Evaluation

The authors evaluated CVL on several demanding benchmarks, including MetaWorld (50 robotic manipulation tasks), D4RL (Walker2d, Ant, Hopper), and image-based versions of these tasks.

Robotic manipulation environments from the MetaWorld and D4RL benchmarks used for evaluation.

CVL demonstrated significant performance gains over state-of-the-art baselines like Conservative Q-Learning (CQL). On the 50-task MetaWorld benchmark, CVL achieved higher Median, Interquartile Mean (IQM), and Mean scores. In D4RL, CVL was particularly effective when learning from "random" datasets. Crucially, in image-based experiments, CVL maintained high performance while baselines saw significant drops, confirming that the implicit model is better suited for high-dimensional inputs.

Discussion and Key Insights

A major advantage of CVL is the decoupling of dynamics from rewards. Because the occupancy model is learned via contrastive learning, it can be trained on unlabeled data, making it a powerful tool for multi-task pre-training. Furthermore, by avoiding TD learning, CVL bypasses the primary source of instability and overestimation in offline RL, turning Q-value estimation into a supervised learning problem.

While CVL currently corresponds to a single step of policy improvement, which may not reach the absolute theoretical optimum in all environments, it provides a stable and scalable alternative to traditional methods. Future work may explore extending CVL with temporal difference updates for the contrastive model itself to allow for iterative improvement.

Summary updated

BibTeX
@inproceedings{mazoure2023contrastive,
  author = {Bogdan Mazoure and Benjamin Eysenbach and Ofir Nachum and Jonathan Tompson},
  title = {{Contrastive Value Learning: Implicit Models for Simple Offline RL}},
  booktitle = {Conference on Robot Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=GkdDshOdLz},
}
Figure