Modern AI Engineering

Lesson 2.8 · 27 min · video lesson

Reinforcement Learning: Teaching Agents Through Reward

Nobody gave AlphaGo a labelled list of "correct moves", and nobody hands a robot the right motor command for every millisecond. How do machines learn when the only feedback is "that went well" or "that went badly"?

In short: In reinforcement learning (RL), an agent learns by trial and error: it observes a state, takes an action, receives a reward, and adjusts its behaviour (its policy) to maximise the total reward it collects over time. Rewards can be delayed, so the agent must work out which earlier actions deserved credit, and it must balance exploring new actions against exploiting what already works. RL powers game-playing systems, robotics, and the RLHF and reasoning-model training behind modern LLMs.

What you will learn

  • The Big Picture
  • What is Reinforcement Learning?
  • A Simple Real-World Analogy
  • The Building Blocks of RL
  • The Reinforcement Learning Loop
  • Reinforcement Learning vs Supervised vs Unsupervised Learning
  • Episode, Return, and Discount Factor
  • Exploration vs Exploitation
  • Common Families of RL Algorithms
  • Where Is Reinforcement Learning Used?
  • Why Reinforcement Learning Is Hard
  • Quick Summary

In this lesson

  1. The big picture: learning from consequences
  2. The building blocks of RL
  3. The reinforcement learning loop
  4. Reinforcement learning vs supervised vs unsupervised learning
  5. Episode, return, and discount factor
  6. Exploration vs exploitation
  7. Common families of RL algorithms
  8. Code: Q-learning for the corridor robot
  9. Where is reinforcement learning used?
  10. Worked example, step by step
  11. Practice: try it yourself
  12. Why reinforcement learning is hard, and a quick summary

Key terms in this lesson

Agent
The learner that observes states and chooses actions in reinforcement learning.
Reward
A number the environment returns after an action, signalling how good the outcome was.
Policy
The agent's strategy: a mapping from states to actions (or action probabilities).
Return
The total discounted reward collected from a point in time onwards.
Discount factor (γ)
A number between 0 and 1 that reduces the weight of rewards further in the future.
Q-value
The expected return after taking a given action in a given state and then acting well.
Exploration vs exploitation
The trade-off between trying new actions to learn and using the best-known action to earn reward.

This lesson is free. Sign in or create a free account to open it with its video and quiz.

← 2.7 Regularization: Stopping Overfitting with L1 and L2 · 2.9 Contrastive Learning: Training by Comparison →