Deep Learning & the Frontier / Learning Machines
Learning from reward, not labels.
Reviewed by Yuvaraj
Supervised learning needs a labelled answer for every example. But how do you label the "right" move in a game, or the "correct" motor torque for a walking robot? Often you cannot, you only know whether things went well eventually. Reinforcement learning (RL) is the framework for learning from that kind of delayed, evaluative feedback: an agent acts, the world responds with a reward, and the agent learns a behaviour that maximizes reward over time.
An RL problem is described as a loop between an agent and an environment:
Answer from memory before revealing, retrieval practice is what builds durable recall.
In reinforcement learning, the agent learns to maximize which quantity?
Ask about this lesson, or about anything in AI. Answers cite the lessons they draw on.
Finished this lesson?
Mark it complete to earn XP, keep your streak, and schedule a review.
The agent's goal is not to grab the biggest immediate reward but the biggest return, the discounted sum of all future rewards, where a discount factor makes sooner rewards worth more than later ones:
The credit-assignment problem
If you win a game after forty moves, which moves deserve the credit? This is the hard problem RL solves. The discount and the value estimates below are how reward earned at the goal flows backward to reward the moves that led there, exactly what you can watch happen in the Q-Learning Gridworld lab.
The key object is a value: how good is it to be in a state (or to take an action in a state), measured in expected future return. The action-value estimates the return from taking action in state and behaving well thereafter. Its defining self-consistency, the Bellman equation, says the value now equals the immediate reward plus the discounted value of where you land:
Everything in tabular RL is a way of making an estimate satisfy this equation.
For a curious beginner
The agent keeps a scorecard: for every square, how good is each possible move? At first the scores are all zero, it has no idea. It wanders (sometimes randomly, to explore), and whenever a move leads somewhere better than expected, it bumps that move's score up a little. Reaching the goal is a jackpot that raises the score of the move just before it; next time, the move before that inherits some of the glow. Slowly, a trail of high scores grows backward from the goal, and following the highest score from anywhere walks the agent home.
How it is actually used
Store as a table of (state, action) values. Act ε-greedily: with probability pick a random action (explore), otherwise pick the highest-valued one (exploit). After each step you observe and nudge the table toward the Bellman target. Exploration matters: with an agent that has never stumbled onto the goal has nothing to learn from. Decay over time to explore early and commit later.
The underlying mechanism
The Q-learning update moves the current estimate a step of size (the learning rate) toward the Bellman target:
Put concrete numbers on the rule. Say the agent is in state , every value starts at , and it takes an action that reaches the goal for a reward (a terminal step, so the bootstrap term drops). With learning rate :
Now the square that leads to the goal has a non-zero value. On a later visit, an action from a neighbouring state that lands in sees a target , so its own value rises to . The reward has taken one step backward along the path. Run enough episodes and a smooth gradient of values grows outward from the goal, the "trail" the intuition described, built by this one line of arithmetic.
Exploit too early and the agent locks onto the first mediocre route it found. Explore forever and it never cashes in what it learned. Every RL method is, at heart, a way of managing this trade-off, and it is why the same algorithm with a different can either find the goal reliably or get stuck. The gridworld lab lets you feel this directly by turning up and down.
Where the table breaks
A 25-square grid has 25 states. A game of Go has more states than atoms in the universe; a robot's camera feed is effectively continuous. You cannot tabulate those. Deep RL replaces the table with a neural network , trained by the same temporal-difference idea, this is how DQN learned Atari from pixels. The update rule you learned here is unchanged; only the function approximator is new.
RL is also the backbone of a technique you have already met: RLHF (reinforcement learning from human feedback) fine-tunes language models by treating human preference as the reward signal. The gridworld and a chat model tuned to be helpful are, formally, the same problem.
The bracket is the temporal-difference error: the gap between what we now believe and what we believed before. On a terminal transition the bootstrap term is dropped (there is no next state). Under mild conditions this update provably converges to the optimal .
The bracket is the temporal-difference error: the gap between what we now believe and what we believed before. On a terminal transition the bootstrap term is dropped (there is no next state). Under mild conditions this update provably converges to the optimal .