MLCrack

    REINFORCEMENT LEARNING · INTERVIEW QUESTION

    Explain Q-Learning in detail. What is the update rule and why is it 'off-policy'?

    🟡 intermediate · Value-Based Methods

    Hint: Q-table, temporal difference update, and learning optimal policy regardless of behavior policy.

    Answer

    Q-Learning is a model-free, off-policy RL algorithm that learns the optimal action-value function Q*(s,a). Update rule: Q(s,a) ← Q(s,a) + α[r + γ·max_a' Q(s',a') - Q(s,a)].

    Components: α = learning rate, r = immediate reward, γ = discount factor, max_a' Q(s',a') = best possible future value. Off-policy: the update uses max (optimal action) regardless of what action the agent actually took (behavior policy). This means it learns the optimal policy even while following an exploration strategy like ε-greedy.

    Model-free: doesn't need to know transition dynamics P(s′∣s,a)P(s'|s,a). Convergence: guaranteed for tabular Q-learning with sufficient exploration (visit every state-action pair infinitely often) and decreasing learning rate. Limitation: works well for small, discrete state/action spaces but becomes impractical for large/continuous ones due to the curse of dimensionality — this motivated Deep Q-Networks (DQN).