Reinforcement Learning interview question

Machine LearningReinforcement Learningeasy

An e-commerce team trains pricing agents in a simulator and keeps a large buffer of transitions collected by older versions of its policies. Which grouping of algorithms into on-policy and off-policy is correct, including what it means for reusing that buffer?

  1. AOn-policy: Q-learning, DQN and SAC, which update towards the greedy or current policy; off-policy: SARSA, REINFORCE and PPO, which can learn from logs of other behaviour policies.
  2. BOn-policy: SARSA and REINFORCE; off-policy: Q-learning, DQN, SAC and PPO, since PPO's probability ratio corrects data from any older policy kept in a replay buffer.
  3. COn-policy: SARSA, REINFORCE and PPO, which must learn from data of the current policy; off-policy: Q-learning, DQN and SAC, which can learn from an old replay buffer.
  4. DOn-policy: SARSA, REINFORCE, PPO and SAC, since policy-gradient and actor–critic methods need fresh samples; off-policy: Q-learning and DQN, the value-based ones.
Show the answer and explanation

Correct answer: C, On-policy: SARSA, REINFORCE and PPO, which must learn from data of the current policy; off-policy: Q-learning, DQN and SAC, which can learn from an old replay buffer.

Explanation Reinforcement Learning

On-policy methods learn about the policy that generates the data. Off-policy methods learn about a target policy (often the greedy one) from data generated by a different behaviour policy, so they can reuse old or replayed experience.

AlgorithmTypeWhy
SARSAon-policytarget uses Q(s′, a′) for the action the current policy takes
Q-learningoff-policytarget uses the max over a′, the greedy policy
DQNoff-policyQ-learning with a replay buffer
REINFORCEon-policygradient is an expectation over the current policy's episodes
PPOon-policyreuses a fresh batch for a few epochs, then discards it
SACoff-policysoft Q-functions trained from a replay buffer

For this team: Q-learning, DQN and SAC can train on the old buffer (with the usual caveat that it must cover the relevant states and actions). REINFORCE and PPO need new rollouts. PPO's ratio π_new/π_old only corrects for the small gap between the policy that collected a batch and the one being updated during a few epochs, and clipping keeps that gap small, so it cannot use data from much older policies. SARSA trained on the old buffer would evaluate the old policies, not the current one.

Why the other groupings fail: SARSA and Q-learning are the textbook on-/off-policy pair, so swapping them is wrong. Being actor–critic does not make a method on-policy: A2C is on-policy, SAC is off-policy.

Interview tip: link the distinction to sample efficiency: off-policy methods reuse data and are usually more sample-efficient, while on-policy methods are often more stable.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Machine Learning questions

  1. A telecom team tunes a churn network with successive halving: 81 configurations, a minimum budget of 1 epoch, a maximum of 81 epochs and η = 3 (keep the best…
  2. What is the difference between model parameters and hyperparameters?
  3. What does the bias–variance trade-off describe?
  4. What does the mean squared error cost J(w) = (1/n) Σ (yᵢ − ŷᵢ)² measure for a linear regression model?
  5. What does the Gini impurity of a decision-tree node measure?