Having a replay buffer does not make a method offline RL. Online off-policy learning can still collect new data. Offline RL has only fixed logs. If a model proposes an uncovered action, no fresh feedback arrives to correct its imagination.

Check support before choosing an algorithm

In one lineA Q-network can rate an untried action highly and the Bellman max spreads it back. More of the same logs never reveal that action's outcome.

Suppose logs at some state $s$ contain only a conservative action, never an aggressive one. A Q-network can assign the aggressive action a high value, and the Bellman maximum can propagate that value backward. This is not evidence of a better policy; the estimate is untested.

More data from the same distribution can reduce estimation variance within covered regions. But repeating the same behavior a million times does not reveal the outcome of an action that behavior never takes. This is a support problem: the target policy needs states or actions outside the behavior distribution's support. An action missing from finite logs need not have zero probability under the behavior policy, but low probabilities and sparse samples can still make estimates unreliable. Also ask whether observations omit variables affecting both action choice and outcomes.

OPE evaluates without deploying

In one lineIS reweights logged returns by the probability ratio; normalizing or clipping trades bias for variance. Low ESS warns a few trajectories dominate.

Off-policy evaluation assesses a fixed policy; offline RL learns one. Basic trajectory importance sampling gives:

$$ \hat J_{\rm IS}=\frac1N\sum_{i=1}^Nw_iR_i,\qquad w_i=\prod_t\frac{\pi(a_t^i\mid s_t^i)}{\mu(a_t^i\mid s_t^i)}. $$

Here $R_i$ is the return of complete trajectory $i$. The target policy and logs must share the initial-state distribution and environment, behavior probabilities $\mu$ must be reliable, and target trajectories must have behavioral support. Self-normalization replaces $N$ with the sum of weights; it does not divide the preceding mean a second time:

$$ \hat J_{\rm SNIS}=\frac{\sum_iw_iR_i}{\sum_iw_i},\qquad \sum_iw_i>0. $$

This is generally biased at finite sample size but may reduce variance. Clipping weights similarly trades bias for stability.

For finite, nonnegative weights with at least one positive weight, a useful diagnostic is:

$$ {\rm ESS}=\frac{(\sum_iw_i)^2}{\sum_iw_i^2}. $$

With 3 trajectory weights $[1,1,8]$, ESS is approximately 1.52, not 3. It warns that a few trajectories may dominate. It does not establish unbiasedness or absence of hidden confounding.

Multiplying every weight by the same positive constant leaves ESS unchanged. Divide by the maximum before sums and squares to avoid overflow or squared-weight underflow. Starting from log-weights, subtract their largest finite value before exponentiation; rescaling cannot recover weights that have already overflowed to infinity or all underflowed to zero. If all weights are genuinely zero, ESS and SNIS are undefined, not valid zero-score estimates. This fixes numerical evaluation, not missing behavioral coverage.

Calculate weights in a two-action bandit first

In one lineIn the example, weight 5 on the right action turns the raw mean 1.2 into the true target value 2; if the old policy never goes right, nothing helps.

Left and right have fixed rewards 1 and 3. The logging policy chooses them with probabilities 90% and 10%; the target policy chooses each with 50%. Suppose 100 logged observations contain exactly 90 left and 10 right actions:

Action Count Reward $\pi/\mu$ Total weighted reward
Left 90 1 $0.5/0.9$ 50
Right 10 3 $0.5/0.1=5$ 150

The raw mean is 1.2. IS gives $(50+150)/100=2$, the target policy’s true expectation. Right’s reward did not change; ten observations now represent its greater target-policy frequency. These are convenient expected counts; actual finite logs fluctuate.

If the logging policy never goes right, there is no right-action feedback. Adding a small constant to the denominator cannot invent those observations. In multistep settings the ratios multiply, and one rare trajectory may dominate the estimate. Inspect support and weight distributions first. How to multiply fewer ratios, and how a value model can cancel noise, is in per-decision weights and doubly robust estimation.

Stitching does not require copying a complete demonstration

In one lineBellman backups can join two logs into a better policy if they meet at the same full Markov state. Trajectory IS cannot; in the example it gives 0.

Offline RL need not select the best complete episode in the logs. COG (Singh et al., 2020), §4 shows how Bellman updates connect behaviors from different datasets. Consider an original fully observed two-step MDP: from initial state $S$, both a direct route and a detour reach $M$ in one step, with rewards 0 and $-2$. At $M$, collecting pays 5 and quitting pays 0; either ends the episode. Dynamics and rewards are deterministic, $\gamma=1$, and state includes time.

Logged episode First step Second step Return
A Direct to $M$, reward 0 Quit, reward 0 0
B Detour to $M$, reward $-2$ Collect, reward 5 3

Terminal transitions give $Q(M,\text{collect})=5$ and $Q(M,\text{quit})=0$. One more backup gives:

$$ Q(S,\text{direct})=0+5=5,\qquad Q(S,\text{detour})=-2+5=3. $$

The new policy goes directly to $M$ and collects, earning 5 without using an unseen state-action pair. It combines compatible transitions at the same Markov state, not arbitrary video clips. If the routes leave different hidden keys, energy levels, or remaining time, they do not reach the same complete state. In a stochastic environment, observing each edge once would not reveal its conditional expectation exactly either.

The example also distinguishes two kinds of coverage. Suppose the logging policy independently chooses each action with probability $1/2$ at each state and happens to produce these two episodes. For the prespecified target policy “direct, then collect,” A has weight $2\times0$ and B has weight $0\times2$. Trajectory IS returns 0; SNIS and ESS are undefined. Yet population support is not missing: the behavior policy generates the target trajectory with probability $1/4$. This finite sample simply missed it.

Under the stipulated deterministic Markov structure, tabular FQE for that fixed target can fit the terminal rewards and then recover initial value 5. Trajectory IS does not automatically exploit stitchable local coverage; FQE gains from additional structure, not from escaping support requirements. Two episodes do not establish determinism; it is an assumption of this toy. Nor does this example establish a general estimator ranking.

Staying in support is not matching action frequencies

In one lineAlways picking the good action stays in support yet far from the logging policy in KL. Support, small KL and density ratios are different limits.

BEAR (Kumar et al., 2019), §4 distinguishes constraints on policy distributions from restrictions on action support. Take a bandit with two well-observed actions: the good action pays 4 and the bad one pays 0. Behavior probabilities are $(0.1,0.9)$. Always choosing the good action stays within support, but:

$$ D_{\rm KL}(\pi\|\mu)=\log(1/0.1)=\log10\approx2.303. $$

A hard constraint $D_{\rm KL}(\pi\|\mu)\le0.1$ excludes this fully supported policy. Conversely, nonzero probability does not mean sufficient observations: rare actions can still have poor estimates. Support restrictions, density-ratio control, and small KL are different requirements. An estimated behavior model can also assign positive probability to genuinely unsupported actions.

What CQL and IQL try to avoid

In one lineCQL pushes down unsupported high Q values; IQL learns only from logged actions, imitating them with weights. Neither adds behavior the data lack.

Method Central idea Remaining dependence
CQL Penalize unsupported high Q estimates conservatively Regularization, coverage, and approximation quality
IQL Learn from dataset actions, then extract a policy with advantage-weighted regression Useful behavior must exist in the dataset
Behavior cloning Learn logged actions directly Demonstration quality and similar deployment distribution

IQL's expectile value regression weights positive and negative residuals differently. For $u=Q(s,a)-V(s)$, the weight is $|\tau-\mathbf1(u<0)|$; $\tau>0.5$ emphasizes better in-dataset actions. An expectile is not a quantile: it uses weighted squared error, not pinball loss.

Conservatism alone is not a safety guarantee. Excessive conservatism may prevent improvements, and no algorithm can guarantee knowledge absent from the data.

Write one step of conservative and in-data learning

In one lineCQL's penalty pushes high Q down and data actions up, not a constant shift. In the example IQL's expectile is 3.2, not the mean 2 or the quantile 4.

A simplified discrete-action CQL penalty at a fixed state takes the form:

$$ \alpha\left[\log\sum_a\exp Q(s,a)-\mathbb E_{a\sim\mathcal D(\cdot\mid s)}Q(s,a)\right]. $$

Optimize it alongside Bellman fitting. The first term pushes down large Q values, while the second pushes data-action values back up relative to the others; it does not just subtract a constant from every Q. With only A observed, $Q(A)=1,Q(B)=5$ gives about 4.018 inside the brackets. Lowering unseen B to 0 gives about 0.313. This illustrates regularization pressure, not knowledge that B is actually bad.

IQL instead fits an expectile value from data-action Q values. For equally weighted values 0 and 4 with $\tau=0.8$, the optimum satisfies $0.8(4-V)=0.2V$, giving $V=3.2$. The mean is 2 and this distribution’s 0.8 quantile is 4: expectiles are different from quantiles.

Then regress $Q(s,a)$ toward $r+\gamma V(s')$ and extract a policy through exponentially advantage-weighted behavior cloning. Implementations still need fixed targets, termination handling, and control of extreme weights. Avoiding a maximization over unseen actions during training does not ensure a parameterized policy never leaves the data distribution at deployment.

Can we estimate Q without trustworthy behavior probabilities?

In one lineFQE regresses Q under a fixed policy and needs no behavior probabilities, but adds extrapolation error. A time limit is not termination.

Fitted Q Evaluation (FQE) fixes the policy $\pi$ being evaluated and repeatedly regresses toward:

$$ y=r+\gamma(1-d)\mathbb E_{a'\sim\pi(\cdot\mid s')}Q_{\rm old}(s',a'). $$

Here $d=1$ means true task termination, giving $y=r$. A data-collection time limit is not termination if the original task continues: bootstrap from the final successor $s'$ before the reset, not the new initial state after it.

Unlike FQI, it averages under a fixed policy rather than maximizing over actions. Estimate performance by averaging the fitted Q over initial states and policy actions. This avoids explicit trajectory weights but introduces approximation and extrapolation risks. Missing support does not disappear. Agreement between estimators sharing the same blind spot is not independent validation.

Model-generated offline data are not new real-world evidence

In one lineModel rollouts add no evidence. A penalty is conservative only if it truly bounds the error; in the example a too-small bound gives 7.5 for a true 1.

Training a model on fixed logs and generating many transitions does not remove extrapolation error. MOPO (Yu et al., 2020), §§4.1–4.3 penalizes model rewards with $\tilde r(s,a)=r(s,a)-\lambda u(s,a)$. Its theory requires $u$ to upper-bound an appropriate model-distribution error, together with value-class and penalty-scale assumptions. Rewards must be known or reward-model error controlled separately. The practical uncertainty estimate is heuristic and does not automatically inherit that guarantee.

An original two-step toy isolates why the error bound matters; it is not a full MOPO implementation. First choose a cautious or risky action, receiving zero reward and transitioning to success or failure. The second step pays 10 or 0 respectively and terminates, with no further choice; $\gamma=1$. Let $p$ be the true success probability and $\hat p$ the model's estimate. If $|p-\hat p|\le u$ is known to hold:

$$ J=10p\ge10\hat p-10u. $$

First action $\hat p$ Valid error bound $u$ Model return Conservative score True $p$ / return in this toy
Cautious 0.40 0.05 4 $4-10\times0.05=3.5$ 0.40 / 4
Risky 0.80 0.70 8 $8-10\times0.70=1$ 0.10 / 1

Without a penalty, the model selects the risky action; valid bounds favor the cautious one. If ensemble members agree on the same wrong prediction and incorrectly report $u=0.05$ for the risky action, its supposed lower bound becomes 7.5, far above its true return of 1. The error-bound assumption has failed. A million rollouts from that model only estimate the wrong value of 8 more precisely.

For the training loop in more detail, offline model-based RL compares three approaches: MOPO penalizes rewards, MOReL transitions to HALT, and COMBO regularizes the critic. Each has a worked calculation, followed by a check on bootstrapping at model-rollout cutoffs.

The coefficient 10 comes from the terminal-value difference, not a universal tuning rule. Multiple steps additionally require discounting, visitation distributions, and error propagation. A return lower bound is neither a safety constraint nor an automatic improvement over behavior. MOPO's behavior-policy comparison still subtracts an uncertainty cost; strict improvement needs further evidence.

A useful evaluation order

In one lineSplit data by time or entity, check coverage and ESS, compare estimators, then run a small real test. Picking policies on the same logs overfits OPE.

Start with time- or entity-separated train / validation / test splits to avoid trajectory leakage. Inspect behavioral support, weight tails, and effective sample size. Compare several OPE or model-based estimates and check ranking stability. Where permissible, follow with limited, controlled real validation.

Do not repeatedly select policies on the same logs and report the winning OPE score as independent evidence. Policy selection can overfit the estimator.

Scope of this introduction

In one lineBuilds intuition for support, weighting, conservative and in-data learning; per-decision IS, doubly robust and LSTD come next. No bounds or proofs.

This chapter develops support, importance weighting, conservative learning, and in-dataset learning; per-decision importance sampling, doubly robust estimation, and LSTD follow in OPE estimators. Neither note derives complete OPE confidence bounds or offline-RL convergence theorems. Read further: CQL, §3.2, Eq. (4) · IQL, §§4.1–4.3 · OPE and weight normalization, §§2–5 · FQE, §3.2, Algorithm 3. For basic importance weighting, revisit policy gradients.