Reinforcement Learning Overview
Reinforcement Learning: Foundations and Motivation
What Is Reinforcement Learning?
Reinforcement learning (RL) studies how an automated agent can learn through experience to make good decisions.
Reinforcement learning is the study of agents that interact with an environment, receive feedback in the form of observations and rewards, and learn to choose actions that maximize future reward.
An RL system typically includes:
An agent that makes decisions.
An environment or world with which the agent interacts.
Actions selected by the agent.
Observations received from the environment.
Rewards that indicate how desirable outcomes are.
A policy that determines which actions to take.
The agent does not necessarily receive correct instructions for every situation. Instead, it must learn from the consequences of its actions, often under uncertainty and with limited data.
RL is deceptively simple to describe because it combines several difficult problems:
Deciding what counts as a good outcome.
Connecting actions to delayed consequences.
Learning despite uncertainty.
Gathering useful information through exploration.
Generalizing decisions to situations not previously encountered.
Why Study Reinforcement Learning?
RL as a Component of Intelligence
Much of machine learning has focused on perception, such as:
Recognizing faces, animals, or objects.
Identifying cars in images.
Interpreting speech or text.
Perception is important, but intelligent behavior also requires deciding what to do based on information. An intelligent system must be able to:
Interpret its surroundings.
Consider possible actions.
Predict or evaluate their consequences.
Select an action that produces a desirable outcome.
Therefore, a general theory of artificial intelligence must address decision-making, not just recognition or prediction.
A central question in AI is:
How can an agent learn to make good decisions when the world is uncertain and only limited data are available?
This question has been studied since at least the 1950s. Richard Bellman made foundational contributions, especially through dynamic programming and the Bellman equation, which connect the value of a decision to the value of future decisions.
RL as a Practical Tool
RL is also important because it has achieved strong results in practical domains where conventional approaches struggled.
Playing Go
Go is a highly complex board game with a much larger search space than chess. It was considered a longstanding challenge for artificial intelligence.
A major breakthrough came from combining:
Reinforcement learning, which learns how to make decisions from outcomes.
Monte Carlo Tree Search, which explores possible future game states by simulated play.
This combination produced systems capable of defeating the strongest human Go players. Importantly, these systems discovered strategies that were not simply copied from human games.
Fusion Science
Fusion energy research involves controlling plasma inside a vessel. One challenge is determining how to command magnetic coil controllers so that the plasma assumes desired shapes.
Deep RL has been used to learn control policies that manipulate the plasma more flexibly than previously expected. This illustrates how RL can control complex physical systems whose dynamics are difficult to model manually.
COVID-19 Testing
During the COVID-19 pandemic, Greece faced limited testing resources and needed to decide whom to test, particularly at national borders.
The decision problem involved:
Changing epidemic conditions.
Population movement across borders.
Limited testing capacity.
Uncertainty about which individuals were most likely to have the disease.
RL provided a data-driven way to allocate testing resources and was deployed for border testing.
ChatGPT and Reinforcement Learning from Human Feedback
Large language models initially learned primarily through large-scale language prediction and supervised training. However, producing likely text is not identical to producing useful, safe, or preferred responses.
A high-level training process for systems such as ChatGPT includes three important stages.
1. Behavior Cloning or Imitation Learning
The system is first trained on examples of prompts and desirable responses.
For example:
Prompt: Explain reinforcement learning to a six-year-old.
Demonstration response: An explanation using simple ideas such as rewards and punishments.
The model learns to map inputs to outputs using supervised learning. This is called behavior cloning or imitation learning because the system imitates demonstrated behavior.
2. Learning a Reward or Preference Model
Not every response found in a large dataset is equally good. Human evaluators can compare multiple responses and indicate which they prefer.
The system uses these comparisons to learn a preference model or reward model. This model attempts to predict how highly humans would evaluate a response.
3. Reinforcement Learning from Human Feedback
The learned reward model is then used as the reward signal for reinforcement learning. The language model is optimized to produce responses that receive higher predicted human approval.
This process is called reinforcement learning from human feedback (RLHF).
RLHF demonstrates how RL can improve behavior when:
The desired behavior is difficult to specify with simple labels.
Human judgments provide useful preference information.
The original training data contain both high- and low-quality examples.
RLHF was developed before ChatGPT, including for simulated robotics tasks, but ChatGPT made the approach widely visible because it produced a substantial improvement in system performance.
Growth and Skepticism in Reinforcement Learning
Interest in RL increased dramatically during the 2010s and afterward. Important contributors to this growth included:
Systems learning to play Atari games directly from pixel inputs.
AlphaGo’s success in Go.
Advances in deep neural networks.
Applications to robotics, science, health, language, and optimization.
Despite this growth, some researchers have questioned how central RL should be to the broader field of AI.
A well-known analogy compared machine learning to a cake:
Unsupervised learning was described as the main body of the cake because it can learn representations from large amounts of unlabeled data.
Supervised learning was described as the icing because labeled data are highly useful but less abundant.
Reinforcement learning was described as the cherry because it was viewed as important but relatively small compared with the rest of machine learning.
The broader issue is not whether one technique is universally best. Rather, different methods are useful for different problems:
Supervised learning is effective when correct labels are available.
Unsupervised learning is useful for discovering structure in unlabeled data.
RL is especially suited to sequential decisions, delayed effects, exploration, and utility optimization.
The Four Core Characteristics of Reinforcement Learning
RL commonly involves four central ideas:
Optimization
Delayed consequences
Exploration
Generalization
1. Optimization
RL seeks good or optimal decisions. This requires a notion of utility, reward, or preference so that different outcomes can be compared.
For example, when finding a route between two cities, a system might seek the minimum-distance route. If one route has distance d1 and another has distance d2, then the first route is preferred whenever:
The optimization aspect of RL means that the agent is not merely predicting what will happen. It is trying to select actions that lead to better outcomes.
Optimization allows an agent to:
Rank alternative decisions.
Compare policies.
Trade off competing outcomes.
Seek the greatest cumulative reward rather than merely an immediately plausible action.
2. Delayed Consequences
An action taken now may affect outcomes much later.
Examples include:
Saving money for retirement.
Choosing an early strategy in a video game.
Training consistently for a marathon.
Selecting educational content that improves future mastery.
Taking medication that changes health outcomes over time.
Delayed consequences create two major difficulties.
Planning Difficulty
Even if the rules of the environment are known, it may be difficult to determine which sequence of actions is best.
Chess illustrates this problem:
The rules are known.
The immediate effects of moves are often visible.
The long-term consequences of a move may extend many turns into the future.
The number of possible action sequences is enormous.
When actions affect distant outcomes, an agent must reason about long-term ramifications rather than only immediate rewards.
Temporal Credit Assignment
When an agent receives a reward much later, it must determine which earlier actions contributed to that outcome.
This is the temporal credit assignment problem.
For example, suppose a person qualifies for a difficult marathon. Many earlier decisions may have contributed:
Eating healthily.
Sleeping adequately.
Training consistently.
Choosing a particular training schedule.
Practicing for many weeks.
If the only reward is received on race day, it is difficult to determine which actions deserve credit. RL systems must learn how to assign credit across time so that useful decisions can be repeated.
Temporal credit assignment is the challenge of determining which past actions caused a later reward or failure.
3. Exploration
An RL agent often learns only by trying actions and observing their consequences. This creates a fundamental limitation:
The agent generally receives information only about the actions it actually takes.
This is called the exploration problem.
A system learning to ride a bicycle, for example, must:
Attempt a movement.
Observe whether it succeeds or fails.
Adjust its behavior.
Try again.
The agent cannot directly observe what would have happened under every alternative action.
Counterfactual Uncertainty
The result of an action is observed, but the outcomes of actions not taken remain unknown. This creates a counterfactual problem.
For example:
A person knows what happened after attending one university.
The person cannot directly observe what life would have been like at another university.
A company can observe what happens after offering a promotion.
It cannot observe what would have happened to the same customers if the promotion had not been offered.
Even comparing different people does not fully solve this problem because the people may differ in important ways.
Exploration therefore requires an agent to balance:
Exploitation: choosing actions already believed to be good.
Exploration: trying uncertain actions to gather information.
Exploration is especially important when the agent may discover behavior better than existing human examples.
4. Generalization
A policy maps situations to decisions. In simple environments, a policy could be written as a table:
If the robot reaches the end of a hallway, turn left.
If the customer is in category A, show advertisement X.
However, realistic environments contain enormous numbers of possible situations.
Suppose a video game provides an image with dimensions 300×400, and each pixel can take at least 256 color values. The number of possible images is at least:
This number is far too large for a policy to store a separate action for every possible input.
The agent must instead learn a compact function that generalizes across related situations. Deep neural networks are one way to represent such policies.
Generalization allows an agent to:
Respond to situations not seen during training.
Recognize similarities between states.
Avoid memorizing an individual action for every possible input.
Scale to high-dimensional observations such as images, language, and sensor streams.
Reinforcement Learning Compared with Other Approaches
AI Planning
AI planning generally assumes that the system has a model of how the world works and seeks a sequence of actions that optimizes an objective.
Planning commonly involves:
Optimization.
Delayed consequences.
Sometimes generalization when the state space is large.
RL includes these concerns but additionally emphasizes learning from experience and exploration when the model or best actions are not known.
Supervised Learning
Supervised learning learns from labeled examples.
Examples include:
Predicting whether an image contains a cat.
Assigning a class label to an input.
Predicting a target value from features.
Supervised learning generally involves:
Learning from data.
Generalizing to new inputs.
Optimizing a loss function.
However, ordinary supervised learning usually does not involve:
Choosing actions that change future states.
Delayed consequences.
Exploration of alternative decisions.
A long-term utility or cumulative reward.
A supervised learner may minimize prediction loss without explicitly optimizing the downstream consequences of its predictions.
Unsupervised Learning
Unsupervised learning uses data without externally supplied labels. It attempts to discover structure, patterns, or representations in the data.
It generally involves:
Learning from experience or observations.
Generalization.
Representation learning from unlabeled data.
Unlike RL, unsupervised learning typically does not require an agent to choose actions in order to influence future observations or maximize reward.
Imitation Learning and Its Relationship to RL
Definition
Imitation learning, also called behavior cloning, learns a policy from demonstrations of desired behavior.
A demonstration may consist of:
A human driving a car while recording steering actions.
A person responding to language prompts.
An expert controlling a robot.
A skilled player making decisions in a game.
The learner attempts to reproduce the expert’s action at each observed situation.
In its simplest form, imitation learning reduces a decision problem to supervised learning:
Observe an input state or situation.
Record the expert’s action.
Train a model to predict that action in similar situations.
Strengths
Imitation learning is useful when:
Good demonstrations are available.
The expert behavior is already satisfactory.
Direct trial-and-error is expensive or dangerous.
The environment is difficult to explore safely.
Limitations
Imitation learning generally cannot exceed the quality of its demonstrations. If all demonstrations are produced by humans, the learned system is usually encouraged to reproduce human-level behavior rather than discover fundamentally better strategies.
Other limitations include:
Demonstrations may contain errors.
Data may cover only a limited set of situations.
The expert’s behavior may be difficult to observe or label.
The learner may fail when it encounters states not represented in the demonstrations.
Imitation Learning versus RLHF
The two approaches differ in how human information is used.
Imitation Learning
Humans provide example responses or actions.
The learner directly imitates those examples.
The examples are treated as target outputs.
RLHF
Humans compare or rank candidate outputs.
A model learns human preferences from those comparisons.
RL then optimizes the policy according to the learned reward.
RLHF is useful when it is easier for humans to compare outputs than to provide ideal demonstrations for every possible input.
Situations Where RL Is Especially Valuable
RL is particularly promising in the following settings.
When Desired Behavior Is Not Available as Demonstrations
If a system must outperform humans, human demonstrations alone are insufficient. RL can optimize outcomes directly and potentially discover strategies beyond human performance.
Potential examples include:
Medical treatment policies.
Educational interventions.
Scientific discovery.
Complex control systems.
Game strategies.
When There Is Little or No Existing Data
Some tasks have no useful historical dataset. An RL agent can learn through interaction, gathering data as it acts.
This is powerful when:
The task is new.
The environment can be simulated.
The agent can safely experiment.
Decisions directly affect future information.
When the Problem Is a Huge Search or Optimization Problem
Some planning or algorithm-design problems have such enormous search spaces that manually designing the best solution is difficult.
RL can guide search through these spaces.
AlphaTensor
AlphaTensor learned faster algorithms for matrix multiplication. The system was not merely selecting among standard algorithms; it searched for new algorithms.
The resulting algorithms:
Produced the correct matrix product.
Improved computational efficiency.
Were discovered automatically through RL-guided search.
Similar ideas have been applied to discovering faster sorting algorithms.
This suggests that RL can serve as a tool for algorithm invention, especially when:
The search space is extremely large.
Candidate solutions can be evaluated automatically.
Correctness can be verified.
The objective is precisely measurable.
In these cases, a difficult search or planning problem can sometimes be reframed as a learning problem so that experience and learned guidance make the search more tractable.
Formulating Problems as Sequential Decision Processes
General Interaction Loop
A sequential decision-making problem under uncertainty consists of repeated interaction between an agent and an environment.
At each time step t:
The agent observes information about the current situation.
The agent selects an action At.
The environment changes in response.
The environment emits an observation Ot+1 and reward Rt+1.
The agent uses the new information to select its next action.
This creates a feedback loop:
The agent’s objective is to maximize expected cumulative future reward, including both immediate and later rewards.
Applications
Web Advertising
Action: Select an advertisement or product recommendation.
Observations: View time, clicks, purchases, or browsing behavior.
Reward: Click-through rate, viewing time, revenue, or purchases.
Challenge: An advertisement may influence later user behavior, not only the immediate click.
Robotics
Action: Move a joint or issue a motor command.
Observation: Camera images, sensor readings, or the robot’s position.
Reward: Completion of a task, such as placing clean dishes in a dishwasher.
A poorly defined reward can produce undesirable behavior. If the reward is simply “the counter contains no dishes,” a robot might push the dishes onto the floor. The reward should instead reflect the intended outcome, such as dishes being placed in the dishwasher and cleaned.
Blood Pressure Control
Action: Recommend exercise, medication, diet, or another intervention.
Observation: Blood pressure and related health measurements.
Reward: Positive value for remaining within a healthy range and penalties for being outside that range.
The reward should reflect the actual health objective rather than an incomplete proxy.
Histories, States, and the Markov Assumption
Histories
At time t, the history Ht is the complete sequence of prior interactions.
It may contain:
Previous actions.
Previous observations.
Previous rewards.
Conceptually, a history can be represented as:
An agent could make decisions using the entire history, but histories grow over time and may become computationally impractical to store and process.
State as a Summary
A state is a representation of the current situation used for decision-making. Often, the state is intended to summarize the relevant information in the history.
A useful state representation can be a sufficient statistic: once the state is known, the rest of the history is unnecessary for predicting future outcomes.
Markov Property
A state St is Markov if the distribution of the next state depends only on the current state and current action, not on the entire prior history.
Formally:
The key intuition is:
Given the present state, the future is independent of the past.
If the complete history is used as the state, the Markov property is automatically satisfied. However, this is usually inefficient because the history may be very large. The goal is often to construct a smaller state that still preserves the information necessary for prediction and control.
Example: Blood Pressure
An agent could store a person’s entire blood-pressure history. In some settings, it may be sufficient to store only recent blood pressure and other current health information.
The smaller representation is more practical, but it is valid only if it preserves the information needed to predict the effects of future actions.
State versus Observation
A state and an observation are not always the same.
An observation is the immediate information received from the environment.
A state is the information representation sufficient for predicting and choosing actions.
Atari Example
For Atari games, using only the current image may not reveal the velocity of moving objects. A sequence of recent frames provides temporal information.
Using the last four frames can help the agent infer:
Direction of motion.
Velocity.
Acceleration.
Changes in object position.
Thus, several observations may be combined to form a more useful state representation.
Representation Trade-Offs
State representations involve a trade-off between simplicity and expressiveness.
Small or Simple States
Easier and faster to process.
Require less data.
May fail to capture important aspects of the environment.
Can produce poor decisions because relevant information is missing.
Rich or Expressive States
Capture more of the environment’s complexity.
May improve final performance.
Require more computation and data.
May be harder to learn from.
This resembles the general machine learning trade-off between bias and variance: an overly simple representation may be systematically inaccurate, while an overly complex one may require substantial data and computation.
Partial Observability
A world is partially observable when the agent cannot directly observe the complete underlying state.
The agent receives noisy or incomplete observations and must infer hidden information.
Student Knowledge Example
In an educational tutoring system, the student’s true knowledge may be latent:
The tutor cannot directly observe whether the student has mastered addition.
It observes whether the student answers a problem correctly.
Correctness is noisy because students can guess correctly or make occasional mistakes.
Therefore, the student’s actual knowledge state is different from the tutor’s immediate observations.
Robot Localization Example
A robot using a laser rangefinder may measure distances to walls at different angles. Rooms with similar geometry can produce identical sensor readings.
The robot may be unable to determine:
Which floor it is on.
Which room it occupies.
Its exact location in the building.
The same observation can correspond to multiple underlying states. This makes the environment partially observable.
Partially observable problems often require maintaining beliefs or summaries of what the hidden state might be, rather than treating the immediate observation as the complete state.
Deterministic and Stochastic Dynamics
Deterministic Environments
In a deterministic environment, a state-action pair produces a predictable next state.
For example, placing a Go piece on an empty legal location produces a known board configuration.
Stochastic Environments
In a stochastic environment, the same state-action pair may lead to different outcomes.
For example, flipping a coin produces either heads or tails, and the outcome cannot be known with certainty beforehand.
RL models generally allow stochastic dynamics because real-world actions often have uncertain results.
Bandits and Sequential Decision-Making
A bandit problem is a simplified decision problem in which an action affects the immediate reward but does not change the future state.
For example, suppose a website displays an advertisement to each independent customer:
The action is which advertisement to show.
The reward is whether the customer clicks or purchases.
One customer’s response does not affect the next customer’s situation.
This differs from a full sequential decision problem, where an action can alter future states and therefore influence later rewards.
Bandits still involve exploration because the agent must learn which actions produce better rewards, but they do not involve long-term state transitions in the same way as an MDP.
Markov Decision Processes
A Markov decision process (MDP) is a formal framework for sequential decision-making under uncertainty.
An MDP typically includes:
A state space S.
An action space A.
A transition or dynamics model.
A reward model.
A policy.
A time horizon.
Often, a discount factor.
Dynamics Model
The dynamics model describes how the environment changes after an action.
It specifies the distribution over next states:
For a stochastic environment, the model gives probabilities for multiple possible outcomes.
For example, a Mars rover in state S1 may try to move right. It might:
Move to S2 with some probability.
Remain in S1 with another probability.
Move in an unintended direction if the action is unreliable.
A model may represent:
The true dynamics of the world.
The agent’s estimated or learned dynamics.
These need not be identical. The agent may have an inaccurate model because it has limited experience or because its assumptions are wrong.
Reward Model
The reward model specifies the immediate desirability of an outcome.
Different conventions define rewards as functions of:
The current state: R(St).
The current state and action: R(St,At).
The current state, action, and next state: R(St,At,St+1).
The third convention is the most expressive because the reward can depend on the transition itself. For example, reaching a particular location may be rewarding even if merely being in the original state is not.
The reward model should accurately represent the intended objective. If it rewards only a convenient proxy, the agent may exploit that proxy in undesirable ways.
Mars Rover Example
Imagine a very small Mars containing seven possible locations.
State: The rover’s current location, one of S1,S2,…,S7.
Actions: Try to move left or try to move right.
Rewards: A field site may provide reward +1, another may provide reward +10, and other locations may provide reward 0.
Dynamics: Movement may fail or result in an unintended location because the rover is imperfect.
The rover must choose actions that maximize cumulative reward while accounting for uncertain movement.
Policies
A policy specifies how the agent chooses actions.
Deterministic Policy
A deterministic policy maps each state to one action:
For every state s, the policy selects a single action a.
Example:
If the rover is in S1, move right.
If the rover is in S2, move right.
Continue moving right in every state.
Stochastic Policy
A stochastic policy specifies a probability distribution over actions:
For example, in a particular state, the agent might:
Choose action a1 with probability 0.9.
Choose action a2 with probability 0.1.
Stochastic policies are useful when:
The environment is uncertain.
Randomization prevents predictable behavior.
The agent needs to explore.
Multiple actions may be similarly valuable.
A policy can change during learning. An agent may begin with a poor policy, explore different actions, and gradually shift toward a policy that achieves higher expected reward.
Policy Evaluation and Policy Control
Policy Evaluation
Policy evaluation asks:
How good is a given fixed policy?
The policy is supplied, and the agent estimates the expected reward obtained by following it.
For example, a business may deploy a fixed advertising policy and measure the resulting revenue.
Policy Control
Policy control asks:
Which policy should the agent use?
The agent searches for a policy that maximizes expected cumulative reward. This generally requires trial and error, strategic exploration, and evaluation of alternative policies.
Evaluation is often a subproblem of control:
Evaluate a candidate policy.
Identify its weaknesses.
Modify the policy.
Evaluate the improved policy.
Continue until performance is satisfactory.
Planning, Learning, and Model-Free Methods
Planning
In planning, the agent is given:
The state space.
The action space.
The transition or dynamics model.
The reward model.
The agent uses these models to compute a high-quality or optimal policy without necessarily needing to learn the model through direct interaction.
Learning
In RL learning settings, the agent must gather experience and use it to improve decisions. The agent may not initially know:
How actions change the environment.
Which actions are rewarding.
Which states are valuable.
Which policy is optimal.
The agent’s choices affect both its rewards and the information it obtains, creating the exploration-exploitation challenge.
Model-Based and Model-Free RL
Model-Based RL
Model-based methods explicitly represent or learn the environment’s dynamics and rewards. They can use the model to predict future outcomes and plan.
Model-Free RL
Model-free methods learn values or policies directly from experience without explicitly learning a complete model of the environment.
Both approaches have advantages and limitations:
Model-based methods can support planning but may suffer when the learned model is inaccurate.
Model-free methods may avoid model errors but can require more experience.
Errors in a model can propagate through multi-step predictions and ultimately lead to poor decisions.
Markov Chains and Markov Reward Processes
Markov Chains
A Markov chain is a memoryless stochastic process with:
A finite set of states.
A transition model.
No actions.
No rewards.
The Markov property means that the next state depends only on the current state.
For a finite state space, the transition model can be represented by a matrix P, where:
Each row of the transition matrix must sum to 1:
This is required because the process must transition to some possible next state with total probability 1.
To generate an episode from a Markov chain:
Select an initial state.
Sample the next state using the transition probabilities.
Continue sampling according to the current state.
Markov Reward Processes
A Markov reward process (MRP) is a Markov chain augmented with rewards and a discount factor.
An MRP contains:
A finite state space.
A transition model.
A reward function.
A discount factor γ.
No actions or policies.
The reward function can be written as a vector when each state has an associated expected reward.
For example, a Mars rover MRP could assign:
Reward +1 to one state.
Reward +10 to another state.
Reward 0 to all remaining states.
Horizon, Return, and Value
Horizon
The horizon is the number of time steps over which rewards are considered.
Finite Horizon
The process ends after a fixed number of steps.
Infinite Horizon
The process may continue indefinitely. In this case, discounting is often needed to keep total return finite.
Return
The return Gt is the cumulative discounted reward from time t onward.
For a finite horizon T:
Equivalently:
The discount factor γ satisfies 0≤γ≤1.
Discount Factor
The discount factor determines how much future rewards matter relative to immediate rewards.
γ=0: Only the immediate reward matters.
A value of γ close to 1: Long-term rewards matter substantially.
γ=1: All rewards are weighted equally, when the total remains well-defined.
Discounting is useful because it:
Represents preference for earlier rewards.
Makes infinite-horizon sums mathematically manageable.
Keeps cumulative rewards bounded in many settings.
Makes policies with infinite cumulative rewards easier to compare when γ<1.
For finite episodes, it is often possible to use γ=1 because the reward sum contains only finitely many terms.
Value Function
The value function gives the expected return from a state.
For an MRP:
The value is generally not equal to the actual return from one trajectory because stochastic transitions can lead to different future states and rewards. Instead, it is an average over possible future trajectories.
The value of a state is the expected cumulative discounted reward obtained from that state onward.
Value functions are fundamental because they allow an agent to compare states according to their expected long-term consequences. In decision processes, analogous value functions can evaluate policies and support the search for better actions.

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