Offline Reinforcement Learning

Imagine a hospital wants a policy for adjusting insulin doses. It wants to learn this from ten years of patient records. It cannot let an untrained agent experiment on real patients. It cannot risk seeing what happens when it makes a bad decision. This is the defining constraint of offline reinforcement learning. The agent must learn a good policy from a fixed, previously collected dataset. There is no further interaction with the environment during training. It is the RL analogue of supervised learning from a static dataset. But the target — a policy that will later act sequentially — makes the problem far more treacherous than it first appears. The trouble is that standard off-policy algorithms like Soft Actor-Critic rely on a hidden assumption. Built on Experience Replay and Target Networks, they quietly rely on being able to correct their own mistakes. They take an action, observe the true consequence, and update. In the offline setting, the agent instead evaluates a value function differently. It evaluates actions the current policy would take, actions the dataset may never have taken. The Q-network is asked to extrapolate into unseen territory. It will happily return confidently wrong answers there. Left uncorrected, this leads to a specific and well-documented failure mode. Value overestimation happens on out-of-distribution actions, which the policy then chases. This produces catastrophic performance when finally deployed. Offline RL matters because interaction is often expensive, slow, or dangerous. Robotics, healthcare, recommendation systems, autonomous driving, and dialogue systems all generate huge log datasets. These logs come from existing, often suboptimal, policies. Being able to train on these logs is a large practical prize. It may even exceed the logging policy's own performance. It converts RL from an online-experimentation-only tool into something closer to a data-driven statistical estimation problem. This article develops the core diagnosis of the offline RL failure mode (distributional shift). It also covers the major families of fixes — policy constraints, conservative value estimation, and model-based pessimism. Expect pseudocode, worked numerical traces, and an honest accounting of what still goes wrong. This article gives you the conceptual machinery to read and evaluate any offline RL paper. It covers the shared vocabulary of distributional shift, the reasons naive off-policy methods fail, and the taxonomy of correction strategies used in practice. It closes by pointing toward the neighboring problem of learning purely by imitation, without any reward signal at all.

Key takeaways
  • Offline RL learns a policy from a fixed dataset, with zero environment interaction during training.
  • The core failure mode is distributional shift: bootstrapped Q-values are queried at actions absent from the data, and errors compound through the Bellman backup.
  • Naively running off-policy algorithms like SAC or DDPG offline causes catastrophic value overestimation.
  • Three major fixes: policy constraint methods (e.g. BCQ, TD3+BC), conservative value estimation (CQL), and model-based pessimism (MOPO, MOReL).
  • Offline RL trades the exploration problem for a statistical estimation problem — performance is bounded by data coverage, not by how clever the algorithm is.
  • It underlies real deployments in robotics, recommendation, and healthcare, and is a stepping stone toward Imitation and Inverse RL.
The core insight

Offline RL fails or succeeds based on how well it controls the gap between the policy it evaluates and the policy that generated the data — not on how good its optimization is.

The idea

In the standard Markov Decision Process formulation, an RL agent alternates between acting in an environment and updating its policy from the resulting transitions. Off-policy algorithms relax this slightly: they can reuse past transitions stored in a replay buffer, as long as the agent is still occasionally collecting fresh data with its current policy. Offline RL removes even that: the agent receives a static dataset

D={(si,ai,ri,si′)}i=1N\mathcal{D} = \{(s_i, a_i, r_i, s_i')\}_{i=1}^N

generated by one or more unknown behavior policies πβ\pi_\beta, and must output a policy π\pi that performs well when actually deployed, without ever touching the environment during training. Only at test time, after training is frozen, does the policy get to act. The central technical difficulty is distributional shift. Any actor-critic method built on the Bellman backup

Q(s,a)←r+γ Ea′∼π(⋅∣s′)[Q(s′,a′)]Q(s,a) \leftarrow r + \gamma \, \mathbb{E}_{a' \sim \pi(\cdot|s')}\big[Q(s', a')\big]

must evaluate QQ at actions a′∼π(⋅∣s′)a' \sim \pi(\cdot \mid s') sampled from the current, evolving policy — not from πβ\pi_\beta. Online, this is harmless because if π\pi drifts toward some novel action, the agent can execute it, observe the true reward, and correct the estimate. Offline, there is no such correction: the Q-function is a neural network trained only on (s,a)(s,a) pairs from D\mathcal{D}, and when queried at an out-of-distribution (OOD) action a′a', it extrapolates. Function approximators, especially trained with few samples near a query point, tend to overestimate rather than underestimate value in unseen regions, because the policy improvement step explicitly searches for actions that maximize the (possibly erroneous) QQ. This creates a vicious cycle: the policy is pulled toward whatever action the critic mistakenly rates highly, the critic is never corrected because that action is never actually tried, and the error compounds across Bellman backups (which propagate errors from s′s' back to ss). The result, empirically and theoretically, is that naively offline-trained SAC/TD3-style agents often collapse to policies far worse than the behavior policy that produced the data — sometimes even failing catastrophically despite the dataset containing near-expert trajectories. The unifying idea behind essentially all successful offline RL algorithms is to introduce some form of pessimism or conservatism about actions and states not well-supported by the data. This can be done at the level of the policy (constrain π\pi to stay close to πβ\pi_\beta, or restrict its support to dataset actions), at the level of the value function (penalize QQ for OOD actions so it never overestimates them), or at the level of a learned dynamics model (penalize transitions into states where the model is uncertain). All three families are attempts to answer the same question: how do we act well using only what the data can actually tell us, refusing to trust extrapolation we cannot verify?

How it works

We walk through the general offline actor-critic recipe, then specialize to two canonical fixes: a policy-constraint method (BCQ-style) and a conservative-value method (CQL-style), which illustrate the two dominant design philosophies.

Policy constraint approach. Restrict π\pi so that it puts negligible probability on actions unlikely under πβ(a∣s)\pi_\beta(a\mid s). Concretely, BCQ (Batch-Constrained Q-learning) trains a generative model Gω(s)G_\omega(s) (e.g. a conditional VAE) to imitate πβ\pi_\beta, samples a handful of candidate actions from it, perturbs them slightly with a learned residual, and picks the candidate with highest QQ — never allowing the policy to propose actions the generative model deems implausible.

Conservative value approach. Conservative Q-Learning (CQL) instead directly shapes the Bellman objective: it adds a regularizer that pushes down Q(s,a)Q(s,a) for actions sampled from the current policy (likely OOD) while pushing up Q(s,a)Q(s,a) for actions actually seen in the dataset. This yields a lower bound on the true value function for the policy being trained, so the policy optimizer can never be fooled into chasing a phantom high-value action. ```text ALGORITHM: Offline Actor-Critic with Conservative Regularization (CQL-style) INPUT: static dataset D = {(s, a, r, s')}, discount γ, penalty weight α INIT: critic networks Q_θ1, Q_θ2, target networks Q_θ1', Q_θ2' actor network π_φ for iteration = 1, 2, ... do sample minibatch B = {(s, a, r, s')} ~ D # never touches env

# ---- Critic update ---- for each (s, a, r, s') in B: a' ~ π_φ(· | s') # policy's own next action y = r + γ * min(Q_θ1'(s', a'), Q_θ2'(s', a')) # standard target (Clipped Double Q)

# standard Bellman regression loss L_bellman = mean over B of (Q_θi(s,a) - y)^2 for i = 1,2

# conservative penalty: push DOWN Q at policy-sampled actions,

# push UP Q at dataset actions for each s in B: a_pi ~ π_φ(· | s) # OOD-risk action a_data = a from dataset at this s L_cql_i = logsumexp_a Q_θi(s, a) - Q_θi(s, a_data) # soft-max over actions minus data action

# (in practice approximated via sampled actions,

# including a_pi and random actions) L_critic_i = L_bellman_i + α * mean over B of L_cql_i # i = 1, 2 update θ1, θ2 by gradient descent on L_critic_1, L_critic_2

# ---- Actor update ---- for each s in B: a_new ~ π_φ(· | s) # reparameterized sample L_actor = - mean over B of min(Q_θ1(s, a_new), Q_θ2(s, a_new)) (+ optional behavior-cloning term λ * ||a_new - a_data||^2 , as in TD3+BC) update φ by gradient descent on L_actor

# ---- Target update ---- θi' ← τ θi + (1-τ) θi' for i = 1, 2 # Polyak averaging, as in SAC/TD3 end for OUTPUT: policy π_φ (deployed only now — no further training from real interaction) ``` Two design choices deserve emphasis. First, the actor is never allowed to update using real environment rollouts — every gradient in the loop above touches only D\mathcal{D}. Second, the conservative penalty term is what prevents the standard runaway overestimation: because log⁡∑aexp⁡Q(s,a)\log\sum_a \exp Q(s,a) (a soft maximum over actions) is penalized while Q(s,adata)Q(s, a_{\text{data}}) is rewarded, the critic is explicitly discouraged from assigning high value to any action other than the ones actually observed, unless the Bellman error strongly disagrees. Tuning α\alpha trades off conservatism against the tightness of the value estimate — too large and the policy becomes overly close to pure imitation; too small and overestimation returns. The simplest and often surprisingly strong baseline, TD3+BC, replaces the whole CQL-style penalty with a single behavior-cloning regularizer on the actor loss, λ∥πϕ(s)−adata∥2\lambda \|\pi_\phi(s) - a_{\text{data}}\|^2, tuned so that the actor is nudged toward data-supported actions while still being allowed to exploit accurate QQ estimates near them.

Figure
Distributional shift: why the Bellman backup fails offline
Query point vs. data support action space a estimated Q(s,a) dataset action support true Q learned Q — accurate extrapolation spike (OOD) π chases this action data-supported region unsupported region

Complexity & correctness

Computational complexity. Per gradient step, offline actor-critic methods cost the same as their online counterparts: one forward/backward pass through two critic networks and one actor network per minibatch, i.e. O(B⋅P)O(B \cdot P) time per update where BB is batch size and PP the network parameter count, with O(P)O(P) space for weights plus O(B)O(B) for the minibatch. Conservative penalties like CQL's logsumexp term require sampling MM extra actions per state (typically M∈[10,20]M \in [10, 20], drawn from the policy and from a uniform proposal) to approximate the log-partition function, multiplying critic compute by roughly M+1M{+}1 but leaving the asymptotic order unchanged, O(B⋅M⋅P)O(B \cdot M \cdot P). Model-based approaches (MOPO, MOReL) add the one-time cost of training an ensemble of KK dynamics models, O(K⋅∣D∣⋅Pmodel)O(K \cdot |\mathcal{D}| \cdot P_{\text{model}}), but subsequent policy optimization runs on synthetic rollouts and never touches the real environment. In all cases, wall-clock cost is dominated by the number of gradient steps, exactly as in standard deep RL, and dataset size ∣D∣|\mathcal{D}| enters only linearly (one pass over data per epoch), so the algorithms scale to million-transition offline datasets without asymptotic surprises.

Why naive off-policy RL fails offline — the argument. Consider the Bellman backup with function approximation. Define the Bellman error at (s,a)(s,a) as δ(s,a)=∣Qθ(s,a)−TπQθ(s,a)∣\delta(s,a) = |Q_\theta(s,a) - \mathcal{T}^\pi Q_\theta(s,a)|, where Tπ\mathcal{T}^\pi is the Bellman operator for policy π\pi. For (s,a)(s,a) pairs in D\mathcal{D}, gradient descent drives δ\delta toward zero because the loss directly supervises those points. For (s′,a′)(s',a') with a′∼π(⋅∣s′)a' \sim \pi(\cdot\mid s') but not in D\mathcal{D}, there is no supervision signal at all — the network's value there is whatever the inductive bias of the function class produces, and because the policy-improvement step is an explicit maximization (π←arg⁡max⁡πE[Q(s,π(s))]\pi \leftarrow \arg\max_\pi \mathbb{E}[Q(s,\pi(s))]), it is selected to find wherever the approximator errs high. This is not a rare accident but a systematic selection effect: over enough optimization steps, the policy is guaranteed to discover the approximator's blind spots, because it is searching precisely for actions where QQ looks best. Once such an action is baked into the policy, the target y=r+γQ(s′,a′)y = r + \gamma Q(s', a') used for the next Bellman update is itself computed at this erroneous point, so the overestimation propagates backward through the Bellman recursion to earlier states — a compounding error whose magnitude, in the worst case, grows with the effective horizon 1/(1−γ)1/(1-\gamma).

Why the fixes are correct. Policy-constraint methods sidestep the problem by construction: if π\pi's support is provably a subset of {a:πβ(a∣s)>ϵ}\{a : \pi_\beta(a\mid s) > \epsilon\}, then every action ever queried during training has appeared (or is arbitrarily close to one that has appeared) in D\mathcal{D}, so the Bellman target is always evaluated in a region with real supervision, and the standard convergence guarantees for fitted Q-iteration with bounded function-approximation error apply. Conservative-value methods take a different route: CQL's penalty is constructed so that, under mild assumptions on the critic's expressiveness, the learned QθQ_\theta is a provable lower bound on the true QπQ^\pi for the policy π\pi being optimized — formally, Ea∼π[Qθ(s,a)]≤Ea∼π[Qπ(s,a)]\mathbb{E}_{a\sim\pi}[Q_\theta(s,a)] \le \mathbb{E}_{a\sim\pi}[Q^\pi(s,a)] for all states in the data distribution, in the tabular/linear-approximation limit. A pessimistic lower bound is safe to optimize against, because the worst that can happen is the policy underperforms its estimate — it can never be lured into an action whose true value is actually catastrophic while its estimated value looks artificially high, which is precisely the failure mode that plagues naive off-policy learning. Model-based pessimism achieves an analogous guarantee by penalizing reward with model disagreement/uncertainty, effectively constructing a pessimistic MDP whose optimal policy is guaranteed (under model-error bounds) to perform at least as well in the true MDP as in the pessimistic one.

Tradeoffs. All three families sacrifice something: policy constraints and behavior cloning terms bias the learned policy toward mimicking πβ\pi_\beta, capping how far it can improve past the data-generating policy. Conservative value methods can be overly cautious, underestimating value even for good, well-covered actions, especially with small α\alpha mistuning. Model-based pessimism inherits the difficulty of learning accurate dynamics models and calibrated uncertainty in high-dimensional or stochastic environments. There is no free lunch: offline RL performance is fundamentally bounded by the coverage of D\mathcal{D} — no algorithm can reliably learn a good policy for state-action regions the data never visited, a limitation formalized in offline RL sample-complexity bounds that scale with the concentrability coefficient (a measure of how well D\mathcal{D}'s state-action distribution covers the distribution induced by the optimal policy).

Worked example

Consider a toy 1-D continuous-action bandit-like MDP with a single state s0s_0, action range a∈[−1,1]a \in [-1, 1], immediate reward r(a)=−(a−0.3)2r(a) = -(a - 0.3)^2, and the episode terminates after one step (γ\gamma irrelevant here — treat it as γ=0\gamma=0 for clarity of exposition; true optimum is a⋆=0.3a^\star = 0.3). Suppose the behavior policy sampled actions only from a∈[−0.5,−0.1]∪[0.1,0.5]a \in [-0.5, -0.1] \cup [0.1, 0.5] (it never tried the region right at 0.30.3 exactly, but did sample nearby, e.g. a=0.28a=0.28). We fit a critic Qθ(s0,a)Q_\theta(s_0, a) on 200 logged transitions.

Action aaIn data support?True reward r(a)r(a)Naive off-policy learned Qθ(a)Q_\theta(a)CQL-regularized Qθ(a)Q_\theta(a)
−0.4-0.4yes−0.49-0.49−0.49-0.49−0.50-0.50
0.10.1yes−0.04-0.04−0.05-0.05−0.06-0.06
0.280.28yes (sparse)−0.0004-0.0004−0.02-0.02−0.03-0.03
0.90.9no−0.36-0.36+0.55+0.55 (extrapolation spike)−0.40-0.40
−0.95-0.95no−1.56-1.56+0.20+0.20 (extrapolation spike)−1.30-1.30

The naive critic, trained with unconstrained fitted-Q, has never seen a=0.9a=0.9 or a=−0.95a=-0.95 and its neural network extrapolates poorly, assigning them spuriously high value (+0.55+0.55, +0.20+0.20) simply due to how the network's activation pattern generalizes outside the training manifold. An unconstrained actor optimizing arg⁡max⁡aQθ(a)\arg\max_a Q_\theta(a) will then confidently select a≈0.9a \approx 0.9 — a genuinely bad action with true reward −0.36-0.36, far worse than the near-optimal 0.280.28 actually present in the data. This is the overestimation failure made concrete: no environment interaction ever corrects the belief, because the policy is only ever evaluated offline against this same faulty critic during training. The CQL-regularized critic, by contrast, has been explicitly penalized for assigning high value to OOD actions like 0.90.9 and −0.95-0.95 (which are heavily sampled during the logsumexp penalty computation, since the actor initially proposes them too), pushing their estimated values down toward or below their true values, while dataset actions like 0.280.28 retain accurate (if conservatively shaded) estimates. The resulting policy correctly selects an action near 0.280.28, close to the true optimum 0.30.3, matching almost exactly what a well-covered dataset supports — it cannot do better than 0.280.28 because the data never demonstrated anything closer to 0.30.3, illustrating the coverage bound: the algorithm is only as good as its data, but it is safe, never catastrophically fooled.

Common pitfalls & traps

PitfallWhy it happensConsequence
Running vanilla SAC/DDPG offline with no modificationBellman target queries OOD actions with no correction mechanismCatastrophic value overestimation and policy collapse
Treating offline RL as pure supervised learning (ignore Bellman bootstrapping)Tempting to just regress on returnsLoses the ability to "stitch" suboptimal trajectory segments into better ones
Over-regularizing toward the behavior policyFear of OOD actions leads to λ\lambda set too highPolicy barely improves over πβ\pi_\beta; underperforms achievable value
Evaluating offline policies using online rollouts as if it were freeConfusing "offline training" with "offline evaluation"Off-policy evaluation is itself a hard open problem; naive on-policy testing may not be allowed in the true deployment setting
Ignoring dataset coverage / supportAssuming more data always helpsExtra data outside the region needed for the target task provides no benefit and can dilute learning signal
Using a single dynamics model for model-based offline RLNo mechanism to detect model errorPolicy exploits model errors ("hallucinated" high reward in fictitious rollouts)

Pioneers & history

Offline RL synthesizes ideas from batch reinforcement learning, causal inference, and deep function approximation, crystallizing into its modern form only once deep RL's instability under distributional shift became impossible to ignore.

Origins · 1 minSergey Levine and how this was discovered
SL
Sergey Levine
1985–present · Deep reinforcement learning and robot learning at UC Berkeley

Levine's group produced much of the foundational work diagnosing and fixing the offline RL overestimation problem, including BCQ, CQL, and MOReL-adjacent model-based methods, alongside extensive work connecting these ideas to real robotic manipulation from logged data.

History
1996
— batch/"fitted" reinforcement learning formalized, including Fitted Q-Iteration, as a way to reuse fixed transition sets.
2016
— deep off-policy actor-critic methods (DDPG) expose acute instability once bootstrapping meets function approximation.
2019
— Batch-Constrained deep Q-learning (BCQ) formally names and diagnoses "extrapolation error" in offline settings.
2020
— Conservative Q-Learning (CQL) introduces a provable pessimistic lower bound on Q-values for offline training.
2020
— model-based pessimism methods (MOPO, MOReL) extend conservatism to learned dynamics models; standardized offline benchmark suites (D4RL) accelerate reproducible comparison.

Where this matters

Offline RL is the practical bridge between reinforcement learning theory and domains where exploration is expensive or forbidden. In robotics, it enables policy improvement from large teleoperation or autonomous-collection logs without risking hardware on an untrained agent. In recommendation systems, it allows optimizing long-term engagement metrics from historical click/watch logs, rather than only the myopic supervised objective of predicting the next click. In healthcare, offline RL research explores treatment-policy learning from electronic health records, where live experimentation on patients is ethically off-limits, though deployment there remains cautious and largely research-stage. Autonomous driving stacks use offline RL and its close relative, offline imitation-augmented RL, to train and evaluate planning policies against enormous fleets' worth of logged driving data before any on-road testing. The conservative value-estimation ideas developed here (pessimism under uncertainty) also echo directly into Imitation and Inverse RL, where an agent likewise must generalize from a fixed set of expert demonstrations rather than free interaction, and into offline policy evaluation, the sister problem of estimating a policy's value from logs without deploying it at all.

Ask the tutor: How does the choice of the conservative penalty weight α in CQL trade off safety against how much the learned policy can improve over the behavior policy?

Why can't we just use experience replay from an online algorithm and call it "offline RL"?

Experience replay, as used in Experience Replay and Target Networks, still assumes the agent periodically collects fresh transitions with its current, evolving policy — it only reuses recent past data to stabilize and improve sample efficiency. Offline RL forbids any environment interaction whatsoever during training: the dataset is frozen before training starts. This distinction matters because online replay lets the agent self-correct any erroneous value estimate by simply trying the action and observing the true outcome. Offline RL has no such recourse, which is exactly why distributional shift becomes catastrophic rather than a minor inefficiency.

Is offline RL the same thing as behavior cloning?

No, though they are related. Behavior cloning is pure supervised learning: it fits π(a∣s)\pi(a\mid s) to match the actions in the dataset, with no reward signal and no notion of value or improvement — it can only ever imitate, never exceed, the demonstrator. Offline RL uses the reward signal and Bellman backups to potentially "stitch together" good sub-trajectories from multiple suboptimal demonstrations, producing a policy that can outperform any single trajectory in the dataset. The tradeoff is that offline RL is much more prone to instability from distributional shift, which behavior cloning entirely avoids by never bootstrapping.

Why does value overestimation specifically, rather than underestimation, dominate offline RL failures?

The policy improvement step is an explicit maximization over actions with respect to the learned QQ. If the critic's errors were unbiased noise, the max operator would still preferentially select actions where the noise happens to be positive — a selection effect analogous to the "winner's curse" in statistics. Combined with neural networks' tendency to extrapolate optimistically in regions far from training data (rather than reverting conservatively to some baseline), this produces a systematic upward bias precisely at the OOD actions the policy is searching over, which is why conservative methods target this specific direction of error.

How is offline RL performance actually evaluated if we can't interact with the environment during training?

Typically, offline RL research still permits evaluating the final trained policy with online rollouts (this is standard practice in benchmarks like D4RL), since the constraint is on training, not on final validation. The harder, still-open problem is offline policy evaluation (OPE): estimating a policy's value using only logged data, without ever running it, which is essential in domains like healthcare where even a validation rollout may be unsafe. OPE methods (importance sampling, fitted Q-evaluation, doubly robust estimators) are an active complementary research area to offline RL's policy-learning side.

Does more data always fix distributional shift?

Not necessarily. What matters is coverage: whether the dataset's state-action distribution overlaps with the state-action regions the optimal (or improved) policy would need to visit. A dataset with millions of transitions concentrated in a narrow region of state-action space provides no more help for out-of-distribution generalization than a much smaller, but broader, dataset. This is formalized via the concentrability coefficient in offline RL theory, which bounds achievable performance based on distributional overlap rather than raw sample count.

How does model-based offline RL (e.g. MOPO) differ from the model-free approaches like CQL?

Model-based offline RL first trains an ensemble of dynamics models P^(s′∣s,a)\hat{P}(s'\mid s,a) from the dataset, then optimizes a policy against synthetic rollouts generated by this model, typically penalizing the reward by a measure of model-ensemble disagreement to discourage the policy from exploiting regions where the model is uncertain (a form of pessimism analogous to CQL's value penalty, but applied to dynamics rather than values). This can generalize better to novel state-action combinations the model interpolates well, but it inherits all the risks of model misspecification, especially in high-dimensional or highly stochastic environments where learned dynamics models are unreliable.

Where does offline RL fit relative to imitation learning and inverse RL?

Offline RL, imitation learning, and inverse RL all learn from fixed data without environment interaction, but they differ in what signal they exploit. Offline RL uses explicit rewards and Bellman backups to potentially surpass the data-generating policy. Imitation learning has no reward signal at all and can only match demonstrated behavior. Inverse RL infers an unknown reward function from demonstrations, then optimizes a policy against it. These form a natural progression: offline RL when rewards are available and reliable, imitation and Imitation and Inverse RL when only demonstrations exist.

Before this