Reinforcement Learning Introduction


Reinforcement Learning Introduction

Anna
Welcome back! Today we're diving into model-free reinforcement learning, specifically gradient-free methods. The big idea is that we don't have a model of the environment—no transition probabilities or reward function—so we rely on trial and error. This is where Q-learning comes in, as one of the most popular techniques.

Maria
Right, and it builds on the concept of the quality function Q, which tells us the value of taking a particular action in a given state. It's richer than the value function V because it's tied to specific actions. The challenge is that without a model, we can't use dynamic programming with the Bellman equation—we have to learn from experience.

Anna
Exactly. And the simplest approach is Monte Carlo learning. That's an episodic method where you run through an entire game or sequence, compute the total discounted reward, and then update the value or Q-function for every state or state-action pair along the way, dividing that total reward equally.

Maria
But that's inefficient because it treats all steps as equally important, even if some were brilliant and others terrible. It's unbiased but requires many episodes to converge. There's a better way: temporal difference learning, or TD learning, which updates based on the difference between the observed reward and the current estimate, like a one-step look-ahead.

Anna
Yes! TD learning uses the Bellman equation recursively: the value of the current state equals the immediate reward plus the discounted value of the next state. The update uses the TD error—the difference between that target and the current estimate. That's biologically inspired, because dopamine signals in the brain act like a TD error, strengthening connections between actions and rewards.

Maria
And you can extend it to look ahead multiple steps. That's TD(n) where you sum rewards over n steps before bootstrapping. In the limit, it approaches Monte Carlo. There's also TD(λ), which exponentially weights all look-ahead steps with a parameter λ, combining the benefits of both.

Anna
Now, Q-learning is essentially TD learning applied to the Q-function, but it's off-policy. That means you can learn from actions that aren't your current optimal policy. When updating, you use the maximum Q-value over actions for the next state, not the action you actually took. This allows learning from past experiences or even watching others.

Maria
And that's the key difference from SARSA, which is on-policy. SARSA uses the action you actually took next to estimate the TD target. That makes it safer during training because it sticks to the current policy, so it's better for things like driving a car where random exploration could be dangerous. Q-learning is more exploratory and can converge faster.

Anna
Right. In Q-learning, you often use an epsilon-greedy policy: mostly take the best action, but with probability epsilon choose randomly to explore. You start with a high epsilon and anneal it down over time. That balances exploration and exploitation.

Maria
So to recap: Monte Carlo is simple but inefficient. TD learning is more efficient and biologically plausible. Q-learning is off-policy TD on Q, allowing flexible learning from any experience. SARSA is on-policy and safer. Both are gradient-free and model-free, and they've become the foundation for deep reinforcement learning.

Anna
Exactly. And we'll see how these combine with neural networks in future lectures. For now, it's important to understand that when you don't have a model, these trial-and-error methods are how you learn optimal behavior. Q-learning is used in everything from game playing to robotics.

Ask anything
We've read this whole study set, so questions about it get the best answers.