What is the difference between on-policy and off-policy learning, and why might you want to learn off-policy?
Reinforcement learning, On-policy and off-policy
Level L1 Beginner. Length Short. Nature Th Theoretical.
What's being asked
Whether you can separate the behaviour policy (which collects data) from the target policy (which is being evaluated or improved).
Key idea
On-policy methods learn about the same policy that produces the data. Off-policy methods learn about a target policy from data generated by a different behaviour policy . Because the data distribution then differs from 's, the update needs a correction, such as a max over actions (Q-learning) or importance sampling.
Steps
- Define the behaviour policy as the policy the agent actually follows to act, and the target policy as the policy whose value we want to learn.
- On-policy: . Examples are SARSA, REINFORCE and A2C (advantage actor–critic). The target for SARSA uses the action actually taken next.
- Off-policy: . Q-learning learns the greedy policy while following an -greedy one. Its target uses , not the action taken.
- Give the benefits of off-policy learning. The agent can keep exploring while learning the greedy policy, reuse old data from a replay buffer, and learn from human demonstrations or other agents' logs.
- Give the cost: off-policy learning with function approximation can be unstable, and importance-sampling corrections can have very high variance.
Common mistakes
- Saying off-policy simply means the agent explores. SARSA with -greedy also explores, yet it is on-policy.
- Calling an algorithm off-policy because it uses a replay buffer. The key question is whether the target policy differs from the data-generating policy.
- Putting an importance ratio into a one-step Q-learning update. It needs none, whereas multi-step off-policy returns do.
How long your answer should be
4–6 sentences.
Last checked on 4 December 2026.
Read this
Previous in Reinforcement learning: What is a Markov decision process, what are its components, and what objective does an agent optimise?
Next in Reinforcement learning: What is the difference between model-free and model-based reinforcement learning, and what is the main trade-off between them?