TL;DR
Conservative Q-learning (CQL) learns a control policy from a fixed log of past experience, with no new trials. It is ordinary Q-learning plus one extra term in the loss. The extra term pushes down the estimated value of actions the data never tried and pushes up the value of actions it did try, so the learned values act as a conservative lower bound rather than an optimistic guess.
Without that term, the learner trusts its own inflated values for actions it has never checked, and the policy it extracts performs badly when run for real. On the harder benchmark datasets the authors report clear gains over earlier offline methods.
Builds on: Deep Q-Network, Offline Reinforcement Learning · Leads to: later offline RL methods that penalise or constrain out-of-data actions
Why it mattered
Offline RL is the setting where a robot, a recommender or a clinic already has years of logged decisions and cannot safely explore. CQL became a common baseline for it because the recipe is simple: take a standard deep Q-learning or actor-critic implementation and add a regulariser. The change is small: it is added on top of soft actor-critic for continuous control and on top of QR-DQN for discrete control.
The benchmark it was tested on, the D4RL gym suite, became a standard way to compare offline methods. Later papers report on the same tasks against the same baselines, including CQL, so its numbers are part of the common scale the field uses.
The idea came from a 2020 arXiv posting by Kumar and colleagues. Earlier offline methods mostly kept the learned policy close to the behaviour policy with a constraint. CQL changes the value estimates instead, so the same penalty works with any value-based or actor-critic learner.
The problem
Q-learning learns a value for each state-action pair by bootstrapping: the target for one entry uses the best value of the next state. When the learner is online, a wrong high value is corrected because the agent tries that action and sees the true result. Offline, the agent cannot try anything. Actions absent from the dataset keep whatever value the network gives them, and the max in the Bellman target keeps selecting the largest of these unchecked numbers. The paper calls the result erroneously optimistic value estimates, driven by bootstrapping from out-of-distribution actions and by overfitting on a small dataset.
The goal is a learner whose value estimate for the policy it will run is never too high. In terms of the prerequisites: the learned should lower-bound the true value of the policy, which is defined through the Bellman equation over the MDP.
How it works
Here is one tiny instance. One state has two actions: , which appears in the dataset, and , which never does. The network currently says and . The network has no evidence for , so is an unsupported guess.
- Take the dataset action . Ordinary Q-learning fits to its Bellman target and does nothing about . A greedy policy would now choose , because .
- Add a penalty that is large when the network gives high values to many actions at once. The penalty is the soft-maximum of all the Q-values in the state, , minus the Q-value of the dataset action.
- Compute it. The soft-maximum is . Subtract the dataset action's value to get a penalty of about .
- Look at the gradient. The soft-maximum puts weight on and on . Minimising the penalty pushes down and pushes up.
- Repeat the update. Over many steps falls toward the level the data supports and rises toward its real value. The greedy policy now prefers the action the data actually shows working.
flowchart LR D[Logged dataset of state, action, reward, next state] --> B[Bellman error on dataset transitions] D --> P[Penalty: push down Q on all actions, push up Q on dataset actions] B --> L[Total loss = alpha times penalty + Bellman error] P --> L L --> Q[Updated Q-function] Q --> PI[Policy: act greedily or by actor-critic]
The math
The paper's practical objective, CQL(), is the Q-function loss used in Algorithm 1:
Here is the dataset, is the behaviour policy that generated the data (estimated from the data), is the weight on the penalty, and is the Bellman target from the previous iterate. The first term is the penalty; the second is the usual squared Bellman error.
Step 2 in symbols: the penalty
The term is a smooth maximum over actions. Its gradient with respect to is the softmax weight , which is large for the highest-valued actions. The second term, , has gradient , which is large only for actions the data contains. Minimising the difference lowers the high-valued actions and raises the logged ones.
In the tiny example the softmax weights were on and on , and the data weight was on and on . The net push on is down by , and on it is up by .
What the bound says
Under the usual regularity assumptions, the paper shows that the learned satisfies for the policy it will run. Only the expectation under the policy is bounded from above, not every single value. This matters: a bound on every action would also push down good actions that the data covers poorly, making the learner too pessimistic.
Variants
If the reference distribution in the penalty is a previous policy rather than uniform, the soft-maximum is replaced by an exponentially weighted average over that policy's actions. The paper calls this CQL(). It is one way to avoid estimating the log-sum-exp by sampling, which can be noisy when the action space is high-dimensional.
Results
The main table reports normalised return on D4RL gym tasks. CQL() is compared with plain SAC, behaviour cloning and earlier offline methods such as BEAR and BRAC. The pattern to look for: on datasets that mix good and mediocre behaviour, plain SAC trained on the same logged data does poorly, while CQL uses both parts of the data. On the single-policy datasets the margins over the strongest earlier baselines are smaller. Read the exact per-task numbers in the paper's table rather than trusting a summary ratio.
Limits, which the paper itself raises:
- It is tempting to think that CQL makes Q-values small in general. In fact the penalty raises logged actions and lowers the rest. The aim is a correct ordering across covered actions and low values for unsupported ones, not a uniform shift down.
- It is tempting to think a lower bound on every action is the goal. In fact only the expectation under the policy needs the bound, and a bound on each action would be too pessimistic.
- For continuous actions the log-sum-exp is estimated by sampling and importance weights. With many action dimensions those weights are noisy, which is the motivation for the CQL() variant.
- Use CQL when the data is fixed, interaction is unsafe, and the data mixes behaviours. A simpler behaviour-constrained method may suffice when the data comes from one good controller. The weight is a real choice: the paper tunes it automatically for continuous control with a Lagrangian rule and fixes it for discrete control.
Reading guide
Read these lessons first: Offline Reinforcement Learning, Deep Q-Network, Markov Decision Process and Bellman Equation. Then read the paper in this order.
- Section 1, Introduction: the motivation, distributional shift and overestimation. Needs Offline Reinforcement Learning.
- Section 2, Preliminaries: the MDP and the Bellman operator. Needs Markov Decision Process and Bellman Equation.
- Section 3.1, Conservative off-policy evaluation: the lower-bound argument for a fixed policy. Needs Expected Value and Value Function.
- Section 3.2, Conservative Q-learning: the CQL family and the two main variants. The prior-based variant needs Kullback–Leibler Divergence.
- Section 3.3, Safe policy improvement: the guarantee that improving against the bound does not make things worse. Optional on a first read.
- Section 4, Practical algorithm: Algorithm 1 and the implementation notes. Needs Deep Q-Network and Actor-Critic Methods.
- Section 6, Experiments: Table 1 onward. Needs Importance Sampling for how the log-sum-exp is estimated with sampled actions.
After this paper, Soft Actor-Critic is the continuous-control base the paper modifies, and Behavior Cloning is the simplest offline baseline it is compared against.
Check yourself
QuestionIn the tiny example, Q(s,a_1) = 0 and Q(s,a_2) = 2, with alpha = 1 and the dataset containing only a_1. What is the penalty term?Show answer
The soft-maximum is . Subtract the dataset action's value . The penalty is about .
QuestionWhy does the CQL penalty raise the value of the logged action when the Bellman term already fits it?Show answer
The Bellman term fits each logged transition to its own target, but it never compares the logged action with the unlogged ones. The penalty does: it subtracts the logged action's value, so lowering the soft-maximum over all actions also raises the logged action relative to them. The logged action is no longer outweighed by unsupported high values.
QuestionWhy does the paper bound only the expectation of Q under the policy, rather than every action's value?Show answer
The policy is evaluated through its expected value, so a bound on that expectation is enough for policy evaluation and improvement. A bound on every action would also push down good actions that the data covers poorly, making the learned values too pessimistic.
QuestionYou run CQL on a robot dataset in which every action comes from one good controller. Why might a simpler method do as well?Show answer
With one behaviour and little variety, there are few unsupported high-value actions to worry about. A method that stays close to the behaviour policy already performs well, so the extra penalty adds cost and tuning without much benefit. The penalty helps most when the data mixes behaviours and the learner could otherwise trust values for actions it never saw.