Demonstration-Conditioned Reinforcement Learning for Few-Shot Imitation

Christopher R. Dance, Julien Perez, Théo CachetICML 2021

Introduction

Few-shot imitation learning (FSIL) aims to create agents capable of mastering a brand-new task after observing only 1–5 demonstrations. Traditionally, this is achieved via Behavior Cloning (BC)—mimicking the expert's actions—or Inverse Reinforcement Learning (IRL)—inferring a reward function from the expert and then training on it.

However, both approaches have significant limitations. BC agents generally cannot perform better than the expert they are copying (the "ceiling" problem) and struggle with domain shifts (e.g., a robot trying to copy a human's motions). Meanwhile, IRL often requires hours of additional training at "test time" for every new task.

Demonstration-Conditioned Reinforcement Learning (DCRL) is a novel framework designed to bridge these gaps. By treating expert demonstrations as contextual input for a reinforcement learning policy, the agent learns to "read" a few demonstrations to understand a new task's objective. This allows it to outperform suboptimal experts and handle differences between the demonstrator and the agent.

Methods and Architecture

The core idea of DCRL is to train a policy that takes the current state history and a set of demonstrations as inputs. Unlike standard imitation, DCRL uses Reinforcement Learning (specifically Proximal Policy Optimization, or PPO) during the training phase. It maximizes the average cumulative reward across a large set of training tasks, using the demonstrations as a "hint" to the policy about which task it is currently solving.

DCRL Architecture

To process this information efficiently, the authors employ a Transformer-based encoder-decoder architecture:

  • Axial Attention: To handle multiple demonstrations (which are long time-series), DCRL uses "axial attention." Instead of a standard Transformer that scales quadratically with the total number of frames, axial attention processes the temporal axis and the "cross-demonstration" axis independently. This significantly improves computational efficiency.
  • Cross-Demonstration Attention: This mechanism allows the agent to look across multiple examples to resolve ambiguities, such as piecing together the start and end of a maze from different demonstrations.

Key Insights

  • Imitation Without Copying: You do not have to strictly copy an expert to learn from them. By treating the demonstration as a task descriptor, the agent uses its own RL-learned "common sense" to complete the task more efficiently.
  • Surpassing the Teacher: Because DCRL is trained to maximize rewards, it can ignore noise in suboptimal demonstrations. If an expert takes a zig-zag path, the DCRL agent can learn to take a straight line to the goal.
  • Zero-Shot Generalization: Once trained, the agent requires no reward function and no gradient updates to tackle a new task. It simply processes the new demonstrations and acts.
  • Handling Domain Shift: DCRL can successfully perform tasks even when demonstrations come from a different robot model with varying degrees of freedom and mechanical structures.

Datasets and Key Results

The researchers evaluated DCRL on two main benchmarks: Meta-World (ML45), a standard robotic manipulation benchmark, and a custom Navigation Benchmark consisting of 60 different maze layouts.

Success Rate vs. Number of Demonstrations

The results highlight several major advantages of the DCRL framework:

  • Superior Zero-Shot Performance: On unseen Meta-World tasks, DCRL achieved a 48% success rate without any fine-tuning, significantly outperforming BC-based methods (which only reached 17–24%).
  • Rapid Fine-Tuning: With just a few seconds of fine-tuning via behavior cloning at test time, DCRL's success rate jumped to 90%, far exceeding previous state-of-the-art results for Meta-World.
  • Information Integration: As shown in the performance charts, DCRL's success rate steadily improves as more demonstrations are provided, proving the axial attention mechanism effectively aggregates information.
  • Robustness to Noise: In experiments with "perturbed experts" (experts with added Gaussian noise), DCRL maintained high success rates even when the demonstrations themselves were failing the task.

Limitations and Future Work

While powerful, DCRL does have limitations. It requires access to reward functions during the training phase. While it doesn't need them at test time, this makes the initial training harder to set up than pure imitation learning. Additionally, training a single policy to handle dozens of tasks simultaneously is difficult due to "gradient interference," where learning one task might degrade performance on another.

Future directions include exploring more extreme domain shifts, such as learning robot policies directly from videos of humans or natural language instructions.

Summary updated

BibTeX
@inproceedings{dance2021demonstration,
  author = {Christopher R. Dance and Julien Perez and Théo Cachet},
  title = {{Demonstration-Conditioned Reinforcement Learning for Few-Shot Imitation}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
}
Figure