Hierarchical Policies

A flat policy that slips once in 20 steps finishes a 100-step task 0.6% of the time. Cut the task into 10 rooms, check each doorway, retry a failed room, and about half the runs finish.

Learn how a high-level policy picks subgoals and a low-level policy carries them out, with every equation read aloud.

Press Run one episode and watch both agents walk the corridor. Then press Run 500 and drag Rooms. Then we build it piece by piece: the two policies, their two clocks, the doorway check, goal types, training, switching and hierarchical RL.

You need a little Python and what a probability is. Imitation learning helps in Chapter 5. We build the rest from zero.

Re-taught from the lecture Hierarchy in Imitation and Reinforcement Learning of Stanford CS 224R: Deep Reinforcement Learning. The explanations, toys and numbers here are our own; every toy number is illustrative.

Walk a corridor of rooms

10
0.05

Illustrative toy. Each room is 10 steps. At every step each agent slips with the chance you set. The flat policy cannot tell it is off course, so one slip ends its run. The two-level policy checks each doorway and retries a room up to 3 times. Ticks on the bars mark the formula of Chapter 3.

Chapter 0

Why Long Tasks Break a Flat Policy

Multiply a small chance of error over many steps and watch the finish rate collapse

A robot must make a sandwich. That takes about 100 small motions: reach, grip, lift, carry, spread, place. A flat policy is one network that maps what the robot sees, plus the task, to the next motor command. It does this at every step, from the first reach to the last.

Each motion is easy. The whole task is hard, for three reasons.

TroubleWhat happensSize
Many pathsThe number of action sequences grows with every step4 actions over 50 steps: 450, about 1.3 × 1030
Compounding errorEvery step is one more chance to go wrongThe equation below
Getting stuckSome mistakes have no way backA dropped slice of bread ends the run

How likely is a long run with no mistake? Call the chance of a slip at one step ε (epsilon). Call the number of steps T. Call the chance that every step goes right P-finish.

Say it aloud

P-finish equals one minus epsilon, to the power T.

Pfinish
P-finish the chance that the whole run has no slip, from 0 to 1.
ε
epsilon the chance of a slip at one step, the same at every step.
T
to the power T multiply by itself once for each of the T steps.
In plain words

One step goes right with chance one minus epsilon. The steps do not depend on each other, so multiply that chance once per step, T times. The product is P-finish.

With numbers

With made-up numbers: epsilon 0.05 and T 100. P-finish = 0.95100 = 0.0059. A policy that is right 95% of the time at each step finishes 0.6% of its runs.

Watch the finish chance fall with length

The orange curve is the flat policy's finish chance against task length. Drag the slip chance, then the length.

0.050
100

The formula above, drawn for every length from 0 to 200 steps. The slips are independent in this toy.

The failure. A flat policy scores well on each piece of the task in testing and near zero on the whole task. To measure it, log the step where each failed run went wrong. If the failures spread over the whole run, compounding is the cause. The fix is to shorten the stretch that any one policy must get right. That is what a hierarchy does.

The road

  1. Two policies: one picks subgoals, one acts.
  2. Two clocks: the rollout, and why the slow model can be big.
  3. Checkpoints: the hero's formula, derived.
  4. What a subgoal looks like: words, images, positions.
  5. Training each level: segmented demos and one loss.
  6. When to switch: options, termination, fixed intervals.
  7. Language and images between the levels: high-level DAgger and SuSIE.
  8. Hierarchical RL: HIRO and skill discovery.
  9. Where hierarchy fails: the cases to test for.
  10. The field guide: terms, numbers, code and links.
A flat policy slips with chance 0.01 at each step. About what share of 100-step runs finish?

Chapter 1

Two Policies: One Picks Subgoals, One Acts

Split the policy into a slow planner that names the next subgoal and a fast controller that reaches it

"Bake a cheesecake" is hard as one task. "Buy the cream cheese" is easier. "Walk to the door" is easier still. People break long tasks into a ladder of shorter ones. A hierarchical policy does the same with two networks.

The high-level policy reads the observation and the task and picks a subgoal: a short target such as "pick up the bread". The low-level policy reads the observation and the subgoal and picks the motor command. Papers also call the subgoal a skill, a subtask, an option or a high-level action.

Call the observation at step t o-t, the subgoal g-t and the motor command a-t.

Say it aloud

g-t is drawn from pi-H-L of g given o-t and the task. a-t is drawn from pi-L-L of a given o-t and g-t.

gt
g-t the subgoal in force at step t, such as "open the drawer".
∼
is drawn from a sample from the chances on the right.
πHL
pi-H-L the high-level policy: a chance for each possible subgoal.
|
given what the policy reads before it chooses.
ot
o-t the observation at step t: camera images and joint angles.
task
the task the whole job, such as "make a sandwich".
at
a-t the motor command at step t.
πLL
pi-L-L the low-level policy: a chance for each motor command.
In plain words

The high level reads o-t and the task and samples a subgoal g-t. The low level reads o-t and that g-t and samples a motor command a-t. Only the low level moves the motors.

With numbers

With made-up numbers: pi-H-L picks "open the drawer" with chance 0.7. Given that subgoal, pi-L-L picks "pull" with chance 0.9. The chance of this pair is 0.7 × 0.9 = 0.63.

Compare three designs over 20 steps

Pick a design. The boxes show who reads what. The rows below light up each time a model runs.

Illustrative: the two-level design here picks a new subgoal every 10 steps.

A third design, the chain-of-thought policy, is one model that writes the subgoal and then the action at every step.

PropertyFlatTwo-levelChain-of-thought
Models121
Learns from subtask labelsNoYesYes
Two speedsNoYesHard
Swap one levelNoYesNo

The failure. The high level asks for a subgoal that the low level never trained on, so the low level moves at random. The symptom is a sensible plan and a wrong motion. Measure the low level's success on each subgoal the high level sends. The fix is to keep the high level to subgoals the low level can do (Chapter 5).

In a two-level policy, which model sends commands to the motors?

Chapter 2

Two Clocks: Rolling Out a Hierarchy

Run the high level now and then and the low level at every step, and share the cost of the slow model

Here is how two trained policies become behaviour. This loop is the rollout.

  1. Observe o-1 at step 1.
  2. Ask the high level for a subgoal g.
  3. Until it is time to switch: the low level picks a-t, the world moves, and t goes up by 1.
  4. Go back to step 2. Stop when the task is done or time runs out.
StepHigh level saysLow level does
t = 1"pick up the bread"move to the bread, close the gripper
t = 20(same subgoal)lift, carry to the plate
t = 35"spread the peanut butter"pick up the knife, scoop, spread
t = 70"place the second slice"reach, position, release

Three high-level decisions cover about 70 low-level ones. That gap lets the high level be a big, slow vision-language model (VLM): a network that reads images and text. The low level must keep up with the robot, at say 50 commands a second.

Call the time of one low-level call c-LL and of one high-level call c-HL. Call the number of steps per subgoal n. Call the average time per control step t-bar.

Say it aloud

t-bar equals c-L-L plus c-H-L divided by n.

t̄
t-bar the average compute time per control step, in milliseconds.
cLL
c-L-L the time of one low-level call.
cHL
c-H-L the time of one high-level call.
n
divided by n the steps that share one subgoal, and so share one high-level call.
In plain words

Every step pays for one low-level call, c-L-L. The n steps of a subgoal share one high-level call, so each step pays c-H-L divided by n.

With numbers

With made-up numbers: c-L-L 5 ms, c-H-L 300 ms and n 20. t-bar = 5 + 300/20 = 20 ms, which is 50 commands a second. With n = 1, t-bar is 305 ms, about 3 commands a second.

Share the slow call over n steps

Each column is one control step. Teal is the low-level call. Purple is a high-level call, spread over its n steps. The dashed line is the 20 ms budget for 50 commands a second.

20
300

Illustrative timings: the low-level call is fixed at 5 ms. The average assumes one processor that takes turns.

The failure. If the high level runs in the control loop, the robot freezes for the whole call, once every n steps. The symptom is a pause at each subgoal switch. Measure the gap between motor commands. The fix is to run the high level on its own thread while the low level keeps the last subgoal.

c-LL is 5 ms, c-HL is 200 ms, and n is 10. What is t-bar, and how many commands a second is that?

Chapter 3

Checkpoints: Why Hierarchy Helps

Derive the hero's formula and find where the gain comes from

Go back to the corridor in the hero. Each doorway is a subgoal, and reaching it is a checkpoint: a test the system can pass or fail. The hierarchy helps in four ways.

BenefitHow it works
Denser supervisionEach subgoal gives its own signal: did the robot pick up the bowl?
Shared skillsLearn "pick up" once and use it in many tasks: K skills plus N plans, not N whole tasks
Exploration in goal spaceTry "go to that door", not random joint wiggles
Two clocksA slow, big model plans and a fast, small one acts (Chapter 2)

The hero shows the checkpoint benefit. Here is its formula, step by step.

  1. One room is n steps. One try at a room has no slip with chance (1 − ε)n.
  2. The doorway check catches a failed try, and the agent tries the room again, up to r tries. All r tries fail with chance (1 − (1 − ε)n)r.
  3. The run needs every one of the K rooms.
Say it aloud

P-finish equals: one minus the quantity one minus one-minus-epsilon to the n, raised to the r, and all of that to the K.

Pfinish
P-finish the chance that the two-level agent gets through every room.
(1 − ε)n
one minus epsilon, to the n the chance that one try at one room has no slip in its n steps.
r
to the r r is the number of tries allowed per room.
K
to the K K is the number of rooms, each one needed.
In plain words

Find the chance that one try at a room goes right. Find the chance that all r tries fail, and subtract it from one. Multiply that room chance across the K rooms.

With numbers

With the hero's numbers: epsilon 0.05, n 10, r 3, K 10. One try: 0.9510 = 0.599. Three fails: 0.4013 = 0.065, so a room passes with 0.935. The run: 0.93510 = 0.51. The flat policy over the same 100 steps finishes 0.006.

Set r to 1. The formula becomes (1 − ε)nK, the flat policy's. In this toy, the whole gain comes from the check and the retry.

Give each room more tries

Orange is flat. Teal is two-level. Each room is 10 steps. Set tries to 1 and the two curves become one.

3
0.05

The formula above. Illustrative: real checks make mistakes, and real retries cost time.

The failure. A check that cannot see failure gives no gain. The symptom is a two-level policy that does no better than a flat one. Measure how often the check disagrees with a human label. The fix is a better check, or a fixed replan clock (Chapter 6).

In the corridor toy, the two-level policy gets one try per room (r = 1). How does its finish chance compare with the flat policy's?

Chapter 4

What a Subgoal Looks Like

Choose words, a picture or a position for the subgoal, and see what each one cannot say

The high level hands over g. What is g in the computer: a string, an image or a vector? The choice decides what data you need and what the low level can be told.

Goal typeWhat g isNeedsWeak at
LanguageA string: "open the drawer"Demos cut into pieces and labelled in wordsVague phrases: "move it over there"
ImageA picture of the scene after the subtaskVideo; no actions or segment labelsThe path; flaws in drawn images
StateA target vector: a hand position (x, y, z)A state space with meaningHow to get there
LatentA learned vectorCare: see Chapter 5Meaning; it can collapse to a flat policy

A good goal type has three properties.

  1. Expressive: it can ask for every behaviour the task needs.
  2. Structured: similar behaviours get similar goals. "Pick up the red bowl" sits near "pick up the blue bowl".
  3. The right level: not "make it work", not "turn joint 3 by 0.02 radians".

Ask for one of two grasps

The robot can grasp the bowl from the left or the right. Pick a goal type and a grasp. Compare the two subgoals it would send.

Illustrative scene. The bowl ends in the same place for both grasps.

Each type reaches the low level as a different input: a text embedding, a second camera-sized image, or a few numbers. Real systems pick by data. Yell At Your Robot uses language, SuSIE uses images and HIRO uses states (Chapters 7 and 8).

A state goal makes success easy to test. With made-up numbers: the target is (0.40, 0.25) m and the hand stops at (0.43, 0.21) m. The miss is the square root of 0.032 + 0.042, which is 0.05 m. Inside a 0.06 m tolerance, the subgoal counts as reached.

The failure. A vague language goal gives different results on different runs. Measure it: send one command 20 times and compare the end states. The fix is a more exact phrase, or a goal image or target position next to the words.

You have hours of robot video and no labels. Which goal type can the high level learn from it?

Chapter 5

Training Each Level

Cut demos into labelled pieces, train each level on its own loss, then fit one level to the other

Each level depends on the other. The low level should train on the subgoals the high level will send. The high level should pick subgoals the low level can do. Neither exists yet.

Imitation learning breaks the loop with a segmented demonstration: a demo cut into pieces, each labelled with its subgoal. The low level learns the motor command from the observation and the label. The high level learns the label from the observation.

Call one recorded step i. It has the observation o-i, the demo's motor command a-i and the label g-i. There are N steps. The low level's weights are θ (theta).

Say it aloud

L-L-L of theta equals minus one over N, times the sum over i of log pi-L-L of a-i, given o-i and g-i.

LLL(θ)
L-L-L of theta the low level's loss: a number that training pushes down.
−(1/N)
minus one over N average over the N steps, then flip the sign.
Σi
the sum over i one term for each recorded step.
log
log the natural log. Log of 1 is 0; log of a small chance is a large negative number.
πLL(ai | oi, gi; θ)
pi-L-L of a-i given o-i and g-i the chance the low level gives the demo's command, from what it saw and the label.
In plain words

For each step i, ask the low level how likely it finds the demo's command a-i, given o-i and the label g-i. Take the log of each chance, average, and flip the sign.

With numbers

With made-up chances 0.9, 0.6 and 0.2 on three steps: the minus logs are 0.105, 0.511 and 1.609. Their average is 0.742. The step at 0.2 costs the most, so training pushes hardest on it.

The high level uses the same loss with the label g* in place of the motor command, and no subgoal as input.

Turn one demo into training pairs

The strip is one demo cut into four labelled pieces. Drag the step to see what each level learns there. Drag the chance to see that step's loss.

42
0.60

Illustrative demo: 120 steps in four pieces of 30, in the style of a bag-packing task.

Train each level alone first. Then fit one to the other: if the low level fails at some subgoals, teach the high level to avoid them. A pre-trained language model can often serve as the high level as it is, since it already knows how tasks break down.

Why not let g be a learned vector and train both levels end to end on one loss? Then the pair is a flat policy with a hidden layer named g. The gain comes from giving g a meaning and each level its own supervision.

The failure. The high level sends subgoals the low level fails at. Measure the low level's success per subgoal, sorted by how often the high level sends it. The fix is to fine-tune the high level on what the low level did, or to train the low level more on those subgoals.

The low level gives the demo's action a chance of 0.5. What does that step add to the loss before averaging?

Chapter 6

When to Switch: Options and Termination

Decide when the high level picks again, and value a skill that runs for many steps

The rollout says "until it is time to switch". When is that? Sutton, Precup and Singh (1999) gave the classic answer. An option is a skill with three parts: the states where it may start, its own policy, and a termination rule. The termination rule gives the chance that the option stops in each state.

The high level picks options. Each runs for several steps. This is temporal abstraction: one high-level decision covers many time steps. How much is starting an option worth?

Call the worth of starting option o in state s Q(s, o). The option runs k steps and collects rewards r-1 to r-k. Each step of delay shrinks a reward by γ (gamma). The option ends in state s′ (s-prime).

Say it aloud

Q of s and o equals r-1 plus gamma r-2, and so on up to gamma to the k minus 1 times r-k, plus gamma to the k times the max over o-prime of Q of s-prime and o-prime.

Q(s, o)
Q of s and o the worth of starting option o in state s and acting well after it.
r1 + … + γk−1 rk
r-1 plus gamma r-2 up to gamma to the k minus 1, r-k the rewards the option collects while it runs, each shrunk for its delay.
γk
gamma to the k the discount for the k steps the option took.
maxo′
the max over o-prime the best next option, the one with the largest worth.
Q(s′, o′)
Q of s-prime and o-prime the worth of starting option o-prime where this option ended.
In plain words

Add up the rewards the option collects, each shrunk by gamma once per step of delay. Then add the worth of the best next option, shrunk by gamma once for each of the k steps.

With numbers

With made-up numbers: k is 4, the rewards are 0, 0, 0 and 1, gamma is 0.9, and the best next option is worth 2. Q = 0.93 × 1 + 0.94 × 2 = 0.729 + 1.312 = 2.04.

In practice there are two switch rules. Completion-based: ask the high level again when a detector says the subgoal has finished. Fixed interval: ask it every n steps.

Switch on a clock or on done

Four subtasks of 30 steps each. Purple ticks are high-level calls. Grey is idle time, red is wasted work. Turn on the slip and compare the rules.

15

Illustrative toy. The high level always picks the right subtask. The slip adds a 10-step subtask, "pick up the scoop", before the scooping can go on.

The failure. A completion detector that never fires leaves the agent on one subgoal forever. That is worse than a wrong subgoal, which the next replan fixes. Measure time spent in each subgoal; one that runs far past its usual length means a stuck detector. The fix is a timeout, which falls back to a fixed interval.

The high level replans every 20 steps at 50 steps a second. A surprise comes at a random moment. About how long until the high level reacts, on average?

Chapter 7

Language and Images Between the Levels

Correct the high level by speaking to it, or let it draw the next scene

Language as the interface. Yell At Your Robot (Shi et al., RSS 2024) puts a two-armed ALOHA robot under a two-level policy. The high level is a vision-language model that writes the next command as text, such as "pick up the bag". The low level is a language-conditioned behaviour cloning (LCBC) policy: it maps images, joint angles and that command to motor targets.

Both start from segmented demos. Then the team improves the high level with DAgger: run the learner, have an expert label the states it reaches, add those labels, retrain. Here the expert speaks.

  1. Run the two-level policy on the robot.
  2. When the high level picks wrong, a person says the right command. The low level follows the person's command.
  3. Keep the low level frozen.
  4. Fine-tune the high level on the spoken corrections, as labels for the states where they happened.
  5. Repeat.

Correct the high level, one round at a time

Each cell is a situation and the command the high level picks there. Red cells are wrong. Each round runs 10 episodes; a person corrects every wrong pick the robot reaches.

Illustrative toy. Each episode has four stages; each stage turns into its recovery case with chance 0.12. The demos showed few recovery cases.

Why it pays, with made-up numbers: the high level makes 4 decisions per run. If each is wrong 10% of the time, a run has no wrong pick with chance 0.94 = 0.66. Cut the error to 2% and that becomes 0.984 = 0.92. The correction costs a sentence, not a session of driving the robot by hand. Hi Robot (Shi et al., 2025) extends this to open-ended prompts and feedback. π0.5 (Physical Intelligence, 2025) has one model first predict a subtask in words, then the motor actions for it.

Images as the interface. SuSIE (Black et al., ICLR 2024) makes the high level an image-editing diffusion model. It reads the current image and the task in words, and draws what the camera should see a short time later. The low level is a goal-image-conditioned policy that drives the scene toward that picture; it never sees words. The high level needs no actions and no segment labels, so it can learn from video of people as well as robots.

LevelLearnsData
High level (image goals)What the scene looks like nextPlenty and cheap: any video
Low levelHow to move the arm to match a pictureScarce: robot data, but short, simple goals

The failure. The drawn goal image has a flaw, such as a bowl in two places, and the low level chases a scene it cannot reach. Measure the gap between the final frame and the goal image per subgoal. The fix is to draw goals often and train the low level on imperfect goal images.

In high-level DAgger with spoken corrections, which part is updated?

Chapter 8

Hierarchical RL and Skill Discovery

Reward the low level for reaching a target, relabel old goals, and find skills with no task reward

With rewards and no demos, HIRO (Nachum, Gu, Lee and Levine, NeurIPS 2018) gives the low level a reward of its own. The high level outputs a goal as an offset: "move 2 m forward and 1 m left". Call the state now s-t, the offset g-t and the next state s-t+1.

Say it aloud

r-L-L equals minus the length of s-t plus g-t minus s-t-plus-1.

rLL
r-L-L the low level's reward for one step: 0 is best.
‖ … ‖
the length of the straight-line distance of a vector.
st
s-t the state now, here a position (x, y) in metres.
gt
g-t the goal offset: how far to move from s-t.
st+1
s-t-plus-1 the state after one step.
In plain words

Add the offset g-t to where the agent is, s-t. That point is the target. Measure how far the next state s-t-plus-1 lands from it, and use minus that distance as the reward.

With numbers

With made-up numbers: s-t (0, 0), g-t (2, 1), s-t-plus-1 (0.5, 0.2). The miss is (1.5, 0.8), of length 1.7, so the reward is −1.7. HIRO then sets the next offset to (1.5, 0.8), so the target point stays put.

Reach for an offset, then relabel it

The purple flag is the target the high level asked for. Press Run 8 steps. The dashed purple arrow is the offset the low level reached.

0.60

Illustrative toy. A weaker low level takes shorter, noisier steps.

The low level keeps changing, so old high-level records stop being true. HIRO relabels each stored goal with the candidate that makes the recorded low-level actions most likely now. The simplest candidate is the offset reached. Jiang, Gu, Murphy and Finn (NeurIPS 2019) relabel with a sentence that describes what the agent did.

Can skills appear with no task reward? DIAYN (Eysenbach, Gupta, Ibarz and Levine, ICLR 2019) picks a skill z at random with chance p(z). A discriminator q(z | s) guesses the skill from the state.

Say it aloud

r equals log q of z given s, minus log p of z.

r
r the skill's reward at state s.
log q(z | s)
log q of z given s the log of the discriminator's chance for the skill that is running.
log p(z)
log p of z the log of a blind guess: 1/4 with 4 skills.
In plain words

Reward the skill when the state gives away which skill is running, compared with a blind guess. Skills that end in different places earn the most.

With numbers

With made-up numbers: 4 skills, so p(z) is 0.25. If q(z | s) is 0.9, r = log 0.9 − log 0.25 = −0.105 + 1.386 = 1.28. If q is 0.25, r is 0: the state tells nothing.

Spread four skills apart

Each shape is where one skill ends, over many runs. Drag the spread and watch the average reward rise toward its ceiling, log 4.

1.2

Illustrative: end states scatter with a spread of 0.5 around each skill's centre; the discriminator is the best guess for that scatter.

The failure. Skills can be easy to tell apart and still useless, such as four ways to twitch in place. Measure them with a high level trained on top, on a real task. The fix: let the discriminator see only the features that matter, such as position.

DIAYN has 4 skills. At some state the discriminator gives the running skill a chance of 0.25. What is the reward?

Chapter 9

Where Hierarchy Fails

Find the subgoal length that balances the two levels, and test for the six usual failures

A hierarchy does not remove errors. It moves them to the hand-off between levels. Ask where your gain comes from: goals with meaning, a loss for each level, two clocks, or a pre-trained high level. If you cannot name one, a flat policy of the same size may do as well.

The first test is the subgoal length n. Short subgoals make the high level decide often, and each decision can be wrong. Long subgoals make the low level stay right for many steps.

Take a 120-step task. The high level picks each subgoal right with chance 1 − δ (delta). The low level carries it out within 2 tries. Multiply over the 120/n subgoals.

Find the best subgoal length

The curve is the finish chance against steps per subgoal, on a log scale. The left end micromanages; the right end is a flat policy. Drag the two error rates.

0.05
0.030

Illustrative toy: a 120-step task, 2 tries per subgoal, the corridor model of Chapter 3 plus a high-level error per decision.

With the default numbers, one decision per step (n = 1) finishes 0.2% of runs. One subgoal for the whole task (n = 120) finishes 4.8%. Subgoals of 10 steps finish 22.9%, the best of the three.

FailureSymptomMeasureFix
Low level cannot do the subgoalGood plan, wrong motionLow-level success per subgoalFit the high level to the low level
Stuck detectorOne subgoal foreverTime in each subgoalA timeout or a fixed interval
Latent goal, end to endNo gain over flatSame-size flat baselineGive g a meaning and its own loss
Wrong subgoal lengthMicromanaging, or long low-level runs that failSuccess against nSweep n
Vague goalsOne command, many outcomesRepeat one command 20 timesExact phrases, images or targets
Slow domainTwo models where one would doCompare with a chain-of-thought policyNo conclusive comparison exists yet

Many current robot systems use hierarchical imitation learning. Fine-tuning such a large two-level system with RL is still an open research problem.

You set n = 1, so the high level picks a new subgoal at every step. What goes wrong?

Chapter 10

The Field Guide

Keep the terms, the numbers, a checklist and the core code on one page

A long task kills a flat policy by compounding small errors. A hierarchy splits it: a slow high level picks subgoals, a fast low level reaches them. The gain comes from checkpoints, a loss for each level, shared skills and two clocks. It is lost when the levels do not fit each other.

Terms and numbers

Term or quantityMeaning or valueChapter
Flat finish chance(1 − ε)T; 0.95100 = 0.6%0
Subgoal gThe high level's output, the low level's input1
Time per stepc-LL + c-HL/n; 5 + 300/20 = 20 ms2
Checkpoint finish chanceK rooms, r tries: 51% against flat 0.6%3
Goal typesLanguage, image, state, latent4
Low-level lossMinus the average log chance; 0.742 for 0.9, 0.6, 0.25
OptionStart states, a policy, a termination rule6
Option worthQ = 0.729 + 1.312 = 2.04 in the example6
High-level DAggerSpoken corrections; low level frozen7
HIRO rewardMinus the miss distance; −1.7 in the example8
DIAYN rewardlog q − log p; 1.28 at q = 0.9 with 4 skills8
Best subgoal lengthn = 10 gives 22.9% against 0.2% at n = 19

Before you trust a hierarchy

The core code

The rollout with a fixed replan interval, and the low-level loss on segmented demos.

pythondef rollout(env, pi_hl, pi_ll, task, n=20, max_steps=1000):
    o = env.reset()
    for t in range(max_steps):
        if t % n == 0:                   # fixed interval: replan every n steps
            g = pi_hl.sample(o, task)    # subgoal: text, goal image or target state
        a = pi_ll.sample(o, g)           # motor command, e.g. 14 joint targets
        o, done = env.step(a)
        if done:
            return True
    return False

def low_level_loss(pi_ll, obs, acts, goals):
    # segmented demos: one (o, a, g) per step; obs [N, ...], acts [N, act_dim], goals [N, ...]
    return -pi_ll.log_prob(acts, obs, goals).mean()

def high_level_loss(pi_hl, obs, labels):
    # same loss: predict the labelled subgoal g* from the observation
    return -pi_hl.log_prob(labels, obs).mean()

Key papers

PaperIdeaGoal type
Options (1999)Skills with start states and a termination ruleAny
HIRO (2018)Off-policy HRL with goal relabellingState
DIAYN (2019)Skills with no task rewardLatent
Language as an abstraction (2019)Language goals with hindsight relabellingLanguage
SuSIE (2024)An image-editing model as the high levelImage
Yell At Your Robot (2024)High-level DAgger from spoken correctionsLanguage
Hi Robot, π0.5 (2025)Two-level vision-language-action modelsLanguage

Keep going

The takeaway. Split a long task where a check can tell success from failure. Give the subgoal a meaning and each level its own loss. Then test the hand-off, because that is where a hierarchy breaks.
Which design is most likely to give no gain over a flat policy of the same size?

Now press Present or Teach and derive the checkpoint formula from memory, then explain why r = 1 gives the flat policy back. Then go back to the corridor, set 12 rooms, and say why the two-level bar barely moves while the flat bar vanishes.

Credit and source

This lesson re-teaches the lecture Hierarchy in Imitation and Reinforcement Learning of Stanford CS 224R: Deep Reinforcement Learning. The papers behind it: Sutton, Precup and Singh (1999), options; Nachum, Gu, Lee and Levine, HIRO (2018); Eysenbach, Gupta, Ibarz and Levine, DIAYN (2019); Jiang, Gu, Murphy and Finn, language as an abstraction (2019); Black et al., SuSIE (2024); Shi et al., Yell At Your Robot (2024) and Hi Robot (2025); Physical Intelligence, π0.5 (2025). The toys and numbers here are our own.

CS 224R: Hierarchical Policies
The course site · HIRO · SuSIE · Back to Gleams