TL;DR
Offline reinforcement learning trains an agent from a fixed log of past experience: tuples of state, action, reward and next state, collected by some earlier controller. The agent never acts in the world while it learns. The main difficulty is that a value learner may believe an action is excellent only because the log never tried it, so the method has to keep its estimates close to what the data supports.
Builds on: Reinforcement Learning, Q-Learning, Covariate Shift · Leads to: conservative Q-learning
Where it's used
Robot manipulation. A robot arm in a factory may have months of logs from a human operator or a scripted controller. Engineers want a better grasping policy from those logs. They cannot let an untested policy run freely on an arm that can break a part or hurt a person, so the learning has to work from the logs alone.
Recommendation and advertising. A platform has a huge record of which item was shown and whether the user clicked. Trying a new ranking on live users is costly and slow to evaluate, so teams often learn a candidate policy from the logged feedback first, then test only the most promising ones online.
Clinical decision support in research settings. Hospitals record what treatments clinicians chose and what happened. Researchers use offline methods to ask what a different rule might have achieved. These studies are educational and exploratory: they do not replace clinical judgement, and any recommendation from them needs careful validation.
How it works
Think of a delivery robot that has logged 1,000 trips. Each trip gives transitions. Here is one tiny instance.
flowchart LR L[Fixed log of transitions] --> Q[Fit a value estimate Q on the log] Q --> P[Read off the best action in each state] P --> C[Check: does the log support each chosen action?] C --> OUT[Policy, kept close to the log]
Take a log with one state and two actions, left and right. The log contains one transition: in state the robot went left, got reward 1, and the episode ended. The log never tried right.
- Start with the estimate and . Check: nothing has been learned yet.
- Use the logged transition to move the left estimate toward the observed reward 1, with step size . The new value is . Check: the estimate went up, but not all the way to 1.
- Repeat the same update on the same log. The new value is . Check: the estimate is closer to 1 again.
- The right estimate stays at 0 forever, because the log has no right transition to update it with. Check: this is the central problem. The estimate for an unseen action is whatever the start value was, and it is never corrected.
- Name the idea. Offline learning can only correct the values it has evidence for. For actions the log never tried, the estimate is a guess, and a learner that picks the largest guess will take the most dangerous unknown action.
The math
A fixed dataset of transitions, collected by a behaviour policy that is not being optimised. No new transitions can be gathered during learning.
Q-learning updates one entry of a table with a step size and discount , using a temporal-difference target: The max is over the actions available in the next state. Online, the agent visits those actions and corrects them. Offline, it only sees the actions in the log.
Step 2 in symbols: the update
With and , the next-state term drops out because the episode ended (there is no next state to value), so the update is . The same logged transition applied again gives . The sequence converges to 1.
Step 4 in symbols: the unseen action
The update touches only the pairs that appear in . For the right action, is never changed, so it remains at its initial value. When the agent takes the max over actions in a later target, it may pick up this untouched value.
Coverage and the behaviour policy
Let be the policy we want to evaluate or improve. A transition is useful evidence for only if the logged data contained the action would take. The importance ratio measures how much more or less often takes an action than the logger did. If while , the ratio is undefined: no amount of data can say what happens there. This is the mathematical form of the mismatch between the data and the new policy, and importance sampling is the usual tool for reweighting.
Worked examples
Use the log from the walkthrough: one transition in which left gives reward 1 and the episode ends. Start with and step size .
- Apply the update once. .
- Apply it again. .
- Apply it a third time. .
- Interpretation: the estimate for left approaches the logged reward 1, each time closing half the remaining gap. The right estimate has no data and does not move.
A state has two actions. The log supports one of them. Let and take a transition from with reward and next state .
- In the log contains only the action right, and its learned value is .
- The action jump never appears in the log. A function approximator, asked about it, returns . This value is an extrapolation, not evidence.
- Target if the max is taken over logged actions only: .
- Target if the max is taken over all actions: .
- The second target is 2.5 times the first. The gap comes entirely from the value of an action the data never checked.
- Interpretation: the learner now believes is worth 4.5, which it has no data to support. If it acts on this belief, the real return could be far lower. This is the overestimation that offline methods must prevent.
A warehouse robot log has 200,000 transitions. A candidate policy would choose the action "side grasp" in 40 percent of the states it visits. In the log, that action appears in 0.2 percent of transitions.
- Compute the logged coverage. The logger took side grasp in 0.2 percent of transitions, so on average. That is logged side grasps in total.
- The candidate would take it in 40 percent of states. Compare: .
- The average importance ratio is . Each logged side grasp would have to carry a weight of about 200, so a handful of transitions dominate any estimate.
- The effective sample size is small. The log says little about the candidate's side-grasp value, even though it contains 200,000 transitions in total.
- Decision: do not trust the estimate for side grasp. Either collect data for that action in a supervised, safe way, or restrict the candidate to actions the log covers well.
- Interpretation: a large log can still be thin for the actions a new policy wants to use. The check is about coverage, not the total count.
- Try it: a candidate takes action X in 10 percent of states, and the logger took X in 0.5 percent of states. What is the average importance ratio? Answer: .
Common mistakes and tradeoffs
Mistake 1: "More logged data always fixes the problem." It is tempting to think that a larger log removes the difficulty. In fact the problem is missing coverage, not missing volume. Actions the logger never took stay unsupported no matter how many transitions are added, as Example 3 shows.
Mistake 2: "Offline RL is just behaviour cloning." It is tempting to think that copying the logged actions is enough. In fact behaviour cloning imitates the logger, so it can be no better than the logged controller on average. Offline RL tries to combine logged actions in better ways, using reward, and that is exactly where the risk of trusting unseen actions comes from.
Mistake 3: "Maximising over actions is safe because it is standard Q-learning." It is tempting to think that the usual Q-learning target carries over unchanged. In fact the max is what turns an unseen but inflated estimate into a bad choice, as Example 2 shows. Offline methods change the target or penalise values of actions outside the data.
Mistake 4: "Offline evaluation is free." It is tempting to think that you can check a learned policy on the same log. In fact evaluating a policy on data it helped shape is biased toward its own choices. Use held-out logs, importance weights with care, or a small online test.
When to use it. Use offline RL when trying actions online is expensive, slow or unsafe, and a reasonable log already exists.
When not to use it. Avoid it when the log covers almost nothing the candidate wants to do. In that case, collecting targeted data is the honest choice.
Alternatives. Behaviour cloning is simpler and safer when the goal is to match the logger. Online replay is the right tool when new experience can still be collected, and deep Q-networks show how the same update is used with a neural network.
History
Reinforcement learning began with methods that worked from experience gathered as the agent acted. Batch methods, which fit a value function to a fixed set of transitions, appeared in the mid-2000s, and tree-based fitted Q-iteration was one of the early practical versions.
Deep reinforcement learning from 2013 onward used replay buffers, but those buffers still held data from a changing policy, so the learner could usually collect new experience. Researchers then found that agents trained only on fixed logs often failed badly, even when the logs looked large and reasonable. Levine and colleagues wrote a 2020 tutorial and review that named this setting offline reinforcement learning and set out its open problems.
Kumar and colleagues then proposed conservative Q-learning in 2020. Its key idea is to push down the values of actions the data does not support, so the learned values stay close to what the log can justify.
Recap
- Offline RL learns from a fixed log of transitions, without new interaction.
- Q-learning's max over actions can pick up values the log never checked.
- Coverage, the chance that the logger took an action, is the key quantity; the importance ratio makes the mismatch visible.
- Methods such as conservative Q-learning keep learned values close to the data.
Next, read Conservative Q-Learning for one answer to the overestimation problem, and Behavior Cloning for the simplest offline method.
Check yourself
QuestionRecall: what is the difference between offline and online reinforcement learning?Show answer
Online learning collects new transitions by acting in the environment while it learns. Offline learning works only from a fixed dataset collected earlier, and it cannot gather new data during training.
QuestionComputation: with step size , a logged reward of 1, and an estimate starting at 0, what is the estimate after one update?Show answer
The update is .
QuestionWhy: a learned Q-function gives an action a higher value than any logged action, and the log contains no example of that action. Why should we not trust that value?Show answer
The value is an extrapolation. The log gives no evidence about the outcome of that action, so the learned number is a guess. Maximising over actions picks the largest guess, so the policy is pulled toward the least supported action.
QuestionApplied: a team has a log of 50,000 transitions and wants to test a policy that chooses a rare action in 30 percent of states, where the logger chose it in 1 percent of states. What should they do?Show answer
The average importance ratio is , so a few logged examples would carry most of the weight. The log is thin for that action. The team should collect targeted data for it, or restrict the candidate policy to actions the log covers well, before trusting the estimate.
Sources
- Levine, Kumar, Tucker and Fu, Offline Reinforcement Learning: Tutorial, Review, and Perspectives on Open Problems (2020): https://arxiv.org/abs/2005.01643
- Kumar, Zhou, Tucker and Levine, Conservative Q-Learning for Offline Reinforcement Learning (2020): https://arxiv.org/abs/2006.04779
- Sutton and Barto, Reinforcement Learning: An Introduction (2nd ed., 2018): http://incompleteideas.net/book/the-book-2nd.html