Inferring Rewards from Behavior

Inverse reinforcement learning reverses the usual RL problem. Standard RL starts with a reward function and asks the agent to find behavior that maximizes it. Inverse RL starts with behavior and asks what reward function would make that behavior sensible.

We rarely articulate our reward functions. Why did a person brake early? Why do doctors choose treatment A over treatment B? Why does an expert pilot fly that trajectory? Behavior reveals preferences, priorities, and constraints. IRL asks: can we infer these?

Forward vs inverse

Which direction is the problem?

Standard RL starts with a reward and derives behavior. Inverse RL starts with behavior and infers the reward that could explain it.

Expert behavior π_E → inferred reward r

Environment
Expert behavior π_E
IRL inference
Reward rr
πE≈arg⁡max⁡πEπ[∑tγtr(st,at)]\pi_E\approx\arg\max_\pi \mathbb{E}_\pi\left[\sum_t \gamma^t r(s_t,a_t)\right]

In the inverse direction, the reward is unknown. Expert trajectories are evidence, and IRL searches for a reward under which the expert's choices look near optimal.

IRL reads trajectories τ_E as evidence about what the expert seems to optimize.

In standard RL, the world gives us the reward. Given environment dynamics, a reward function r(s,a)r(s,a), and discount factor γ\gamma, the agent computes or approximates an optimal policy:

π∗=arg⁡max⁡πEπ[∑tγtr(st,at)]\pi^*=\arg\max_\pi\mathbb{E}_\pi\left[\sum_t\gamma^t r(s_t,a_t)\right]

This is the forward direction: reward →\rightarrow behavior.

In IRL, the reward is unknown. Instead, we observe expert trajectories τE={(st,at)}\tau_E=\{(s_t,a_t)\} and search for a reward under which the expert looks approximately optimal:

πE≈arg⁡max⁡πEπ[∑tγtr(st,at)]\pi_E\approx\arg\max_\pi\mathbb{E}_\pi\left[\sum_t\gamma^t r(s_t,a_t)\right]

The expert's actions should look optimal under the reward we recover. Conceptually, IRL tries to match intentions, or the principles that justify observed actions, rather than merely matching actions.

Behavior as evidence

Trace the demonstration, infer the motive

Tap adjacent cells to sketch what the expert did. Different reward hypotheses become more or less plausible as the path changes.

Steps

6

Wet cells

0

Goal reached

yes

Fast-delivery reward53%
Safety-first reward100%
Inspection reward45%
Inverse RL treats behavior as evidence about reward, not as the reward itself.

The path-tracing activity shows the core inference problem. A short path to the goal might suggest a speed reward. A detour around the wet floor might suggest a safety reward. A stop near the charger might suggest battery management. The observed behavior is evidence, not proof. The same path can be compatible with several objectives.

A common maximum-entropy framing assigns higher probability to trajectories with higher reward while still allowing imperfect behavior.

Equation walkthrough

Trajectory probability under a reward

Click each term to see how MaxEnt IRL turns a reward function into probabilities over demonstrations.

Trajectory probability

how likely this path is under reward R

The model assigns a probability to an entire trajectory tau after choosing a candidate reward function R.

Higher total reward makes a trajectory more likely, but proportionality reminds us that normalization is still needed.

The trajectory τ\tau is the observed sequence of states and actions. The inferred reward RR should make expert demonstrations more likely than alternatives, but the model should not assume the expert is a perfect optimizer in every state.

Why not just use behavior cloning? Behavioral cloning asks, "What action would the expert take here?" It can be simple and stable when the deployment distribution closely matches the demonstrations, but it is brittle outside the demo distribution, can replicate mistakes, has no understanding of why the behavior is good, and learns no reward model that can be re-optimized.

IRL asks, "What objective seems to explain the expert's choices?" If an expert avoids a cliff, behavior cloning learns something like "the expert pressed left here." IRL tries to infer "cliffs are costly." That inferred reward can then be optimized in new states, used to compare alternative policies, adapted to new dynamics, or inspected for alignment problems.

Why not just imitate?

Behavior cloning vs inverse RL

Pick a learning strategy and compare what it captures from demonstrations.

If the expert avoids a cliff, infer: cliffs are costly.

Useful because

Can generalize to unseen states

Can re-optimize with stronger RL methods

Can expose tradeoffs the expert seems to make

Watch out

Reward inference is ambiguous

Needs enough context to separate intent from constraints

Recovered rewards need validation

Behavior cloning matches actions; IRL tries to recover the reward that makes those actions sensible.

If we recover a useful reward, we can do more than replay the demonstrations. We can improve on an imperfect expert, transfer to new dynamics, plan under different constraints, examine what the inferred model values, and detect when the inferred reward is misaligned. This is one reason reward inference sits underneath many modern alignment strategies, including RLHF-style reward modeling.

⚠

Behavior Is Filtered Evidence

Demonstrations reflect objectives, but also constraints, habits, limited information, training, fatigue, and institutional rules. Treating every demonstrated action as direct evidence of preference can bake those limitations into the inferred reward.

ℹ

When IRL Is Useful

Use inverse RL when rewards are difficult to write down, demonstrations are available, and the goal is to recover a transferable objective rather than imitate exact actions. It is especially relevant in robotics, driving, assistive agents, medicine, and alignment settings where human intent is richer than an explicit scalar reward.

Checkpoint

Why can inferring a reward be more useful than simply matching expert behavior?