How robots learn, explained for non-engineers: demonstrations, teleoperation, simulation, trial and error and large robot models.
Guide

Imitation learning: how robots learn by copying demonstrations

How robots learn tasks from human demonstrations, why small errors snowball, how human corrections fix drift and where imitation learning works now.
Imitation learning: how robots learn by copying demonstrations

Imitation learning teaches a robot by example: a person demonstrates a task, usually by driving the robot, and a model learns to repeat the recorded actions in similar situations. In a 2023 study, a low-cost two-armed robot learned six fine tasks this way, such as slotting a battery, mostly from 50 demonstrations per task.

The idea in one paragraph

Think of the robot as having eyes and hands. At each moment its eyes give it a picture and its hands could move in many ways. A demonstration shows which movement a person chose for each picture. Gather enough of these pairs and a learning algorithm can fit a function that maps a new picture to a sensible movement. That function is the policy. The robot is not memorising a film of one performance. It is fitting a rule that covers pictures it has not seen exactly, which is why a policy trained on towels laid out in many positions can often handle a position it was never shown. The approach is also called learning from demonstration.

This differs from classic programming, where a technician writes the path. It also differs from the trial and error described in the reinforcement learning guide, because nobody here defines a reward. The target is given directly by the examples.

What a demonstration contains

A demonstration is a recording of an episode from start to finish. For a robot arm it usually contains a stream of camera frames, often from a camera mounted on the wrist and one or two fixed cameras watching the table. It contains the robot’s joint positions or the position of its gripper, the state of the gripper itself (open or closed), and the commands that were sent to the motors. Many projects also store a short text label such as “put the cup on the saucer”, which becomes important when a model is later trained to follow instructions.

Each frame is paired with the action the operator chose at that moment. If the system records at 10 to 50 steps per second, a 45-second demonstration holds hundreds or thousands of observation and action pairs. The number of demonstrations is therefore a smaller figure than the number of training examples the model sees.

Where the demonstrations come from matters. Most arm projects use teleoperation, covered in the teleoperation guide. Some use kinesthetic teaching, where a person physically guides the arm by hand while it is set to a compliant mode that lets it be moved. Others record humans using tools with cameras attached, so the learning system sees a human-style demonstration without a robot in the room, although converting that into robot actions takes extra work.

Behaviour cloning step by step

Behaviour cloning is imitation learning treated as ordinary supervised learning. The steps are short.

  1. Record demonstrations of the task, covering the variation you want the robot to handle.
  2. Clean the data: remove failed takes, trim dead time at the start and end, and check that camera and action recordings line up in time.
  3. Train a neural network to predict the demonstrated action from the observation.
  4. Test the policy on the robot, usually starting with a few trials in conditions close to the demonstrations.
  5. Add demonstrations where the policy fails and train again.

Step 5 is where most of the real effort goes. A first policy often fails in ways nobody predicted. The improvement comes from looking at the failures, deciding what the training data was missing, and recording more of it. Open-source tools have made this loop accessible to small teams, and the LeRobot documentation shows how teleoperation, recording, training and deployment fit together on affordable arms.

Why do small errors snowball?

Supervised learning in its textbook form assumes each example is independent of the others. Robot control breaks that assumption. The picture the robot sees next depends on the action it just took. The paper that introduced DAgger, by Stephane Ross, Geoffrey Gordon and Drew Bagnell and published in 2011, begins from exactly this point: in imitation learning, future observations depend on previous predictions, which violates the usual independence assumptions and leads to poor performance. The paper is available on arXiv.

Here is what that looks like in practice. A person demonstrating a pouring task keeps the cup near the right height and rarely makes large mistakes. The recorded data therefore contains almost no examples of the cup being badly misplaced. The trained policy is not perfect, so at some moment it moves the gripper a centimetre off the path a person would have taken. That centimetre puts the robot in a spot that appears nowhere in the data. The policy has no training for this spot, so its next action is a worse guess, which pushes it further off. After a few steps it is somewhere that looks nothing like a demonstration, and it flails or freezes. The error has compounded.

Researchers describe this as a mismatch between the distribution of states in the training data (what the expert saw) and the distribution the learned policy visits when it runs. Nothing is wrong with the optimiser. The data simply never covered the places the policy ends up.

Fixing drift with human corrections

The DAgger algorithm, short for dataset aggregation, addresses the mismatch directly. Run the current policy and let it drive. While it drives, a human expert looks at each situation the policy reaches and says what action they would have taken there. Add those expert labels, which cover the policy’s own mistakes, to the training set and train again. Repeat.

The result is a dataset that includes the strange places the policy gets to, each paired with a good action to leave them. In the original paper the authors report that the approach outperformed earlier methods on two imitation learning problems and a sequence labelling benchmark. Those results belong to those problems. What carries over to robots generally is the idea: collect corrections where the robot actually goes.

Practical versions look different from the original algorithm. A common one is a takeover: a person watches the autonomous robot, grabs the controls when it starts to go wrong, guides it back to a good state and lets go. The recording of the takeover becomes new training data labelled with the corrective action. Some teams call this human-in-the-loop data collection. It is slower per example than ordinary demonstration because it needs a person watching a running robot, but each example is worth more because it sits exactly where the policy was weak.

A related trick is to deliberately add small disturbances while recording demonstrations, so the data contains the operator recovering from slight errors. Both methods give the policy examples of how to get back on track.

Diffusion policies and action chunks

Two ideas have changed how modern imitation policies are built: predicting several actions at once, and modelling more than one acceptable way of doing something.

Early behaviour cloning predicted one action at each step. A policy that predicts a short run of future actions, often called an action chunk, behaves more smoothly and makes fewer jittery corrections, because it commits to a plan for a fraction of a second before looking again. After executing part of the chunk, the policy looks at the camera and predicts a fresh chunk. This pattern is called receding horizon control. Action Chunking with Transformers (ACT), the method behind the 2023 study mentioned at the top of this page, also predicts actions in chunks, and its authors present it in a paper on arXiv as a response to errors that compound over time.

The second idea matters because people do not always do the same thing in the same situation. One operator may go around an obstacle on the left and another on the right. If a model is trained to predict the average of the two, it drives straight into the obstacle. Diffusion Policy, which a Columbia University group and its collaborators published in 2023, represents the policy as a denoising diffusion process, the same family of method used in many image generators. Instead of outputting one averaged action, it starts from random noise and refines it into an action sequence, and it can end up on either side of the obstacle without blending them. The project page says the authors benchmarked it on 12 tasks from four manipulation benchmarks and found it outperformed the existing methods they compared, with an average improvement of 46.9 per cent. The size of that improvement depends on the tasks and baselines chosen, so treat it as a reason the method became popular, not a guarantee for your own task.

How many demonstrations does a task need?

There is no universal number, and anyone quoting one without the task attached is guessing. Reported figures range from a few dozen to tens of thousands. The 2023 ACT study used about 50 demonstrations per task for six tasks, each on one fixed setup, while the DROID dataset gathered 76 thousand across hundreds of scenes for policies meant to work in many places. Several factors move the number.

  • Variation in the scene. Putting one mug in one place needs far fewer demonstrations than putting any mug anywhere on a cluttered table.
  • Task length. A task with many steps gives errors more chances to compound.
  • Precision. Inserting a plug into a socket tolerates less error than pushing a box.
  • Sensing. A wrist camera often helps for fine alignment.
  • Starting point. A policy fine-tuned from a model pretrained on large datasets usually needs fewer task-specific demonstrations than one trained from scratch.

For planning, the teleoperation guide has a calculator that converts a demonstration count and the time per demonstration into operator hours and working days. With its default settings, 200 demonstrations of 45 seconds with 30-second resets come to about 4.2 hours of operator time, and 1,000 come to about 21 hours, before breaks and failed takes are added.

Coping with new objects, rooms and lighting

A policy learns whatever regularities its data contains, including ones nobody intended. If every demonstration was recorded under the same lamp, the model may rely on a shadow pattern that disappears when the lamp is moved. If the cup was always blue, a red cup may be ignored.

Teams address this in a few ways. They vary the scene deliberately between demonstrations: different objects, positions, tablecloths and lighting. They use data augmentation, which crops, shifts or recolours training images so the model does not depend on exact pixels. They pool data from several places. The DROID dataset, described on arXiv, was collected by 50 people across North America, Asia and Europe over 12 months, covering 564 scenes, because the authors found that most robot data had come from a small number of environments. The authors report that training with it gave policies with higher performance and better generalisation. And the Open X-Embodiment collaboration, described on arXiv, pooled data from many robots and institutions to test whether one model can use experience from different machines.

Even with these steps, performance often drops in a new building or on unfamiliar objects until more varied data is added. Success in one kitchen is a result about that kitchen.

Myth or fact

Myth Myth: The robot copies a person's movements exactly.

Fact Fact: It learns a mapping from what its sensors see to the actions to take, so it can respond when things shift slightly.

Myth Myth: One perfect demonstration is enough.

Fact Fact: Most methods need many varied demonstrations of the same task.

Myth Myth: Only flawless demonstrations make good data.

Fact Fact: Robots also need examples of recovering from mistakes. Methods such as DAgger collect corrections in the situations the robot actually reaches.

Myth Myth: A robot that learned a task can do it anywhere.

Fact Fact: New objects, lighting and layouts often lower success until more varied data is added.

Myth Myth: Once trained, no people are involved.

Fact Fact: People still collect data, label, correct and supervise.

Where imitation learning works today

Published work shows imitation learning handling tabletop manipulation: pushing, picking and placing objects, pouring, wiping, folding cloth, inserting parts and opening drawers. It performs best when the scene is fairly controlled, the robot is the same as the one used for demonstrations, and a person can supply enough examples. It is a standard starting point in university robotics labs, and low-cost leader and follower arms have put it in reach of hobbyists and classrooms.

It also underpins the newer large models described on the compare methods page. A vision-language-action model is typically trained, in large part, by imitation on pooled demonstrations. So the questions in this guide, such as where the data came from and how varied it was, apply to those models too.

Limits and open questions

Several problems remain open. Imitation can only reproduce behaviour at roughly the skill level of the demonstrator, so it does not by itself produce a robot better than the people who taught it. Demonstrations of a task done from the operator’s viewpoint can miss information the robot needs, such as the force required to push a drawer shut. Policies are hard to inspect, so when one fails the cause is often unclear. Coverage is a standing issue: no dataset contains every situation a household or workplace will produce.

Researchers are working on several fronts, including combining demonstrations with the practice-based learning in the reinforcement learning guide, learning from video of people without a robot present, and building larger pooled datasets. Progress is real and also uneven, which is why the checklist for reading robot demo videos recommends asking what the robot was shown, how often it failed, and whether the setting was new.

Questions about a specific paper or method can be sent through the contact page.

Frequently asked questions

What is imitation learning in simple terms?

It is teaching a robot by example. A person performs a task, usually by driving the robot, the system records what the robot sensed and did, and a model is trained to produce similar actions in similar situations. It is also called learning from demonstration.

How is imitation learning different from programming a robot?

In programming, a person writes the path or rules. In imitation learning, the person shows examples and the model works out the rule. This helps when the world varies, but the result is harder to read and check than a script.

How many demonstrations does a robot need to learn a task?

It depends on the task. A 2023 study taught six fine tasks with about 50 demonstrations each on one fixed setup, while pooled datasets for broad skills run to tens of thousands. More variation in objects, positions and lighting means more demonstrations, unless the model starts from pretraining.

Why do robots trained by imitation make strange mistakes?

Small errors can move the robot into situations absent from its demonstrations. The model has no training there, guesses badly, and drifts further. Collecting human corrections where the robot actually goes, as DAgger does, reduces this.

What is behaviour cloning?

Behaviour cloning is the simplest form of imitation learning. Recorded pairs of observation and action are treated as a supervised learning problem, and a network is trained to predict the demonstrated action from each observation.

What is a diffusion policy?

It is a policy that generates robot actions with a denoising diffusion process, the family of method used in many image generators. It can produce a short sequence of actions at once and handle cases where people did the same task in different ways.

Can a robot learn by watching videos of people?

Research is exploring it, but it is harder than learning from robot demonstrations, because a human body and a robot body differ. The video has to be converted into actions the robot can perform, and that conversion is an open research problem.

Was this page useful?

Have a question?

Send it through the contact page or email hello@trainingrobot.com.

Ask how robots learn
Ask how robots learn