Goal-Conditioned Reinforcement Learning from Sub-Optimal Data on Metric Spaces

Alfredo Reichlin, Miguel Vasco, Hang Yin, Danica Kragic

TL;DR

MetricRL is a novel goal-conditioned offline reinforcement learning method that recovers near-optimal behavior even from severely sub-optimal datasets (such as random walks). By replacing the standard Bellman operator with a metric learning objective based on a new property called "distance monotonicity," it completely avoids the catastrophic value overestimation typical of offline RL without needing restrictive policy constraints.

What Problem Does This Paper Address?

Offline reinforcement learning (RL) allows agents to learn effective policies from pre-collected, static datasets without risking dangerous or expensive real-world interactions. However, a major bottleneck occurs when the available data is highly sub-optimal or collected by random policies.

Standard offline RL algorithms rely on dynamic programming (the Bellman operator) to estimate value functions. The core issue is the max operator used to estimate target values: it tends to heavily overestimate the value of unseen, out-of-distribution (OOD) actions. While modern offline methods use conservative regularization or behavior cloning constraints to prevent the agent from taking these OOD actions, this severely limits the agent's ability to discover behaviors that are substantially better than the sub-optimal data it was trained on.

The authors address this challenge specifically for goal-conditioned offline RL under sparse rewards, deterministic transitions, and invertible actions.

Methods

Instead of trying to fix the Bellman operator's overestimation bias with constraints, the authors introduce MetricRL, which bypasses the Bellman operator entirely by framing value estimation as a geometric distance problem.

  1. Distance Monotonicity (DM): The core idea is to map the environment's states into a Euclidean latent space where distances correspond to the minimum number of actions needed to travel between states. Because finding a perfect isometric (distance-preserving) mapping is often mathematically impossible for complex topologies, the authors introduce Distance Monotonicity. This relaxed property ensures that if state $s_1$ is closer to the goal than state $s_2$ in the true environment, its latent representation will also be closer to the goal representation.
  2. Contrastive-Style Loss: MetricRL learns this embedding by minimizing a loss function that forces directly connected states to be exactly one unit apart in the latent space, while simultaneously pushing randomly sampled, non-adjacent states away from each other.
  3. Policy Estimation: Once the distance-monotonic embedding is learned, the value function is approximated directly from these latent Euclidean distances. The policy is then optimized using a simplified weighted imitation learning objective (maximum likelihood) that acts greedily on this value function, ensuring the agent only samples valid, in-distribution actions from the dataset.
  4. Super-States for Images: To handle high-dimensional image observations where changing goals can break graph connectivity assumptions, the authors introduce a synthetic "super-node" that links all termination states together, maintaining a coherent latent structure.

Datasets

The authors evaluated MetricRL against a wide array of state-of-the-art baselines across three dataset quality tiers (low / random, medium, and high / expert):

  • Maze2D (U-Maze, Medium, Large): Continuous navigation tasks from the standard D4RL benchmark suite.
  • Reach: A robotic manipulation task featuring a 7-DoF arm moving to random workspace goals.
  • Minigrid (Empty, DoorKey): Discrete grid-world navigation tasks evaluated using both compact state features and raw image observations.
  • Hypermaze: A newly introduced navigation benchmark consisting of an $n$-dimensional grid-like maze with large discrete action spaces (e.g., 4D with 81 possible actions), designed specifically to test scalability.

Key Insights and Ideas

  • Monotonicity is Enough: You do not need a perfect mapping of exact graph distances (isometry) to recover an optimal policy. Preserving the relative ordering of distances (distance monotonicity) is mathematically sufficient for a greedy policy to find the shortest path to a goal.
  • Geometry Beats the Bellman Trap: Shifting from temporal difference (TD) learning to geometric metric learning fundamentally eliminates the risk of OOD action overestimation.
  • The Power of Symmetry: Assuming invertible actions (if you can move from A to B, an inverse action exists to go from B to A) provides a powerful inductive bias. This symmetry allows the model to interpolate missing transitions, drastically reducing sample complexity.

Key Results

  • Dominance on Sub-Optimal Data: MetricRL consistently outperforms prior state-of-the-art goal-conditioned offline methods (such as IQL, CQL, QRL, and GoFAR) when trained on low and medium quality data. As shown in Figure 1, MetricRL achieves near-optimal rewards on Minigrid DoorKey even when the dataset contains virtually zero successful trajectories.
  • Respecting Environment Topology: Value function visualizations on Maze2D Large (Figure 5) demonstrate that MetricRL is uniquely capable of capturing maze structures. It correctly assigns low values to states separated by a wall, whereas baseline methods smooth over the wall and erroneously assign high values to dead ends.
  • Linear Scaling: In sample efficiency trials on the Hypermaze benchmark, MetricRL's required training iterations scaled linearly with the state-space size, while standard TD-learning methods (DQN) scaled exponentially.
Figure 1
Figure 4: Estimated value function for different methods using a dataset collected from a random policy in Maze2D Large. We highlight (in red) how MetricRL is the only method able to correctly assign low values to states that are close in the Euclidean space but not in terms of distance to the goal. Additionally, we highlight (in orange) that our proposed distance monotonicity in complex topologies is not equivalent to isometries, yet we are still able to recover provably optimal policies (as we discuss in Section 3.3). All values are normalized.

Limitations and Future Work

  • Deterministic & Reversible Assumptions: MetricRL relies on Euclidean metric spaces, which are inherently symmetric. This restricts the method to deterministic environments with invertible actions (i.e., physical systems where actions can be undone), making it inapplicable to purely directed or highly stochastic environments.
  • Dataset Connectivity: The method assumes the offline dataset forms a single connected component, though the authors mitigate this for multi-goal image datasets using synthetic super-states.
  • Future Directions: The authors aim to extend distance monotonicity to quasimetrics to accommodate asymmetric, directed state transitions, adapt the framework to stochastic Markov Decision Processes (MDPs), and explore its application in online reinforcement learning settings.

Summary updated

BibTeX
@misc{reichlin2024goal,
  author = {Alfredo Reichlin and Miguel Vasco and Hang Yin and Danica Kragic},
  title = {{Goal-Conditioned Reinforcement Learning from Sub-Optimal Data on Metric Spaces}},
  year = {2024},
  eprint = {2402.10820},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.10820},
}
Figure