Kinds of learning
Imitation Learning: Learning Behavior From Demonstrations
Understand behavioral cloning, sequential distribution shift, expert inconsistency, and how demonstrations can complement rewards and constraints.
By the end you can
- Define imitation learning as learning a policy from demonstrated behavior
- Explain behavioral cloning and its relationship to supervised learning
- Recognize compounding error and covariate shift in sequential deployment
- Evaluate demonstrations for expertise, coverage, and hidden objectives
Example
The demonstration dataset contains a policy, not merely labels
Waymo trained a driving policy on roughly 26 million examples — about 60 days of continuous driving — and it still could not recover from a mistake. The 2019 ChauffeurNet paper puts the verdict in its abstract: “30 million examples are still not enough”. The introduction says why the authors had expected otherwise: “Despite recent results that point to error accumulation no longer being an issue with good representations and high capacity models (Laskey et al. [10]), our first finding was that not even 30 million examples were sufficient for pure imitation learning.”
What the data lacked was not volume but coverage. Waymo's own account of the system states it directly: “Expert driving demonstrations obtained from real-world driving typically contain only examples of driving in good situations, because for obvious reasons, we don't want our expert drivers to get into near-collisions or climb curbs just to show a neural network how to recover in these cases.”
The closed-loop test made that visible. Across 20 lane-departure scenarios the pure-imitation baseline M0 “is not able to recover in any of the situations”. Two other models, M3 and M4, were trained on synthesised trajectory perturbations, with environment losses and a reduced weight on the imitation loss. They “handle all deviations well”. Sixty days of good driving did not teach recovery. Twenty fabricated departures did.
- Camera and sensor observations recorded at each moment become inputs, of which ChauffeurNet had roughly 26 million.
- Human actions at those same moments become the supervised targets for behavioral cloning.
- Rare recoveries are absent because skilled drivers avoid dangerous states, and no fleet sends expert drivers to “climb curbs just to show a neural network how to recover”.
- Different drivers trade comfort, speed, and caution differently, so the targets are not one consistent policy.
- A cloned policy drifts into states the demonstrators rarely visited: M0 recovered in none of the 20 lane-departure scenarios.
- Safety constraints remain necessary even when the teacher was competent, which is why ChauffeurNet added synthesised perturbations rather than more demonstrations.
Case
NVIDIA had to manufacture the mistakes its drivers never made
A network that only ever sees good driving learns to drift off the road. NVIDIA hit that wall in 2016 and engineered around it. Its end-to-end system mapped a single camera frame straight to a steering command, trained on “about 72 hours of driving data” gathered as of 28 March 2016. Bojarski and twelve colleagues were blunt about what those hours lacked: “Training with data from only the human driver is not sufficient. The network must learn how to recover from mistakes. Otherwise the car will slowly drift off the road.”
The fix was to manufacture the missing states. Two extra cameras, mounted left and right of centre, supplied off-centre views. Further shifts and rotations were synthesised by viewpoint transformation of the nearest camera's image. Each fabricated view was paired with the steering command that would correct it. On a typical drive from Holmdel to Atlantic Highlands, New Jersey, the car then steered itself “approximately 98% of the time”. It had learned to recover from positions no driver had ever put it in.
Demonstrations supervise actions
Imitation learning uses examples of behavior produced by a teacher, an expert, a historical policy, or a planner. From those trajectories the learner tries to reproduce or infer a policy of its own.
Behavioral cloning is the simplest method. It treats observation–action pairs as supervised examples. Sequential deployment then creates an extra difficulty, because the learned policy changes the observations it later encounters.
The method is 37 years old, and its central defect was named in the paper that introduced it. ALVINN was a 3-layer back-propagation network trained for 40 epochs on 1,200 simulated road snapshots. In 1988 it drove Carnegie Mellon's NAVLAB van at half a metre per second, along a 400 metre path through a wooded part of the campus, under sunny fall conditions. Discussing what it would take to train on the fly with real images rather than simulated ones, Dean Pomerleau wrote that “the network must not solely be shown examples of accurate driving, but also how to recover (i.e. return to the road center) once a mistake has been made.” Everything since — NVIDIA's synthesised off-centre views, ChauffeurNet's perturbations, interactive correction — is an answer to that one sentence.
Visual
How a small imitation error can compound
One imperfect action can move the learner away from the demonstration distribution, where subsequent predictions have weaker support.
The compounding has been quantified. Ross and colleagues stated the worst case in 2011, in one sentence: “a classifier that makes a mistake with probability ε under the distribution of states/observations encountered by the expert can make as many as T²ε mistakes in expectation over T-steps under the distribution of states the classifier itself induces”. Errors grow with the square of the horizon, not with its length.
Their Super Tux Kart experiment shows why more demonstration does not repair it. Under the plain supervised approach “performance does not improve as more data is collected … because most of the training laps are all very similar and do not help the learner to learn how to recover from mistakes it makes”. Their DAgger policy instead collects fresh expert labels in the states the learner actually reaches. It “never falls off the track after 15 iterations of training”.
The theory and the fleet agree. A quadratic bound is what 26 million examples run into.
1. Copy familiar action
The policy predicts well on states common in demonstrations.
2. Make a small error
A slight deviation changes position or context.
3. Enter an unfamiliar state
The new observation was rare or absent in the expert data.
4. Accumulate uncertainty
Further action errors become more likely along the trajectory.
5. Recover or fail
Interactive correction, fallback control, or constraints determine the outcome.
Comparison
Demonstrations, corrections, and rewards
Human information can enter sequential learning in several forms. The teacher shows a complete or partial trajectory. The teacher takes over, or supplies the better action, in the difficult states. Or the teacher evaluates outcomes and alternatives after the fact.
Each form buys something and costs something. Demonstration is efficient when good behavior is easy to show, but it omits failure recovery and copies hidden habits. Correction targets learner-specific failures, but it burdens the teacher and can endanger them. Reward or preference allows behavior beyond exact copying, but it requires objective design, and the feedback can arrive delayed or ambiguous.
One deployed system stacked two of the three and published the price of each. For InstructGPT, OpenAI hired about 40 contractors, supervised-fine-tuned GPT-3 on written demonstrations, trained a 6B reward model on human rankings, and ran PPO against that reward. The 2022 paper gives the three sizes: “The SFT dataset contains about 13k training prompts (from the API and labeler-written), the RM dataset has 33k training prompts (from the API and labeler-written), and the PPO dataset has 31k training prompts (only from the API).”
The demonstration set is the smallest of the three. It also carried the most. Labelers preferred the resulting 1.3B-parameter model's outputs to those of the 175B GPT-3, a model with over 100 times more parameters.
The teachers were not an oracle either. In the same study the training labelers agree with each other 72.6 ± 1.5% of the time. That number is a ceiling on what any of the three signals can be said to encode.
Demonstration
The teacher shows a complete or partial trajectory.
- Efficient when good behavior is easy to show
- May omit failure recovery
- Copies hidden habits and constraints
- Useful for initial policy learning
Intervention or correction
The teacher takes over or supplies the better action in difficult states.
- Targets learner-specific failures
- Improves coverage near mistakes
- Can burden or endanger teachers
- Useful for interactive imitation
Reward or preference
The teacher evaluates outcomes or alternatives.
- Allows behavior beyond exact copying
- Requires objective design
- Feedback can be delayed or ambiguous
- Useful for refinement
Key idea
Expert behavior is conditional and sometimes inconsistent
An experienced operator may act under undocumented constraints, incomplete information, personal habits, or institutional incentives. Several experts may solve the same situation differently.
The institutional-incentive case has a documented instance. A rule-based model trained on a pneumonia dataset of 14,199 patients, described by 46 features and split 9,847 train / 4,352 test, learned the rule “HasAsthama(x) ⇒ LowerRisk(x)”. A history of asthma marked a patient as safer. The rule was not a data error. The 2015 paper reporting it explains why: “But it reflected a true pattern in the training data: patients with a history of asthma who presented with pneumonia usually were admitted not only to the hospital but directly to the ICU (Intensive Care Unit).” The historical policy's own intervention had been recorded as a property of the patients. A learner that imitated the record would send the highest-risk group home. The more accurate neural nets were kept out of the planned clinical trial because the same rule could not be found and removed in them.
Inspect disagreement and context rather than averaging blindly. The desired policy may need to outperform historical behavior on safety, fairness, efficiency, or consistency.
The robomimic study built that disagreement into the data on purpose. Two kinds of demonstrations were collected for the same manipulation tasks. The Proficient-Human set held 200 demonstrations “collected by a single, experienced teleoperator”. The Multi-Human set held 300 demonstrations from “6 teleoperators of varying proficiency, each of which provided 50 demonstrations”. Two of the six were rated better, two okay, two worse. The proficiency gap showed up as “large variations in trajectory length and noise in robot movement or mistakes (e.g. missed grasps)”. Offline reinforcement-learning algorithms cope well with mixed-quality machine-generated data. That did not carry over: “we empirically find that they fail to learn well from mixed quality human data.” Human disagreement is not noise a loss function averages away.
Demonstrations reveal what was done under particular conditions, not the only correct policy.
Analogy
Apprenticeship beside a skilled craftsperson
An apprentice watches an expert, then attempts the work. Observation provides rich sequences. But the apprentice may not see the expert's internal checks, or know how to recover from a novel mistake.
Imitation learning has the same hidden-context problem. The pneumonia rule is what it looks like when the hidden context is an institution rather than a person: the apprentice saw the asthmatic patients do well, and did not see the intensive-care unit they had been sent to. A real apprentice brings broad understanding and can ask a question. A model has neither, unless the system is explicitly built to support it.
Copying visible action is easier than recovering the reasoning and safety margin behind it.
Steps
Audit demonstrations before training a policy
The trajectory dataset should be reviewed as a record of behavior and opportunity. The cases above give the audit its questions.
Define expertise: state who produced the behavior and what evidence supports competence. Robomimic's six teleoperators were graded better, okay and worse before a single policy was fitted.
Capture context: log observations, available actions, constraints, and intervention authority. The asthma rule was legible only once someone knew where those patients had been admitted.
Find coverage gaps: search for rare states, recoveries, boundary cases, and changing conditions. ChauffeurNet's 60 days of driving contained none of the twenty lane departures it was later tested on.
Preserve disagreement: record alternate expert actions and reasons where available, rather than averaging them into a single target.
Test closed-loop behavior: evaluate full trajectories rather than isolated action accuracy. The T²ε bound is about trajectories, not about per-step error.
Add safe fallback: define takeover, constraints, and stop conditions before deployment.
1. Define expertise
State who produced the behavior and what evidence supports competence.
2. Capture context
Log observations, available actions, constraints, and intervention authority.
3. Find coverage gaps
Search for rare states, recoveries, boundary cases, and changing conditions.
4. Preserve disagreement
Record alternate expert actions and reasons where available.
5. Test closed-loop behavior
Evaluate full trajectories rather than isolated action accuracy.
6. Add safe fallback
Define takeover, constraints, and stop conditions before deployment.
Imitation often initializes rather than finishes learning
Demonstrations can provide a safe and competent starting policy. Reinforcement, preferences, planning, or targeted corrections then improve specific behaviors.
AlphaGo is that arc with numbers on it. A 13-layer supervised-learning policy network was trained on 30 million positions from the KGS Go Server. It reached 57.0% accuracy at predicting expert moves on a held-out test set, and 55.7% from raw board position and move history alone, against a prior state of the art of 44.4%. A self-play reinforcement-learning policy network was then initialised from it, and won more than 80% of games head-to-head against it.
The stronger policy is not the one that shipped inside the search. The paper, in Nature in 2016, notes the reversal: “It is worth noting that the SL policy network pσ performed better in AlphaGo than the stronger RL policy network pρ, presumably because humans select a diverse beam of promising moves, whereas RL optimizes for the single best move.”
This combination should preserve constraints and independent evaluation. Additional optimization can erase desirable teacher behavior if the new reward is poorly aligned. Here the erased property was breadth. The refined policy was better at winning and worse at proposing candidates, and the search needed candidates.
Example
What to measure beyond action accuracy
A sequential policy should be judged on trajectories and recovery, not only on agreement with the demonstrator. The first of these measures is not an informal one. California defines the event a fleet must count, in regulation: “For the purposes of this section, "disengagement" means a deactivation of the autonomous mode when a failure of the autonomous technology is detected or when the safe operation of the vehicle requires that the autonomous vehicle test driver disengage the autonomous mode and take immediate manual control of the vehicle, or in the case of driverless vehicles, when the safety of the vehicle, the occupants of the vehicle, or the public requires that the autonomous technology be deactivated.”
Every permitted manufacturer must file an annual report by 1 January, covering 1 December to 30 November. Under that rule the California DMV reported on 2 February 2024 that test vehicles drove a record 9,068,861 miles in autonomous mode on California public roads in the 1 December 2022 – 30 November 2023 period: 5,801,069 miles with a safety driver and 3,267,792 miles of driverless testing. A rate needs a denominator. That is one a regulator publishes.
- Intervention rate: how often a safety driver or operator must take control, against a stated denominator — 9,068,861 autonomous miles in the 2022–2023 California reporting year.
- State coverage: whether evaluation includes conditions absent from ordinary demonstrations, as the 20 lane departures were absent from ChauffeurNet's 26 million examples.
- Recovery quality: whether the policy returns safely after small deviations, which is the property M0 lacked entirely.
- Constraint violations: counts and severity of prohibited or unstable actions.
- Task completion: success over complete episodes rather than isolated time steps.
- Behavior shift: differences across sites, operators, weather, or equipment versions — the gap robomimic found between one experienced teleoperator and six of mixed proficiency.
Key takeaways
- Imitation learning uses demonstrated actions or trajectories to learn a policy, and ALVINN named its recovery gap in 1988.
- Behavioral cloning is supervised learning applied to observation–action pairs, and ChauffeurNet's 26 million examples did not make it enough.
- Sequential distribution shift compounds quadratically: T²ε mistakes over T steps, not Tε.
- Demonstrations encode teacher context, incentives, habits, and coverage gaps — including an institution's own interventions, as the pneumonia asthma rule shows.
- Interactive corrections can target learner failures, but they increase expert burden and risk, and the human signal is itself inconsistent at 72.6 ± 1.5% labeler agreement.
- Imitation often works best as a constrained starting point, though AlphaGo shows the imitated policy can also be the one that survives into deployment.