Offline RL and imitation

Learning a policy from a fixed dataset instead of from interaction: copying an expert (behaviour cloning, DAgger, inverse RL, GAIL) and improving on logged rewards (BCQ, TD3+BC, CQL, IQL, Decision Transformer), how both are evaluated and where they run. A child page of Topic: rl. Data as of October 2026; sources read 4 October 2026. Reading: 34 min, plus 9 in closed details.

The idea in one screen

A learner trained on a fixed dataset fails exactly where it leaves the data: a copy of the expert drifts into states the data never showed (compounding error), and a value maximiser picks actions the data never tried (extrapolation error). Every method on this page is a way of keeping the learner where the data can vouch for it, or of getting new data where it cannot.

Fig. 1 · two ways off the data: along the state axis (imitation) and along the action axis (offline RL)

  1. The data. Each white block is one logged (state, action) pair. The shaded band is the dataset: the states the behaviour visited and, in each, the actions it took. Only inside it can the data check what a learner believes.
  2. Imitation leaves along states. A cloned policy makes a small mistake, lands in a state just outside the band, has no label there and errs again: the states drift away (sections 2 and 3).
  3. DAgger labels the drift. The expert is asked what it would do in the states the learner actually reached (the stream of labels), so DAgger extends the band to the learner's states (section 3).
  4. Offline RL leaves along actions. In a state inside the band, Q-learning asks for maxa Q(s, a). On section 6's toy, the first fit of Q to 30 rewards near a = −0.31 keeps rising past the data, and the max lands on an action nobody tried: a = 1, Q = 3.26, where the true reward (dashed) is −0.44. The network's value there is an unchecked guess (section 6).
  5. CQL pushes values down outside the band. The same fit with CQL's penalty (α = 0.1): Q falls where a maximiser would go and is held up on the data, and the max moves back to a = −0.20 (Q = 0.77), inside the band (section 8).
  6. Or never leave the band. BCQ and TD3+BC keep the policy inside it (the glass walls: the data's mean ± 2 s.d. in this state); IQL never queries outside it, evaluating only the data's own actions (the bright dots on the curve) (sections 7 and 9).

The state axis and the band's shape are a sketch (illustrative); the action slice in steps 4 to 6 is section 6's toy, computed in the page (seed 1). Drag the figure to turn it.

You need: Q-learning, off-policy learning and importance sampling from Model-free prediction and control; overestimation bias and replay from Value-based deep RL; TD3, SAC and TRPO from Policy gradients and actor-critic (the offline methods are built on them). The vocabulary (state, action, return, value, policy) is on the parent Topic: rl.

Behaviour policy πβ
whatever produced the data: one controller, many people, a mixture of old systems, often unknown.
Behaviour cloning (BC)
supervised learning from states to the logged actions.
Compounding error
the learner's mistakes move it to states outside its training data, where it makes more mistakes.
Extrapolation error
a value function's error at actions the data does not contain, which the max in a Bellman target selects and bootstrapping spreads.
Stitching
joining pieces of different logged trajectories into one route none of them took; needs dynamic programming.
Occupancy measure
the discounted distribution of (state, action) pairs a policy produces.
Return-to-go R̂t
the sum of rewards from step t to the end of the episode.
Off-policy evaluation (OPE)
estimating a policy's value from logs, without running it.
MethodLearns fromNeeds during trainingAnswer to the failureSection
Behaviour cloningExpert (state, action) pairsNothing elseNone: errors compound, up to T²ε over T steps2
DAggerExpert labels on the learner's own statesAn expert to query, environmentTrain on the states the learner actually reaches: Tε plus recovery3
Inverse RL (max-margin, MaxEnt)Expert trajectoriesEnvironment or model (an RL inner loop)Recover the reward, then plan: the whole trajectory is judged, not each step4
GAIL, AIRLExpert trajectoriesEnvironment (on-policy RL)Match the expert's state-action distribution with a discriminator as reward4
Learning from preferencesComparisons between behavioursA rater, environmentFit a reward to the comparisons, then RL: the road to RLHF5
BCQ, BEAR, TD3+BC(s, a, r, s′) with rewardsNothing elseKeep the policy on the data's actions7
CQL(s, a, r, s′)Nothing elsePush values down off the data: a lower bound8
IQL, AWR(s, a, r, s′, a′)Nothing elseNever evaluate an action outside the data9
Decision Transformer, RvSTrajectories with returnsNothing elseNo value function: predict the action given the return asked for10
Cal-QL, RLPDA dataset, then interactionEnvironment, laterStart from the data, then fix the mistakes online11

Rows jump to their section. The parent's Taxonomy tab sets online, off-policy and offline side by side, and its Method atlas places behaviour cloning, GAIL, CQL, IQL and Decision Transformer among 47 methods. The two replays below (Fig. 2, behaviour cloning against DAgger; Fig. 3, one dataset through four offline learners) are computed exactly in the page and equal an independent Python implementation on 32,948 values (src/recompute.py); the D4RL results tab holds the benchmark's numbers as printed.

1The setting: a fixed dataset, no interaction

An offline (or batch) learner receives a dataset D = {(si, ai, ri, s′i)} collected by a behaviour policy πβ and must output a policy without collecting anything more (Levine, Kumar, Tucker and Fu 2020; the older name "batch RL" and fitted Q iteration go back to Ernst, Geurts and Wehenkel 2005). Why bother: in medicine, driving, robotics on expensive hardware and recommendation, trying random actions is dangerous, slow or costly, while logs of past decisions are plentiful; offline RL is the attempt to give decision-making deep learning's recipe of large fixed datasets.

Three distinctions are easy to blur. Off-policy means learning about one policy from data produced by another; Q-learning and DQN are off-policy but still online, because they keep collecting data with their current policy (Model-free prediction and control, Value-based deep RL). Offline removes the collection entirely: the policy that would fix its own mistakes by trying them never gets to. And imitation differs from offline RL in what the data must contain: imitation needs good behaviour and no reward; offline RL needs rewards and can use poor behaviour, in principle stitching pieces of mediocre trajectories into a better one (which D4RL's maze datasets were built to test; Fu et al. 2020).

2Behaviour cloning, and why its errors compound

Behaviour cloning maximises Σi log π(ai | si) over expert pairs (or minimises squared error for continuous actions). It is the oldest method here: ALVINN steered a vehicle from camera images with a small network trained on a person's driving (Pomerleau 1988). It is also the most used: supervised fine-tuning of a language model on demonstrations is behaviour cloning on tokens (Alignment: SFT, RLHF, DPO Family, RLVR), and large robot policies are mostly BC with expressive models: RT-1 was trained on about 130,000 demonstration episodes collected by 13 robots over 17 months and performs over 700 training instructions at 97% success (Brohan et al. 2022); Diffusion Policy reports an average improvement of 46.9% over prior methods across 12 manipulation tasks by modelling multimodal action distributions (Chi et al. 2023).

The trouble: supervised learning assumes test inputs come from the training distribution. Training states come from the expert's distribution dπ*; at test time the learner visits dπ, the states its own actions lead to. NVIDIA's end-to-end driving paper says it plainly: "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" (Bojarski et al. 2016, §5). Their fix was data augmentation: images from left and right cameras, and synthetic shifts and rotations, labelled with the steering that would return to the lane.

A number first. A learner wrong on 2% of the expert's own states (ε = 0.02) over T = 60 steps: if its errors did not change its inputs, it would expect 60 × 0.02 = 1.2 bad steps. Because each slip moves it off the data, the bound is T²ε = 72, and the exact cost on the task below is 25.5 steps out of lane.

J(π) ≤ J(π*) + T² ε
J(π)
expected total cost of the learner over T steps, with each step's cost in [0, 1]
ε
the learner's error rate (0-1 loss) on the expert's own state distribution: what supervised learning controls
T²
the price of distribution shift: a mistake at step t can cost up to every remaining step

That is Ross and Bagnell's bound for behaviour cloning (Ross, Gordon and Bagnell 2011, Theorem 2.1; first proved in Ross and Bagnell 2010). The intuition is a sum: a first mistake at step t happens with probability about ε and can cost up to T − t afterwards, so the total is about Σt ε (T − t) ≈ εT²/2. A learner whose errors did not change its inputs (ordinary classification) would pay only Tε.

Predict, then watch. Both learners in Fig. 2 make the same 2% of mistakes on the expert's states. After DAgger's five rounds, will its cost at T = 60 be about half of behaviour cloning's 25.5, or a tenth?

Fig. 2 · the same slip: behaviour cloning drifts off the road, DAgger has labels for where the slip leads and comes back

  1. The labels each learner has. The expert steers back to its lane and straightens up, so its own data never leaves the centre: behaviour cloning has 1 of the 27 states (lane by heading, the tiles behind each road) labelled, and copies that label, "straight", everywhere else. DAgger's 5 rounds ran the learner, had the expert label every state it visited (the stream) and retrained: 15 of 27, including the states a slip leads to.
  2. Steps 1 to 10: the first slips. Both learners are wrong with probability ε at every step. Bars are the exact probability of each lane, blue where the learner has a label for its state, red where it has none. P(out of lane) at step 10: 0.183 for cloning, 0.040 for DAgger.
  3. Steps 11 to 25: a slip becomes permanent. On a state without a label, "straight" keeps the car drifting, so cloning's red spreads across the road: 40% of its probability sits on unlabelled states at step 25. DAgger's stays at 0.040 out of lane: each slip is corrected within a few steps.
  4. Steps 26 to 40: the costs part. Expected cost so far (Σ P(out of lane)): 12.83 for cloning against 1.58 for DAgger.
  5. Steps 41 to 60: the bill. Over T = 60, cloning pays 25.55 steps out of lane, under the bound εT² = 72; DAgger pays 2.38, about 2εT = 2.4, where εT = 1.2 is what errors would cost if they did not move the inputs.

Set DAgger rounds to 2: one round of the learner's own data covers only the side it happened to drift to, and the cost barely falls (21.9 against 25.5 at ε = 0.02, T = 60); from round 3 it is 2.4. The ball is one sampled car (the same draws for both learners). The task is illustrative; how it is built is in the closed block below.

How the driving task and the two learners are built 1 min

Nine lanes, the car's own lane in the middle; each step the action turns the heading left, keeps it, or turns it right, and the car moves one lane per step of heading. The expert steers back to its lane and straightens up, so its own data never leaves the centre state and its cost is 0. Cost: 1 for every step outside the car's lane. The learner predicts the expert's label at the nearest state it has data for and is wrong with probability ε at every step (ε is exactly its error on the expert's states). DAgger: round 1 is the expert's data (so its policy is behaviour cloning); each later round rolls out the current learner 5 times, has the expert label every state visited, and retrains on everything (Ross et al. 2011, Algorithm 3.1 with βi = I(i = 1)). The state distribution is propagated exactly (seed fixed for the sampled car and the DAgger rollouts); the page's engine equals an independent Python implementation on 32,948 values (src/recompute.py).

The same failure in language models is exposure bias: a model trained to predict the next token given the true previous tokens must, at generation time, condition on its own outputs, "as errors may accumulate along the way" (Ranzato et al. 2015). On-policy distillation is the DAgger answer: the student generates, the teacher labels the student's own sequences (Agarwal et al. 2023, GKD). RL fine-tuning after SFT is another, since the model is then trained on its own samples (RL for LLMs).

The bound is tight under 1 min

Ross, Gordon and Bagnell give a problem where J(π̂) = (1 − εT) J(π*) + T²ε, so no better guarantee is possible for behaviour cloning in general: the quadratic is the real price of training on the expert's states and testing on the learner's.

3DAgger: label the states the learner actually reaches

If training states come from the expert and test states from the learner, train on the learner's states. DAgger (Dataset Aggregation; Ross, Gordon and Bagnell 2011) does this iteratively; Fig. 2 runs it:

D ← expert demonstrations; π̂₁ ← train on D for i = 1 … N: π_i ← β_i π* + (1 − β_i) π̂_i (β₁ = 1, then usually 0) run π_i, record the states it visits ask the expert for its action at every one of those states D ← D ∪ {(s, π*(s))}; π̂_{i+1} ← train on all of D return the best π̂ on validation

The guarantee changes from quadratic to linear: J(π̂) ≤ J(π*) + uTεN + O(1), where εN is the error on the learner's own state distribution and u bounds how much worse the cost-to-go gets after one non-expert action (the cost of recovering; Theorems 3.1 and 3.2). In Super Tux Kart, behaviour cloning did not improve with more expert laps, "because most of the training laps are all very similar and do not help the learner to learn how to recover from mistakes", while DAgger's policy "never falls off the track after 15 iterations of training" (§5.1).

Its price is the expert. DAgger needs an expert who can be asked "what would you do here?" in states the expert would never have reached, and needs the environment to run the learner. That is cheap for a planner, a search procedure or a stronger model (teacher-student distillation), and awkward for people: labelling while not in control is unnatural, so variants let the human take over only when needed and learn from the takeovers (HG-DAgger, Kelly et al. 2018). When the learner predicts something the recording already holds, the recording can be the expert. WorldTUI, a 360M model trained to imitate a terminal, rolls out 1 to 4 events on its own screens from a point in a recorded session and trains on the edit from its wrong screen back to the recorded one, keeping a correction only if its words had already appeared on screen or in the typing, so it is never rewarded for inventing what it could not know (one author's small tests; WorldTUI). When neither the expert nor the environment is available again, the remedies are offline: augment the data with perturbed states labelled by recovery actions (NVIDIA's shifted cameras), inject noise into the expert's actions while collecting so the data shows recoveries (DART, Laskey et al. 2017), or reason about the whole trajectory (section 4).

Why the analysis works: a reduction to no-regret online learning under 1 min

With enough rounds (N of order T up to log factors), some policy in the sequence has error εN on its own state distribution, the best achievable by the policy class on the aggregated data. Each round is a new loss function (the new states), and training on all data so far is Follow-The-Leader, a no-regret algorithm; no-regret over the rounds is what turns the per-round errors into the linear bound.

Behaviour cloning's cost grows like T² until a slip is near-certain; DAgger's grows like T

Exact expected cost J at ε = 0.02 (log-log) of behaviour cloning and of DAgger after 8 rounds (rollouts of length T), against the lines εT² (Ross and Bagnell's bound, with J* = 0 here) and εT. From T = 5 to T = 40 behaviour cloning's cost rises 44 times for 8 times the horizon, then bends back to slope 1 once almost every remaining step is out of the lane. DAgger stays at about 2εT: each slip costs about two steps out of lane before the correction (Ross et al.'s recovery constant u ≈ 2).

4Inverse RL and GAIL: judge whole trajectories, at the price of an RL loop

Behaviour cloning copies actions one step at a time. Inverse reinforcement learning asks what reward the expert is optimising. Given that reward, planning or RL produces a policy that judges whole trajectories, so a learner that has drifted still knows where it should be heading; the reward is also the more transferable thing, describing the task rather than one way of doing it in one environment.

The problem is ill-posed. Ng and Russell (2000) set it up for a known MDP and observed optimal behaviour and noted the degenerate answer first: R = 0, under which every policy is optimal, explains any behaviour. Their fix was a heuristic: among the rewards that make the expert optimal, pick the one that makes the expert's action beat the next-best action by the largest margin, with a penalty favouring simple rewards. Every IRL method since is a choice of which reward to prefer, run inside the same loop (right):

  • Feature matching (Abbeel and Ng 2004). With a reward linear in known features, R(s) = w·φ(s), a policy's value is w·μ(π), where μ(π) = E[Σt γt φ(st)] are its feature expectations. Match the expert's feature expectations within ε and the value is within ε for every such reward, so the true reward need never be identified.
  • Maximum entropy IRL (Ziebart et al. 2008). Among path distributions that match the expert's feature counts, take the least committed: P(ζ) ∝ exp(θ·fζ), so better paths are exponentially more likely but every path has some probability. They learned the route preferences of 25 Yellow Cab drivers from over 100,000 miles of GPS traces.
  • GAIL (Ho and Ermon 2016). RL on the reward found by maximum-causal-entropy IRL is the same as finding the policy whose occupancy measure ρπ(s, a) is closest to the expert's, up to an entropy term (their Proposition 3.2; the same object as the linear-programming view of MDPs on Dynamic programming). Matching distributions is a two-sample problem, which a GAN-style discriminator solves, so the reward never needs to be written down.
Eπ[log D(s, a)] + EπE[log(1 − D(s, a))] − λ H(π)
D(s, a)
discriminator: trained to tell the policy's pairs (high) from the expert's (low)
π
policy: updated with TRPO steps using log D(s, a) as its cost, so it is pushed toward pairs the discriminator mistakes for expert ones
λ H(π)
causal entropy bonus, from the maximum-entropy derivation

Because GAIL matches distributions over whole trajectories rather than single actions, it does not compound errors the way behaviour cloning does: on Humanoid, behaviour cloning never exceeded 60% of expert performance while GAIL matched the expert at every dataset size tested; on Reacher, behaviour cloning was the more data-efficient. But GAIL is not offline: its environment interaction "was comparable to the number needed for TRPO to train the expert policies from reinforcement signals", against behaviour cloning's zero (§6 and §7). The cost of the whole family is that inner RL problem, which is why inverse RL is mostly used where dynamics are known or cheap to simulate (route planning, robot footstep planning, driver modelling).

Details of each method, and GAIL's successors 2 min

Apprenticeship learning alternates a max-margin step (find the w with ‖w‖ ≤ 1 under which the expert most beats the policies so far) with an RL step (find the best policy for that w). Maximum margin planning (Ratliff, Bagnell and Zinkevich 2006) casts the same idea as structured prediction: the expert's path must beat every other path by a margin that grows with how different that path is.

MaxEnt IRL's likelihood gradient is the expert's feature counts minus the model's expected feature counts, which needs a soft planning pass (a soft-max version of value iteration) per gradient step. The causal-entropy version handles stochastic dynamics and is the form later deep methods build on. Deep IRL replaces the planning pass with sampling from a policy that is itself being optimised: guided cost learning (Finn, Levine and Abbeel 2016), which leads directly to the adversarial methods.

GAIL's objective, with the Jensen-Shannon form of the regulariser, is the JS divergence between the two occupancy measures minus λH(π) (their Equation 15); ρπ(s, a) = π(a|s) Σt γt P(st = s | π). The paper found GAIL "generally quite sample efficient in terms of expert data"; the parent's Method atlas lists its data as "On-policy (TRPO steps) plus fixed demonstrations".

Successors fix one weakness each. AIRL structures the discriminator so that it recovers a reward that still works when the dynamics change (Fu, Luo and Levine 2017). ValueDICE rewrites the distribution-matching objective so that it can be optimised off-policy, from replay data (Kostrikov, Nachum and Tompson 2019). IQ-Learn learns a single soft Q-function from which both the reward and the policy follow, avoiding the adversarial game (Garg et al. 2021).

Every method here runs an RL problem inside each reward update; that inner loop is why none of them is offline

The expert's demonstrations are fixed. Each outer step fits a reward (or a discriminator) that separates the expert from the current policy, then improves the policy against it, which needs the environment or a model of it. The methods differ in what is compared: feature expectations (apprenticeship learning), the likelihood of paths under a maximum-entropy model (MaxEnt IRL), or a classifier's output (GAIL).

5Learning from preferences: the bridge to RLHF

Inverse RL infers a reward from what an expert does; preference learning infers it from what a person prefers between two behaviours, which is easier to give and possible for tasks the rater cannot perform. Christiano et al. (2017) showed a non-expert two short clips, asked which was better, fitted a reward model with the Bradley-Terry model, and trained the policy by RL on it while collecting more comparisons on its newest behaviour. It solved Atari games and MuJoCo locomotion "while providing feedback on less than one percent of our agent's interactions with the environment", and taught the Hopper to backflip from 900 queries in less than an hour, a behaviour no one had a reward function for.

That recipe with a language model as the policy is RLHF (InstructGPT); DPO removed the RL loop by training on the preference pairs directly, which makes it an offline preference method in exactly this page's sense (DPO). This page stops at the bridge: the reward model's loss and its failure modes are on Alignment: SFT, RLHF, DPO Family, RLVR (section 2, Reward models), PPO, GRPO and verifiable rewards on RL for LLMs, and over-optimising a learned reward on Reward Hacking.

Where each LLM training stage sits on this page's map

Supervised fine-tuning is behaviour cloning (section 2), with exposure bias as its compounding error. A reward model fitted to preferences is preference-based reward learning (this section). DPO is offline learning from fixed preference pairs; online RLHF and RLVR are online RL. Rejection sampling and best-of-n fine-tuning (train on the model's own highest-scoring samples) are filtered behaviour cloning, the same idea as the "10% BC" baseline in section 10.

Christiano et al.'s reward model, written out under 1 min

For two segments σ¹ and σ², the probability that σ¹ is preferred is exp Σ r̂ over σ¹ divided by the sum of that and exp Σ r̂ over σ²; r̂ is trained by cross-entropy on the human's choices.

6Offline RL's problem: distributional shift and extrapolation error

Offline RL keeps the rewards and asks for more than imitation: a policy better than the one that collected the data. The natural tool is off-policy Q-learning, which in principle learns the optimal Q from any data. In practice it fails, and the reason is in its target:

Q(s, a) ← r + γ maxa′ Q(s′, a′)
maxa′
queries Q at actions a′ that may never appear with s′ in the data
Q(s′, a′)
for such actions, whatever the function approximator extrapolates; no sample ever corrects it

Online, a wrongly high value gets tried, disappoints and is corrected. Offline it never gets tried. The max picks out exactly the actions whose errors happen to be positive, bootstrapping copies those values into every state that leads there, and the policy heads for actions nobody has tested. Fujimoto, Meger and Precup (2019) called this extrapolation error, "introduced by the mismatch between the dataset and true state-action visitation of the current policy": an off-policy actor-critic (DDPG) trained on a million transitions collected by a trained expert "quickly learns to take non-expert actions, under the guise of optimistic extrapolation. As a result, the value estimates rapidly diverge and the agent fails to learn". Kumar et al. (2019) named the propagated version bootstrapping error, which "accumulates via the Bellman backup operator". It is overestimation bias (Value-based deep RL has Double DQN's version) in its worst form: online, the noise is around actions that are tried; offline, around actions that never will be.

Predict, then play. The data in Fig. 3 holds 30 actions, all near a = −0.35; the best action is at 0.15 and worth 10. After 40 iterations of plain fitted Q iteration, where will the policy act, and will its believed value be above or below 10? Then watch.

Fig. 3 · naive fitted Q iteration

  1. The data and the truth. Thirty actions from a narrow behaviour policy (white pillars); always taking a is worth r(a)/(1 − γ) (dashed; best 10 at a = 0.15). Q starts at 0 everywhere, so the policy (bars on the floor) is uniform over all actions.
  2. Iteration 1: the fit leaves the data rising. Q is fitted to the 30 rewards; past the data the ReLU fit extrapolates linearly, upward to the right, and the policy (∝ exp(βQ)) jumps to a = 1, where nobody acted. It believes it is worth 2.94; following it is really worth −0.14.
  3. Iterations 2 to 5: the max feeds itself. Each target is ri + γ × (the believed value of the next state); the stream carries that value back into every data point, so the whole curve rises and the right edge with it: believed 12.03 at iteration 5.
  4. Iterations 6 to 40: nothing contradicts the edge. The fitted line keeps rising past the data, the policy stays at a = 1, and the believed value climbs past 25 (28.94) while the true value of what it does stays below 0 (−0.14).
  5. Believed against true. The gap between the two balls is extrapolation error spread by bootstrapping: the learner's favourite action is worse than simply repeating the behaviour policy (5.46) or than the best action inside the data's range (9.12).

One state, an action a in [−1, 1], reward r(a) = 1 − 2(a − 0.15)², γ = 0.9, so always taking a is worth r(a)/(1 − γ) (dashed curve; best 10 at a = 0.15). The 30 data actions come from a narrow behaviour policy N(−0.35, 0.12²). Depth is the iteration of fitted Q iteration (square-root spacing, the newest in front); for the other learners the grey line is the naive learner at the same iteration. Each learner's steps are in its own section; a click on one switches the figure. The task is illustrative; its construction is in the closed block below.

How the four learners are built, and the original paper's experiments 1 min

The rewards in the data carry noise of s.d. 0.1. Q is a ReLU network with its first layer frozen (21 fixed features, ridge 10⁻³), so every fit is solved exactly and the extrapolation outside the data is linear, as a ReLU network's is. Each iteration fits targets ri + γ·(value of the next state). The value of the next state is the policy's expected Q, where the policy is ∝ exp(β Q) over all actions (naive, CQL), over actions within two standard deviations of the data's mean (BCQ-style, the shaded band; a fitted Gaussian stands in for BCQ's generative model), or, for IQL, the τ-expectile of Q over the dataset's own actions, with the policy extracted by advantage weights exp(β(Q − V)) on those actions. CQL adds α·((1/β) log Σ exp(β Q) − mean of Q on the data) to every fit: CQL(H), with its soft maximum taken at the policy's temperature so that the distribution pushed down is the policy itself (μ = π, the case of CQL's Theorem 3.2). Checked against an independent Python implementation (src/recompute.py).

In Fujimoto et al.'s experiments, even an agent trained on exactly the data of a behavioural agent learning alongside it ("concurrent") did much worse than that agent: the same data, without the ability to try its own actions, is not enough.

7Policy constraints: stay on the data's actions (BCQ, TD3+BC)

The first family attacks the max directly: if the policy only ever chooses actions the data contains, Q is only ever queried where data can correct it. BCQ (batch-constrained Q-learning; Fujimoto, Meger and Precup 2019) fits a generative model of the data's actions (a conditional VAE), samples n actions from it in each state, lets a small perturbation network nudge each within [−Φ, Φ], and takes the one with the highest Q (their Equation 11). The two knobs interpolate between imitation and RL: "If Φ = 0, and the number of sampled actions n = 1, then the policy resembles behavioral cloning and as Φ → amax − amin and n → ∞, then the algorithm approaches Q-learning". The BCQ-style learner in Fig. 3 is this idea with a Gaussian in place of the VAE.

Fig. 3 · the BCQ-style learner (section 7)

  1. The same data, one rule more. The policy may only choose actions within two standard deviations of the data's mean (the glass strip on the floor); a fitted Gaussian stands in for BCQ's generative model.
  2. Iteration 1. The fit is naive's (grey line), but the max is taken inside the strip: the policy moves to a = −0.06; believed 0.79, true 7.31.
  3. Iterations 2 to 5. Bootstrapping still feeds the believed value back, but only values the data can check: believed 3.24.
  4. Iterations 6 to 40. Outside the strip Q is still wrong (the grey naive curve keeps rising) but never used: believed 7.80, true 7.31.
  5. Believed against true. Close, and above the behaviour policy's 5.46: a real improvement, capped by the strip, whose best action is worth 9.12.

TD3+BC (Fujimoto and Gu 2021) asks how little needs to change. Its whole method is one line in the actor's loss of the online algorithm TD3, plus normalising the states:

π = argmaxπ E(s, a)∼D [ λ Q(s, π(s)) − (π(s) − a)² ], λ = α / meani |Q(si, ai)|, α = 2.5
λ Q(s, π(s))
TD3's usual objective, rescaled by the average size of Q so that α means the same thing on every task
(π(s) − a)²
a behaviour-cloning term pulling the action toward the data's action in that state

It "compares favorably against many offline RL algorithms, while being significantly easier to implement and more than halving the required computation cost". The lesson the field took: much of offline RL's progress was tuning and implementation, and a strong simple baseline is required in any comparison. ReBRAC (Tarasov et al. 2023) revisited this minimalist approach with a handful of further design choices and is the strongest average performer in CORL's reruns (D4RL results tab).

The limit of every constraint is that it ties the policy to the behaviour: the tighter, the safer and the less improvement. When the data has to be stitched, a policy kept near each state's logged actions cannot follow the joined route. In CORL's reruns on AntMaze's medium and large mazes, TD3+BC scores between 0 and 0.25, against 20.5 to 67.25 for CQL and 30.25 to 73.75 for IQL (normalised score of the last policy, 4 seeds; Tarasov et al., Table 1).

Support against distribution: BEAR and BRAC, and TD3+BC's table of changes under 1 min

BEAR (Kumar et al. 2019) argues that matching the behaviour policy's distribution is too strict when the data comes from a poor, noisy policy, and constrains only its support: "restrict the support of the learned policy, but not the probabilities of the actions lying within the support", enforced with a sampled maximum mean discrepancy (MMD) penalty. BRAC (Wu, Tucker and Nachum 2019) puts the divergence to the behaviour policy either into the value target or into the policy loss and compares the choices. TD3+BC's Table 1 lists the many changes other offline methods make to their base algorithms, each with its own hyperparameters.

8Conservative values: CQL

Instead of restricting the policy, Conservative Q-learning changes what Q means: it learns a Q-function whose values are a lower bound on the true ones, so maximising it is safe because nothing is overestimated (Kumar, Zhou, Tucker and Levine 2020). Fig. 3 runs it (switch to CQL; its steps are below the theorem). The regulariser is added to the ordinary Bellman error:

minQ α ( Es∼D, a∼μ(a|s)[Q(s, a)] − E(s, a)∼D[Q(s, a)] ) + ½ E(s, a, s′)∼D[(Q(s, a) − B̂πQ̂k(s, a))²]
Eμ[Q]
pushes Q down on actions drawn from μ, a distribution chosen to find high values (in CQL(H), μ ∝ exp Q, which turns the term into a soft maximum, log Σa exp Q(s, a))
− ED[Q]
pushes Q back up on the actions in the data, so only the gap is penalised
α
the strength of the conservatism

With both terms, Q is not a pointwise lower bound (values of the data's own actions can be too high), but the policy's value Eπ[Q̂] is a lower bound on its true value when μ = π (Theorem 3.2). CQL reported "2-5 times higher final return" than prior offline methods, especially on datasets mixing several policies. Set α to 10 in Fig. 3 and the policy collapses onto the behaviour, both numbers settling at its 5.5: over-conservatism is CQL's failure mode, and α cannot be tuned without evaluating policies somewhere. CORL's reruns found "CQL is extremely sensitive to the choice of hyperparameters and implementation details", needing, for example, five hidden layers in the critic on AntMaze but not elsewhere (Tarasov et al. 2022, Observation 3).

Fig. 3 · CQL (section 8)

  1. The same data, a penalty. Every fit adds α((1/β) log Σ exp(βQ) − mean of Q on the data): Q is pushed down wherever the policy would put weight and pushed up on the data's own actions.
  2. Iteration 1. The curve now falls away past the data's right edge, and the policy moves to a = −0.20; believed 0.53, true 6.36.
  3. Iterations 2 to 5. The values grow only where the data supports them: believed 2.17.
  4. Iterations 6 to 40. The believed value settles at 5.21, below the true 6.36: a lower bound (Theorem 3.2 with μ = π).
  5. Believed against true. A real improvement found without trusting any value off the data: the true value beats the behaviour policy's 5.46. Set α to 10 and both numbers settle near 5.5: the policy has collapsed onto the behaviour.
The two theorems, Q-Transformer, and model-based pessimism (MOPO, MOReL) 1 min

The paper proves two bounds. With only the push-down term (its Equation 1), the learned Q is below the true Qπ at every state and action, for α large enough relative to the sampling error (Theorem 3.1). With both terms (Equation 2), the bound holds for the policy's value only, and is tighter (Theorem 3.2). In Fig. 3 the Theorem 3.2 bound holds in every run at β = 1 and at the defaults, by construction of the setting (the soft maximum is taken at the policy's temperature); at α = 10 it is within the noise of 30 rewards (up to about 0.3 above).

The idea scales: Q-Transformer trains a Transformer Q-function offline on real robot data with a conservative regulariser that "pushes down the Q-values Q(s, a) for any action a outside of the dataset" (Chebotar et al. 2023). A model-based relative uses the same pessimism with a learned dynamics model: MOPO subtracts an uncertainty penalty from the model's rewards, and MOReL builds a pessimistic MDP that ends episodes where the model is unsure (Yu et al. 2020; Kidambi et al. 2020). Learned models and their exploitation are on Model-based RL and planning.

9In-sample learning: IQL and advantage-weighted regression

The third family never asks about an action outside the data at all. The simplest version is SARSA on the dataset: bootstrap from the action actually taken next, Q(s, a) ← r + γQ(s′, a′), which evaluates the behaviour policy without extrapolating; one step of policy improvement on top of that value is already a strong method (Brandfonbrener et al. 2021, "Offline RL Without Off-Policy Evaluation"). The question is how to get more than one step of improvement without leaving the data.

Implicit Q-learning (Kostrikov, Nair and Levine 2021) answers with expectile regression. The τ-expectile of a set of numbers minimises an asymmetric squared loss, L2τ(u) = |τ − 1(u < 0)| u²: at τ = 0.5 it is the mean, and as τ → 1 it approaches the maximum.

The expectile slides from the mean of the data's action values to their maximum, without ever looking at an action outside the data

Dots: Q (vertical) at each of the 30 data actions (horizontal) of Fig. 3, from the IQL learner's final fit (seed 1, τ = 0.9, β = 3), each drawn at its action. The line is the τ-expectile of those 30 numbers, computed exactly. Predict before dragging: where is the line at τ = 0.5, and can any τ lift it to the true optimum of 10, which sits at an action off the data?

IQL fits a state value V(s) to that upper expectile of Q(s, a) over the dataset's actions, then fits Q(s, a) to r + γV(s′). At τ = 0.5 this is SARSA; as τ → 1 it approaches Q-learning's max restricted to actions the data contains (their Equation 4), so it "never needs to evaluate actions outside of the dataset". The policy is extracted afterwards by advantage-weighted regression: behaviour cloning in which each logged action is weighted by exp(β(Q(s, a) − V(s))), so better-than-average actions are copied more; small β is plain cloning, large β approaches the best in-data action. The paper's settings: τ = 0.7 and β = 3 on locomotion, τ = 0.9 and β = 10 on AntMaze, where the larger expectile is "crucial" for stitching.

Fig. 3 runs IQL on the same data (switch to IQL; its steps are below). Every loss is a regression on dataset samples, so these methods inherit the stability of supervised learning; in CORL's reruns IQL, AWAC and ReBRAC are "the strongest offline baselines on average" (Observation 1).

Fig. 3 · IQL (section 9)

  1. The same data, only its own actions. The next state's value is the τ-expectile of Q over the 30 data actions (τ = 0.9), so Q is never queried anywhere else; the policy reweights the data's actions by exp(β(Q − V)).
  2. Iteration 1. The policy lives on the data actions (bars at the pillars), most likely a = −0.09; believed 0.73, true 6.92.
  3. Iterations 2 to 5. The expectile lifts the target above the average of the data's values without reaching past them: believed 3.11.
  4. Iterations 6 to 40. The extrapolated edge exists but nothing ever reads it: believed 7.55, true 6.92.
  5. Believed against true. Close, and above the behaviour policy's 5.46. Raise τ toward 0.99 and the believed value climbs toward the highest Q among the data's actions (8.8 on seed 1), while the policy still never leaves the data.
Where the weighting comes from: AWR and AWAC under 1 min

The weighting comes from AWR (Peng et al. 2019), two supervised regressions (a value function, then weighted action regression), and AWAC (Nair et al. 2020), which uses a Q-function critic and was designed for fine-tuning online after offline training.

10Sequence modelling: Decision Transformer, and when it works

Decision Transformer (Chen et al. 2021) drops value functions entirely. Each trajectory becomes a sequence of triples (R̂t, st, at), where R̂t = Σt′ ≥ t rt′ is the return-to-go, and a causal GPT-style Transformer predicts each action from the last K triples (K = 30 on Atari). At test time you ask for a return: feed the desired R̂ first, act, subtract each reward received, and continue (right).

It "matches or exceeds the performance of state-of-the-art model-free offline RL baselines on Atari, OpenAI Gym, and Key-to-Door tasks", and longer contexts helped (K = 1 was "significantly worse"). Four results then narrowed what return conditioning buys:

  • Filtered cloning does as well on D4RL. The paper's own "Percentile Behavior Cloning" clones only the top X% of timesteps by episode return; with plentiful data "we find %BC can match or beat other offline RL methods", with DT "competitive with the performance of the best %BC" (§5.1). DT's advantage showed in low-data Atari. The 10% BC column in the D4RL results tab is this baseline.
  • A small MLP is enough. RvS (Emmons et al. 2022): "simply maximizing likelihood with a two-layer feedforward MLP is competitive with state-of-the-art results of substantially more complex methods based on TD learning or sequence modeling with Transformers".
  • It needs near-determinism and return coverage, and cannot stitch. Brandfonbrener et al. (2022) prove that return-conditioned supervised learning recovers a near-optimal policy only under assumptions "stronger than those needed for the more traditional dynamic programming-based algorithms", and that such methods "cannot perform stitching in general, even with infinite data".
  • It confuses luck with skill. In a stochastic environment a high-return trajectory may be high-return by chance; conditioning on its return asks the policy to repeat the lucky actions (Paster, McIlraith and Ba 2022, "You Can't Count on Luck"). Their fix, ESPER, conditions on the average return of clusters of trajectories instead.

The working summary: sequence models are a strong way to imitate selectively from large, mostly good, near-deterministic data, and a weak way to improve on data that must be recombined, where dynamic programming (CQL, IQL) still wins. Kumar et al. (2022) draw the same line between offline RL and behaviour cloning generally: offline RL wins with sparse rewards, "critical" states where a few decisions matter, long horizons and noisy data, and "policies trained on sufficiently noisy suboptimal data can attain better performance than even BC algorithms with expert data".

Precursors, and what RvS found matters under 1 min

Conditioning an action model on an outcome came earlier as upside-down RL and reward-conditioned policies, and Trajectory Transformer (Janner, Li and Levine 2021) modelled whole trajectories and planned with beam search. RvS found that what matters is model capacity and what to condition on (a goal or a return), not the Transformer. Brandfonbrener et al.'s assumptions are near-deterministic dynamics and data that actually reaches the return being asked for.

Training reads returns off the data; at test time the return is a request, reduced by each reward received

Top: one logged trajectory as tokens; the Transformer sees everything to the left of each action token and is trained to predict that action. Bottom: at test time the first token is the return asked for (90 here, illustrative), and after each reward the next token is what is still owed. The model only interpolates among returns the data reached: asking for more than the data contains does not make the policy better.

11Offline to online: start from the data, then interact

The purest offline setting is rare; more often a dataset exists and some interaction is allowed later. Pretraining offline then fine-tuning online is less natural than it looks: Nakamoto et al. (2023) note the "counter-intuitive trend: policy initializations obtained from more effective offline RL methods tend to exhibit worse online fine-tuning performance", and identify an unlearning dip: a conservative Q-function's values are too low, so the first online updates spend themselves raising them and the policy gets worse before it gets better. Cal-QL keeps CQL's lower bound but stops values from falling below a reference policy's (the behaviour policy's) value: "calibrated", "a one-line code change" to CQL, better than prior methods on 9 of 11 fine-tuning tasks.

The opposite route also works: run an ordinary online off-policy method with the offline data mixed in. RLPD (Ball, Smith, Kostrikov and Levine 2023) trains SAC from scratch with "symmetric sampling", each batch half offline data and half online replay, plus layer normalisation in the critic (which "can bound the extrapolation of networks" without constraining the policy to the data) and large ensembles, reporting "a 2.5× improvement over existing approaches" with no offline pretraining at all.

How much online fine-tuning adds, in CORL's reruns under 1 min

On AntMaze (6 datasets, 1 million offline then 1 million online steps), the average normalised score moved from 48.4 to 95.6 for CQL, 56.3 to 78.5 for IQL, 53.0 to 97.3 for Cal-QL and 18.1 to 16.5 for AWAC (Tarasov et al., Table 3; per-dataset values in the D4RL results tab).

12Evaluation: D4RL, and off-policy evaluation

D4RL (Fu et al. 2020) is the benchmark nearly every paper above reports: locomotion datasets of graded quality, mazes that need stitching, a dexterous hand with few human demonstrations, and multitask kitchen data (the closed block below lists them). Scores are normalised so that 0 is a uniformly random policy and 100 a domain expert (a SAC agent on Gym-MuJoCo):

normalised score = 100 × (score − random score) / (expert score − random score)
Hopper
random −20.27, expert 3,234.3 (the reference values in D4RL's infos.py), so a raw return of 1,600 is 100 × 1,620.27 / 3,254.57 = 49.8

Two numbers that look the same often are not. The same method on the same dataset differs by dataset version (v0 against v2), by whether the last or the best policy during training is reported (CORL: BC averages 50.4 last and 70.2 best across Gym-MuJoCo), and by hyperparameters chosen with online evaluation, which breaks the offline assumption. Compare within one table; the D4RL results tab shows five printed tables side by side without splicing them, and the closed block lists the pitfalls with their evidence. D4RL itself is no longer maintained: its environments moved to Gymnasium and its datasets to Minari.

D4RL's datasets, and reading its tables: versions, checkpoints, tuning, seeds, saturation 2 min

The datasets probe specific difficulties: Gym-MuJoCo locomotion with "medium" (1 million samples from a SAC policy stopped early), "medium-replay" (the replay buffer up to that point) and "medium-expert" (medium and expert data mixed); Maze2D and AntMaze for stitching undirected data with sparse rewards; Adroit's 24-degree-of-freedom hand with a small number of human demonstrations; Franka Kitchen for multitask data.

  • Dataset versions. The Gym-MuJoCo datasets were reissued as v2 in December 2020, which "fixed Hopper's performance and the qpos/qvel fields" (D4RL README). The IQL paper points out that the Decision Transformer and one-step papers "incorrectly report results for some prior methods, such as CQL, using the '-v0' environments", which "generally produce lower scores than the '-v2' environments that these papers use for their own methods" (§5.2). CQL on halfcheetah-medium-expert is 62.4 in its own paper (v0) and 91.6 in IQL's table (v2). RvS's AntMaze table, labelled v2, includes CQL, TD3+BC and one-step numbers from v0, flagged by an asterisk.
  • Last policy or best policy. CORL reports both. Across Gym-MuJoCo, BC averages 50.4 last and 70.2 best; CQL on AntMaze 50.7 last and 61.8 best (Tables 1 and 2). "Best during training" was found by evaluating in the environment, which an offline method cannot do.
  • Hyperparameters chosen online. "Existing hyperparameter selection methods for offline RL break the offline assumption by evaluating policies corresponding to each hyperparameter setting in the environment" (Paine et al. 2020), and offline RL algorithms "are not robust to hyperparameter choices".
  • Few seeds, and two printings of the same run. Most tables average 3 to 5 seeds. The CQL paper's Table 1 and the D4RL paper's Table 2 both print CQL on the same v0 datasets, and disagree: CQL is 111.0 on hopper-medium-expert and 98.7 on walker2d-medium-expert in the CQL paper, and the reverse in D4RL's; the CQL paper's walker2d-medium-expert row also repeats the baselines of its walker2d-mixed row. Which printing is right is unconfirmed; the tab shows both.
  • Saturation. On Gym-MuJoCo the best averages in CORL's reruns are 89.7 (ReBRAC) and 92.9 (EDAC) on a scale where 100 is the reference SAC agent; the hard remaining suites are AntMaze and Adroit.

Off-policy evaluation (OPE) is the offline answer to "how good is this policy?", needed for model selection and deployment decisions. Importance sampling reweights logged returns by the product of π/πβ along each trajectory: unbiased, with variance that grows exponentially with the horizon (the off-policy Monte Carlo section of Model-free prediction and control shows the blow-up). Doubly robust estimators add a learned value model as a control variate, "guaranteed to be unbiased and can have a much lower variance" (Jiang and Li 2016). Fitted Q evaluation (FQE) runs fitted Q iteration for the fixed policy and reads off its value (Le, Voloshin and Yue 2019); it is biased by the same extrapolation as section 6 when the policy leaves the data. Paine et al. found that, controlled carefully, offline estimates "can reliably rank policies across hyperparameter choices"; a benchmark of these estimators on D4RL-style tasks is DOPE (Fu et al. 2021). Healthcare shows what goes wrong when they are not controlled (next section).

13Where it is used, and its limits

  • Robotics. QT-Opt learned closed-loop grasping from "over 580k real-world grasp attempts" of logged off-policy data; "even fully off-policy training can outperform strong baselines", and about 28,000 additional on-policy grasps raised success to 96% on unseen objects (Kalashnikov et al. 2018). Q-Transformer trains offline on demonstrations plus autonomously collected data across a multi-task real-robot suite. Most deployed robot policies, though, are behaviour cloning at scale (RT-1, Diffusion Policy; section 2), because demonstrations are easier to collect than reward labels.
  • Recommendation. YouTube scaled REINFORCE to "an action space on the orders of millions" learning from logged user feedback, with an off-policy correction for the fact that the logs only show items earlier recommenders chose, and a top-K version of the correction for recommending several items at once; it was tested in live experiments (Chen et al. 2019). Learning from logs is the norm in recommendation, usually as contextual bandits (Bandits and exploration).
  • Healthcare is where the setting fits best and evaluation is hardest. The AI Clinician learned vasopressor and fluid dosing for sepsis from intensive-care records and reported that "mortality was lowest in patients for whom clinicians' actual doses matched the AI decisions" (Komorowski et al. 2018). A reproduction found that, under the same importance-sampling evaluation, a policy giving no drugs at all often scored better than the clinicians (Jeter et al. 2019), and methodological work showed how the summary of a patient's history, the variance of the estimators and confounders "can result in unreliable, even misleading estimates of the quality of a treatment policy" (Gottesman et al. 2018; guidelines in Nature Medicine 2019).
  • Language models. SFT is behaviour cloning; DPO is offline preference learning (section 5); value-based offline RL has been applied to text generation (ILQL, Snell et al. 2022). Most current post-training is online RL on the model's own samples (RL for LLMs), partly because sampling a language model is cheap and its "environment" (a verifier or reward model) is free to query.
Limits that no algorithm removes

Coverage: no method can learn the value of something the data never does; offline RL can only recombine and reweight what is there, and the best policy within the data's support (the glass strip in Fig. 3) is the ceiling. Confounding: if the people who produced the data acted on information the data does not record (a clinician's bedside impression), the logged actions are correlated with outcomes for reasons the learner cannot see, and every estimate inherits the bias. Evaluation: without interaction, the policy's quality is itself an estimate, with the problems of section 12. Non-stationarity: the world that produced the logs may not be the one the policy is deployed in, and deploying the policy changes it.

Depth

Common mistakes and misconceptions, each with its evidence 2 min

"Off-policy means offline." Off-policy is about which policy the values describe; offline is about whether the agent may collect data. DQN and SAC are off-policy and online; naive off-policy algorithms fail offline for the reason in section 6, even on expert data (Fujimoto et al.'s "imitation" batch).

"More expert demonstrations will fix behaviour cloning." More data from the expert's state distribution lowers ε but does not cover the states the learner drifts into; Ross et al.'s Super Tux Kart learner did not improve with more expert laps. Coverage of recovery states (DAgger, noise injection, augmentation) is what helps.

"Offline RL beats behaviour cloning." Not on clean expert data, and not always on D4RL: in CORL's reruns 10% BC averages 69.3 on Gym-MuJoCo against CQL's 78.3, and BC beats both on pen-human (71.0 against −3.9 for TD3+BC and 13.7 for CQL). Offline RL wins when rewards are sparse, data is noisy or must be stitched (Kumar et al. 2022).

"A conservative value is a pessimistic estimate of every action." CQL's practical form (Equation 2) bounds the policy's value, not every Q-value: actions that are frequent in the data can be overestimated. Only the push-down-only form (Equation 1) is a pointwise lower bound.

Comparing D4RL scores across papers. Check the dataset version (v0 against v2), last against best checkpoint, the number of seeds, and whether hyperparameters were chosen by online evaluation. Compare within one table where possible, as the D4RL results tab does.

Asking a Decision Transformer for a return far above the data. Return conditioning interpolates among returns the data reached; asking for more does not make the policy better, and in stochastic environments the returns it was trained on may reflect luck rather than skill.

"GAIL is offline imitation." GAIL needs on-policy rollouts in the environment, comparable in number to training the expert with RL. Its demonstrations are fixed; its own data is not.

Trusting an importance-sampled value of a learned treatment policy. With long horizons and a deterministic learned policy, few logged trajectories match it, the weights explode, and the estimate rests on a handful of patients. Report the effective sample size and use several estimators.