Model-based trajectory stitching for improved behavioural cloning and its applications

Charles A. Hepburn, Giovanni Montana

Abstract

Behavioral Cloning (BC) often fails when trained on sub-optimal or noisy datasets because it lacks a mechanism to distinguish between high- and low-reward actions. We present Model-Based Trajectory Stitching (MBTS), a "data-first" offline reinforcement learning approach that improves BC by repairing sub-optimal datasets. MBTS uses learned dynamics models to "stitch" together high-value states from different trajectories using newly generated actions. Our results on the D4RL benchmark demonstrate that MBTS-enhanced datasets allow simple imitation learning to compete with and often outperform state-of-the-art offline RL algorithms.

Introduction

Behavioral Cloning (BC) is a fundamental imitation learning technique that maps states to actions via supervised learning. While effective with expert demonstrations, its performance degrades significantly with "noisy" or sub-optimal data, such as logs from mediocre agents. Traditional offline Reinforcement Learning (RL) methods address this by introducing complex mathematical constraints or penalties during training. MBTS shifts the focus from algorithmic complexity to data quality, asking whether we can "fix" the dataset itself to enable simpler learning paradigms.

The MBTS Framework

Model-Based Trajectory Stitching (MBTS) functions by "Frankensteining" a superior dataset from the components of a mediocre one. The process involves three primary stages:

  1. Candidate Search: For every state in a given trajectory, the algorithm searches the entire dataset for states in other trajectories that are reachable and possess a higher future value.
  2. The Stitching Event: When a superior state is identified, MBTS employs a Forward Dynamics Model (an ensemble of Gaussian networks) to verify that the transition is physically plausible. A State-Value Function ensures the jump leads to higher rewards.
  3. Action Generation: To bridge the gap between previously unconnected states, a Conditional Variational Autoencoder (CVAE) acts as an inverse dynamics model to "imagine" the required action.
Figure 1: Visualization of the Model-Based Trajectory Stitching (MBTS) process.

This iterative process—typically reaching peak performance within five iterations—allows the value function to be re-trained on progressively better data.

Experimental Evaluation

We evaluated MBTS using the D4RL benchmarking suite, focusing on MuJoCo locomotion tasks (Hopper, Halfcheetah, and Walker2d) across various data quality levels: "Medium," "Medium-Replay," "Medium-Expert," and "Expert." MBTS-enhanced data was compared against standard BC and state-of-the-art offline RL methods, including CQL, IQL, and TD3+BC.

Key Insights and Results

The core advantage of MBTS is its ability to find "shortcuts" to high-reward regions that exist within the data but were never connected in a single continuous run. Unlike other model-based methods that generate entirely synthetic "dreamed" experiences—which can lead to model exploitation—MBTS only connects existing, grounded states.

Key findings include:

  • Performance Gains: On the "Hopper Medium-Replay" task, MBTS improved standard BC performance by nearly 70%.
  • State-of-the-Art Results: When combined with existing offline RL methods like TD3+BC or MBOP, MBTS-based approaches achieved SOTA results in 10 out of 12 D4RL datasets.
  • Expert Alignment: KL-divergence metrics confirmed that MBTS-enhanced policies are mathematically closer to true expert policies than standard BC, even when starting with minimal expert data.

Conclusion and Future Work

MBTS demonstrates that improving data quality can be as effective as improving learning algorithms. By grounding synthetic transitions in existing states, it avoids common pitfalls of model-based RL. While currently focused on continuous control, future work could adapt MBTS to discrete spaces or multi-agent settings. The primary limitation remains the reliance on model accuracy; errors in the dynamics models could introduce unrealistic transitions into the dataset.

Summary updated

BibTeX
@article{hepburn2024model,
  author = {Charles A. Hepburn and Giovanni Montana},
  title = {{Model-based trajectory stitching for improved behavioural cloning and its applications}},
  journal = {Machine Learning},
  year = {2024},
  doi = {10.1007/s10994-023-06392-z},
}
Figure