Offline and Conservative Model-Based RL › Learning from Fixed Datasets
World Models HandbookAll chapters Offline and Conservative Model-Based RL › Learning from Fixed DatasetsOne section · Sections in this chapter2 / 8 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
This section fixes notation, states a coverage assumption that can support offline learning, and derives the simulation lemma, which is the single most useful equation in the chapter. It explains why a model that looks accurate can produce a badly wrong value function, and it draws the line between model-based and model-free approaches to the offline problem. Later we will distinguish coverage from justified structural assumptions that can also constrain unobserved outcomes.
The setup
We have a Markov decision process as introduced in Part II: Inference, Decisions, and Control. To keep the comparison with learned models clean, we will assume throughout that the state is fully observed and the MDP is stationary. Neither assumption is free. Under partial observability the effective state is a belief, and the coverage problem becomes harder because two observation histories can be indistinguishable while requiring different actions. We will flag where that matters.
The stationarity assumption matters too. If the environment drifts over time, last year's transitions may not describe the world the deployed policy will face. In the warehouse example, a reorganised floor plan changes the dynamics represented by the logs. Here we assume no such drift: training and deployment share the same environment.
Instead of interacting, we are handed a dataset
where:
- : the fixed dataset of transitions
- : the -th observed state
- : the -th observed action taken in that state
- : the observed reward, whose conditional mean is
- : the next state, drawn from the transition distribution
- : the behaviour distribution, the state-action distribution induced by whatever process generated the logs
The behaviour distribution might come from a human demonstrator, a hand-tuned controller, a previously deployed policy, or five such policies mixed together. We do not need to know which. We only need the samples. Notice that the dataset records actions and their outcomes but never explains them. Nothing tells us why the behaviour policy chose a given action, which matters later when we want to imitate it in states where the model is uncertain.
The objective is unchanged from online RL. We want a policy maximising
where:
- : the expected discounted return of policy
- : the discount factor in
- : the reward received at step
- : the initial-state distribution, with
- : the policy, giving the action distribution at state
- : the environment transition distribution
The difference from online RL is entirely in what we are allowed to do while searching for . Online, we can test , observe the return, and adjust. Offline, that loop is severed: the objective is still defined against the true environment, but we can only ever evaluate candidate policies against our beliefs about it.
These terms are used loosely in the literature and the distinctions matter.
- Off-policy learning means the update rule can use data from a policy other than the current one. It says nothing about interaction. Deep Q-learning is off-policy and can still collect fresh data.
- Offline (or batch) learning means the dataset is fixed during the offline training phase; the learner collects no new transitions in that phase. Later deployment or offline-to-online fine-tuning is a separate stage. This is a restriction on data acquisition during training, not on the update rule.
- Off-policy evaluation is the sub-problem of estimating for a candidate using data from . It arises in online settings too, but offline RL cannot avoid it.
The last point is the practical sting. In online RL you evaluate candidates by running them. Offline you must estimate their value from the same fixed data you used to train, which means your evaluation inherits your coverage problems. We return to this in the final section.
Occupancy measures and the coverage assumption
It is convenient to work with discounted state-action occupancy measures rather than raw trajectories. For a policy with initial distribution , define the mass of any measurable state-action set by
where:
- : the discounted occupancy mass that policy assigns to set
- : the probability of visiting at step under policy starting from
- : the normalising factor that makes the sum a probability distribution
The factor makes a probability distribution over . In a discrete space, abbreviates the mass of the singleton ; in a continuous space, it denotes a density only when one exists with respect to a stated reference measure. Why bother with this object rather than working with the trajectory distribution directly? Because an occupancy measure summarises "where the policy spends its time," weighting near-term visits more heavily than far-future ones. It converts the trajectory of the policy into a static picture of the space, which is exactly what we need to compare two policies and to reason about how much their visited regions overlap. With this normalisation, the objective is a simple expectation:
Now compare with . If a policy spends time where the behavior distribution has substantial mass, the data can inform those choices; where it has none, learning requires additional structure. For the displayed ratio, read both quantities as masses in a discrete space or densities with respect to a common reference measure in a continuous space. This intuition is captured by the concentrability coefficient:
where:
- : the concentrability coefficient of policy
- : the discounted occupancy of under policy
- : the behaviour distribution's density at
- : the supremum over state-action pairs in the discrete case, or the essential supremum of the density ratio in the continuous case
Define the ratio as infinite when the target occupancy assigns positive mass to a region where the behavior distribution assigns zero; zero-over-zero pairs do not affect it. In continuous spaces, this requires absolute continuity and an essentially bounded density ratio. Thus finite requires the occupancy of that policy to be supported by the behavior distribution. Some offline-RL guarantees assume coverage of an optimal policy, , together with further statistical and algorithmic conditions. Covering one optimal policy is weaker than covering every policy, but it does not by itself make any particular learning algorithm successful. A small coefficient says the behavior distribution gives reasonable weight to what the policy visits; a large one signals weak coverage.
A dataset concentrates on a policy class with coefficient if, for every ,
Roughly: no state-action pair that some policy in visits often is more than a factor rarer in the data. Small means the data covers what the policies want to do.
Coverage is one way to make offline learning identifiable. Without coverage or justified structure linking unobserved outcomes to observed ones, no method can guarantee good decisions uniformly over the unrestricted MDP class.
The coefficient compares state-action occupancy densities. The next picture simplifies them to their state marginals: if the target visits states the behaviour never reaches, then it necessarily visits unsupported state-action pairs and is infinite. A gap confined to actions at otherwise covered states would also matter, but this state-only picture does not show it.
import numpy as np
# Schematic occupancies on a one-dimensional state space s in [0, 1].
# The behaviour density is truncated to [0.0, 0.5]. Most target mass lies
# to the right of 0.5, but Gaussian tails also overlap behaviour support
# below 0.45; the exact overlap is not confined to [0.45, 0.5].
_state = np.linspace(0.0, 1.0, 501)
_behaviour_support = (_state >= 0.0) & (_state <= 0.5)
def _bump_mixture(x, centres, width):
"""Normalised sum of Gaussian bumps, used only for this schematic figure."""
bumps = np.exp(-0.5 * ((x[:, None] - np.asarray(centres)) / width) ** 2)
density = bumps.sum(axis=1)
return density / (density.sum() * (x[1] - x[0]))
rho_beta = _bump_mixture(_state, [0.15, 0.30, 0.45], 0.07) * _behaviour_support
rho_beta = rho_beta / (rho_beta.sum() * (_state[1] - _state[0]))
d_pi = _bump_mixture(_state, [0.45, 0.65, 0.85], 0.07)
unsupported_mask = (rho_beta <= 0.0) & (d_pi > 1e-4)
Consider two MDPs that agree everywhere puts mass and disagree on an unseen action. Both produce the same dataset. In one, the unseen action is better than the logged choice; in the other, it is worse. Any data-only algorithm makes the same choice in both, so it cannot guarantee near-optimality in both over this unrestricted class. Coverage or justified structural information is needed to distinguish them.
The fixed log alone cannot identify the outcome of that unseen action. An offline method needs either relevant coverage or assumptions that constrain such outcomes.
The simulation lemma
Now suppose we learn a model from and use it in place of the environment. How wrong is the resulting value function? The answer is the simulation lemma, and it deserves a careful derivation because it is the theoretical heart of the whole chapter.
Fix a deterministic policy for this derivation; a stochastic policy gives the same identity after averaging each action-dependent term over . Write for its value under the true MDP and for its value under the model. Define the gap . Expanding both Bellman equations,
Subtracting the second from the first and adding and subtracting a term that evaluates under the model,
where:
- : the value gap at state
- : the reward-model error, abbreviated
- : the transition error, evaluated using the true value function
- : the expected continuation of the gap under the model's dynamics
The adding-and-subtracting trick is the algebraic seed of the whole result. We insert not because it was there already, but to isolate the reward mismatch and the transition mismatch as a single "local inconsistency" while leaving a clean recursion for the remaining gap. Everything that follows is a matter of chasing where that local inconsistency gets weighted.
The first two terms do not depend on ; call their sum the local inconsistency . The recursion unrolls along the trajectory distribution generated by the model. Write for the model's normalised discounted state-action occupancy and for its state marginal, both induced by the learned model rather than the true MDP. Averaging the initial-state gap over gives
Here , , and . A pointwise value-gap identity would instead use a model occupancy conditioned on that particular starting state; the displayed occupancy is averaged over .
The boxed equation averages local errors over states visited by a fixed policy in the learned model, not necessarily in reality. If the model's dynamics place substantial occupancy in a region where its predictions are wrong, that region contributes heavily to the value gap. The identity does not say that error itself attracts a fixed policy toward that region.
Error compounding and model exploitation are distinct steps. The fixed-policy identity describes how one-step errors propagate through model rollouts. When a policy is then selected by maximizing learned-model value, it may favor optimistic, poorly supported regions; that selection can change the model occupancy in the identity. The two mechanisms can reinforce each other, but neither the identity nor a fixed-policy bound alone proves that the errors concentrate exactly where they are largest.
A worked example: how vacuous the worst-case bound becomes
Bound the two error terms to get a usable inequality. Suppose the reward model is off by at most and the transition model has total-variation error at most :
where bounds the reward error, bounds the total-variation transition error, and is the maximum absolute reward. Since and ,
where:
- : the maximum reward-model error,
- : the maximum total-variation transition-model error
- : the maximum absolute per-step reward
- : the discount factor
The and prefactors come from two separate sources, and it is instructive to see both. The reward error is a per-step bias paid every step, so summing it under discounting costs the horizon factor . The transition error is more expensive: total-variation error is compared against value functions bounded by , and each step of the horizon multiplies the accumulated value bound by another factor, so the sum produces . The quadratic blow-up in the transition term is exactly the compounding effect, and it is the term that decides whether the bound is usable.
Now plug in an illustrative set of numbers. Take and . If rewards lie in , then returns lie in ; under the weaker assumption, returns lie in . Let the transition model have a uniform total-variation error upper bound of per state-action pair. This is a distance between distributions, not a claim that 95% of predicted transitions are correct. The transition-error term gives
With , the reward-error term adds 1, so the full bound is 991. Even the transition term alone exceeds a range-based upper bound of 201 on the value difference when true rewards satisfy and the learned reward may differ by up to . The bound is therefore vacuous in this example: a uniform 0.05 per-step TV bound does not yield a useful guarantee at this discount factor.
Plotting the two error terms against the discount factor shows which one drives the blow-up.
import numpy as np
# Bound terms from the worked example, as functions of the discount factor.
# Reward error is bounded by eps_r / (1 - gamma); transition error by
# 2 * gamma * R_max * eps_P / (1 - gamma) ** 2. The values fix eps_r = 0.01,
# eps_P = 0.05, and R_max = 1.0, matching the numbers discussed in the text.
_gamma_grid = np.linspace(0.5, 0.999, 400)
EPS_R = 0.01
EPS_P = 0.05
R_MAX = 1.0
reward_term = EPS_R / (1.0 - _gamma_grid)
transition_term = 2.0 * _gamma_grid * R_MAX * EPS_P / (1.0 - _gamma_grid) ** 2
The moral is not that the bound is bad. The bound is correct, and it is telling you something true: worst-case, there is no useful guarantee. A useful guarantee requires additional information, such as coverage of the policies under consideration or justified structure that bounds model error where they go. Pessimistic penalties and policy constraints can use such assumptions to limit unsupported choices; they do not themselves create coverage or certify a heuristic uncertainty score. This is why offline model-based RL is not simply "model-based RL without exploration."
It is worth emphasising that the numbers here are chosen to make the point sharp, not because is a realistic worst case. A uniform TV upper bound of 0.05 permits that much transition error at any state-action pair, including those the policy visits; it does not say actual error is 0.05 everywhere. The vacuity comes from pairing that global error allowance with a long horizon. Shorten the horizon () and the bound tightens quickly; make the model extremely accurate only where the policy goes and the uniform bound overstates the damage. Both of these escapes correspond to real assumptions we can make, and both are what the algorithms in the next sections exploit.
Both families exist, and they differ in what they learn.
- Model-free offline RL learns a -function or policy directly from , and handles distribution shift by constraining the policy or penalising the critic. Representative strictly offline methods include BCQ, BEAR, BRAC, TD3+BC, IQL, and CQL. AWAC can use an offline warm start but was designed for subsequent online improvement.
- Model-based offline RL learns predictive structure from and uses it for rollouts, planning, or critic training without new interaction. MOPO, COMBO, RAMBO, and MOBILE use learned dynamics in policy learning; MOReL plans in a pessimistic learned MDP, MBOP uses model-based planning, and Trajectory Transformer models joint state-action-reward sequences for reward-guided planning rather than fitting separate and networks.
A learned transition model can generate arbitrarily many synthetic transitions, including in regions the dataset never visited. Those samples do not create new evidence about the real environment. The design problem is to use rollouts where they help policy learning without letting unsupported predictions mislead the optimiser.
Why bother with a model at all, given the risk? Because of the amplification factor. With real transitions you can train a value function on samples, or you can train a model on samples and generate many imagined transitions from it. If the model is accurate on the region the policy cares about, those rollouts can help. MBPO made this argument in the online setting, as discussed in Part VIII: Decision-Centric Research Lineages. Online interaction can expose a wrong prediction and provide data for correction, though it does not guarantee safe exploration or eventual recovery. Offline, the fixed log cannot supply that targeted correction; repeated synthetic rollouts retain the model's unsupported assumptions.
The natural worry is a mismatch between where the model is accurate and where an improved policy might go. The dataset reflects , while an unconstrained improvement step can favor actions with little coverage. Improvement need not leave support: a mixed or suboptimal behaviour dataset may already contain better actions. The methods below try to use that opportunity without letting the optimiser exploit unsupported estimates.