Pessimism: The Theory of Offline RL
Coverage, concentrability, and why pessimism is provably efficient.
Online RL is optimistic: when unsure, try it, and the data will correct you. Offline, nothing corrects you, and the sign must flip. This lesson makes that precise. It shows what the data must cover (one good policy, not all of them), proves in a few lines that acting on lower confidence bounds competes with every policy the data cover, gives rates that interpolate between imitation learning and RL, and ends with the limits: lower bounds, and a result showing that pessimism is a principled choice rather than a uniformly optimal one.
What you’ll learn
- Show that no offline algorithm can compete with a policy the data do not cover, and define all-policy and single-policy concentrability.
- Prove the pessimism bound: if a penalty dominates the Bellman estimation error, the greedy policy of the penalized values loses at most twice the penalty accumulated along any comparator's trajectories.
- State the rates of lower-confidence-bound methods in bandits, contextual bandits and MDPs as functions of and , and explain how they interpolate between imitation learning and RL.
- Describe Bellman-consistent pessimism for general function classes, and the lower bounds and the batch-bandit result that limit what pessimism can promise.
What the data must cover
Start with the smallest offline problem, a two-armed bandit. The data contain pulls of arm 1, whose mean is 0.5, and none of arm 2. Consider two worlds that differ only in arm 2: in one its mean is 1, in the other 0. The data have the same distribution in both worlds, so any algorithm picks arm 2 with the same probability in both. It loses in the first world and in the second, so in one of them it loses at least 0.25, however large is.
Coverage is measured by density ratios between a policy's occupancy measure and the data. With the normalized discounted occupancy from the initial distribution , and the data distribution , the two standard notions are
The first is a simple form of all-policy concentrability, what fitted Q-iteration's guarantees need (Fitted Q-Iteration & Its Guarantees): data covering everything any policy might do. The second is single-policy concentrability: data covering one policy. Rashidinejad, Zhu, Ma, Jiao and Russell (2021) organized offline RL around . It is never below 1, since both distributions sum to one; it equals 1 when the data are exactly the optimal policy's; and it is finite whenever the data cover the optimal policy, even if they never show a single suboptimal action.
A contextual bandit has 4 actions, and contexts come from the same distribution in the data and at deployment. In every context the behavior policy takes the optimal action with probability 0.9, and otherwise picks uniformly among all 4, so the optimal action's total probability is . What is ?
Show the answer
1.08
and , so . The all-policy coefficient is 40: a policy that always takes some other action has ratio . Data from a good, slightly noisy policy have excellent single-policy coverage and poor all-policy coverage, which is why greedy methods that need are the wrong tool for them.
Pessimism, proved
Work in a finite-horizon MDP with steps , rewards in and a dataset of trajectories, the setting of Jin, Yang and Wang (2021), whose indexing this step follows. Let be an empirical Bellman operator, , estimated from the data. A penalty is a ξ-uncertainty quantifier if, with probability at least , for all , and , where is the algorithm's own estimate. Pessimistic value iteration (PEVI) subtracts it:
Pessimistic value iteration (PEVI)
V̂_{H+1} ← 0
for h = H, H−1, ..., 1:
Q̂_h(s, a) ← clip( (B̂_h V̂_{h+1})(s, a) − Γ_h(s, a), 0, H − h + 1 )
π̂_h(s) ← argmax_a Q̂_h(s, a)
V̂_h(s) ← Q̂_h(s, π̂_h(s))
return π̂ = (π̂_1, ..., π̂_H)The penalty is an online exploration bonus with its sign flipped (Optimism in MDPs: UCRL2 & UCBVI). For tabular data, with the pair's count at step and a logarithmic factor. For a linear MDP with features , Jin et al. use , with the data's regularized feature covariance at step and of order .
Let be the error of the algorithm's values against a true backup of its own next-step estimate. On the good event, : before clipping, . Clipping at 0 keeps both inequalities, and the clip at cannot bind on the event, because .
For any policy , write and , then unroll along 's trajectory (the extended value-difference identity):
For the second sum vanishes, so : the pessimistic estimate is a lower bound on the true value of the returned policy. Subtract the two identities. The inner products are at most 0 because is greedy for , and the sum is nonnegative:
Compare optimism. With a bonus instead of a penalty, , and the same algebra bounds the loss by the uncertainty along the learner's own trajectories, . Online, that is self-correcting: wherever goes, data accumulate and shrinks. Offline, may head exactly where data are absent, and the bound is vacuous. Pessimism moves the uncertainty onto the comparator's trajectories, where good data can make it small.
From penalties to rates: between imitation and RL
Take the tabular penalty with samples of each pair at step , where is the data's distribution at step and the comparator's:
Split into two square roots and bound one of them by the concentrability :
For a deterministic comparator, sits on one action per state, and Cauchy–Schwarz gives . Summing over the steps:
This is a heuristic. A careful proof must handle the dependence of on the same data used to estimate , by sample splitting or by a union bound over value functions, and sharper analyses improve the powers of and . But the structure survives: the error depends on the data only through the comparator's coverage.
The sharpest known results, all for lower-confidence-bound (LCB) methods, with samples and up to logarithmic factors:
| Setting | Pessimism (LCB) achieves | Lower bound | Source |
|---|---|---|---|
| Multi-armed bandit | when ; exponentially small in when | Rashidinejad et al. (2021) | |
| Contextual bandit, contexts | the same: LCB is optimal for every | Rashidinejad et al. (2021) | |
| Discounted MDP | (VI-LCB) | Rashidinejad et al. (2021) | |
| Discounted MDP, sharpened | , with | matching, for every accuracy | Li, Shi, Chen, Chi & Wei (2024) |
| Linear MDP, dimension | when the data cover the optimal policy's feature directions | the same intrinsic uncertainty , up to the factor | Jin, Yang & Wang (2021) |
In the contextual bandit of the first step (), compare the refined rate with the cruder obtained by reusing the bandit argument. To reach the same error, how many times fewer samples does the refined rate need?
Show the answer
13.3
Equal error needs instead of , a ratio . Data from a nearly expert policy are worth an order of magnitude more than the crude analysis suggests, because pessimism needs to resolve only the contexts where the behavior strayed.
The bandit row hides a surprise. With nearly expert data (, so the best arm is more than half the data), the minimax rate is exponentially small in , and an algorithm that ignores rewards entirely and picks the most frequently logged arm gets there. It errs only if the best arm fails to be the most common, an event of probability at most . LCB, which uses rewards, has a guarantee of only order , the cost of comparing estimated means, and Rashidinejad et al. show that no setting of its confidence level makes it optimal in both regimes. Imitation exploits information that value-based methods discard: which actions the behavior chose. With several contexts the picture changes: majority voting can be wrong in contexts where the behavior mostly erred, its loss no longer vanishes as grows, and LCB is optimal across the whole range.
Think first 60% of logged pulls are of the best arm. Roughly how likely is majority voting to pick the wrong arm, and how does that compare with LCB's worst-case loss?
The vote fails only if a Binomial(1000, 0.6) count falls to 500 or below, which by the Chernoff bound has probability at most . LCB's guarantee is only of order : it ranks arms by estimated means, and two arms whose means differ by a few hundredths cannot be ranked reliably from 400 rewards of one of them.
General function classes, and the limits
Uncertainty quantifiers like are available for tabular and linear models. For a general class of candidate action-value functions and a policy class , Xie, Cheng, Jiang, Mineiro and Agarwal (2021) apply pessimism to a version space. For each policy, keep the functions whose empirical Bellman error for is small, and score the policy by the most pessimistic of them at the initial state :
with and an empirical Bellman error corrected for the double-sampling bias.
The coefficient measures distribution shift only through the Bellman errors of functions in the class, so it can be far smaller than a density ratio: differences between and that no candidate's Bellman error can detect cost nothing. For linear function classes with a small, finite action space this improves Jin et al.'s error bound by a factor . The price is computation: the max–min over policies and version spaces is intractable in general. A practical descendant, ATAC (Cheng, Xie, Jiang & Agarwal, 2022), plays a two-player game between an actor and a critic trained to find data-consistent functions under which the actor looks worse than the behavior policy; if the actor has no regret in this game, its policy is no worse than the behavior policy for a wide range of the pessimism hyperparameter.
The limits are as instructive as the guarantees.
- The comparator must be covered. The two-armed bandit of the first step rules out anything else.
- Realizability is not enough. Foster, Krishnamurthy, Simchi-Levi and Xu (2022) showed that with in the class and even all-policy coverage, but without completeness, some problems need a number of samples polynomial in the number of states; Wang, Foster and Kakade (2021) showed that with linear features realizing every policy's value and well-conditioned data, even evaluating a policy can need exponentially many samples in the horizon (Fitted Q-Iteration & Its Guarantees). Zhan, Huang, Huang, Jiang and Lee (2022) escape through a different door: realizability of a value function and a density ratio of a regularized occupancy linear program, together with single-policy concentrability, give polynomial sample complexity with a primal–dual algorithm.
- Pessimism is not uniquely optimal. For batch policy optimization in finite-armed bandits, Xiao et al. (2021) proved that every rule in a family of confidence-adjusted indices, pessimistic (LCB), neutral (empirical means) or optimistic (UCB), is minimax optimal, and that no algorithm is instance-optimal: for any algorithm that is optimal in one environment there is another where it does arbitrarily worse than the best. Pessimism comes out ahead only under a weighted minimax criterion that accounts for how hard the optimal value is to predict. The case for pessimism is that its guarantee is relative to what the data cover and cannot be wrecked by an unlucky extrapolation, not that it is uniformly best.
Key takeaways
- Without coverage of a comparator, no offline algorithm can compete with it: guarantees must be relative to what the data cover. Single-policy concentrability is the measure for pessimistic methods; greedy methods such as fitted Q-iteration need all-policy coverage.
- If a penalty dominates the Bellman estimation error, the greedy policy of the penalized values loses at most to any comparator : uncertainty is paid only along the comparator's trajectories, the reverse of optimism.
- LCB rates interpolate between imitation and RL: in contextual bandits , which is on expert data; for tabular MDPs about samples are necessary and sufficient. In multi-armed bandits with nearly expert data, majority voting achieves an exponentially small error, which no setting of LCB matches in both regimes.
- With general function classes, pessimism over a Bellman-consistent version space competes with every covered comparator under realizability and completeness. Realizability alone is not enough, and pessimism is minimax optimal but not uniquely so.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
What coverage does a pessimistic offline algorithm need in order to compete with the optimal policy?
- Data covering every state–action pair any policy can reach (all-policy concentrability)
- Data generated by the optimal policy itself
- Data covering the state–action pairs the optimal policy visits, in proportion (finite single-policy concentrability )
- A dataset larger than the state space
Show the answer
C. Data covering the state–action pairs the optimal policy visits, in proportion (finite single-policy concentrability )
The bound involves the penalty only along the optimal policy's trajectories, where it is small when the data cover them well; how badly the data cover other policies does not enter.
In the proof of the pessimism bound, which property makes ?
- is greedy with respect to the pessimistic values
- stays close to the behavior policy
- for every policy
- The penalty is larger where data are scarce
Show the answer
A. is greedy with respect to the pessimistic values
For each state, . Pessimism is used elsewhere: to make , so that the sum can be dropped.
The data contain pulls of arm 1 (mean 0.5) and none of arm 2. Over the two worlds in which arm 2 has mean 0 or mean 1, what is the smallest worst-case expected loss any algorithm can guarantee?
- 0, once is large enough
- 0.5
- 0.25
Show the answer
D. 0.25
The data are identically distributed in both worlds, so the algorithm picks arm 2 with the same probability in both, losing in one world and in the other. The worst case is minimized at , where it is 0.25, for every .
In a multi-armed bandit with nearly expert data (the best arm makes up 60% of the pulls), why can choosing the most frequently logged arm beat an LCB rule?
- Because LCB needs reward data for every arm
- Because the action frequencies reveal the best arm, and majority voting errs only with probability exponentially small in , while LCB's guarantee is only of order , the cost of comparing estimated means
- Because LCB is a biased estimator
- Because the most-played rule is more pessimistic than LCB
Show the answer
B. Because the action frequencies reveal the best arm, and majority voting errs only with probability exponentially small in , while LCB's guarantee is only of order , the cost of comparing estimated means
Imitation uses information that value-based methods discard: which actions the behavior chose. With the best arm is the majority, and a Chernoff bound makes the vote wrong with probability at most . With many contexts the advantage disappears: voting can fail in contexts where the behavior mostly erred.
Further reading
- Y. Jin, Z. Yang & Z. Wang, "Is pessimism provably efficient for offline RL?" Proceedings of the 38th International Conference on Machine Learning (ICML) (2021).
- P. Rashidinejad, B. Zhu, C. Ma, J. Jiao & S. Russell, "Bridging offline reinforcement learning and imitation learning: A tale of pessimism," Advances in Neural Information Processing Systems 34 (2021).
- T. Xie, C.-A. Cheng, N. Jiang, P. Mineiro & A. Agarwal, "Bellman-consistent pessimism for offline reinforcement learning," Advances in Neural Information Processing Systems 34 (2021).
- C. Xiao, Y. Wu, J. Mei, B. Dai, T. Lattimore, L. Li, C. Szepesvári & D. Schuurmans, "On the optimality of batch policy optimization algorithms," Proceedings of the 38th International Conference on Machine Learning (ICML) (2021).
- G. Li, L. Shi, Y. Chen, Y. Chi & Y. Wei, "Settling the sample complexity of model-based offline reinforcement learning," Annals of Statistics 52(1), 233–260 (2024).