Reinforcement Learning Overview
Reinforcement Learning: Learning to Make Good Decisions
Reinforcement learning is the study of how an automated agent can learn through experience to make good decisions.
This definition is simple, but the problem it describes is remarkably difficult. A reinforcement-learning agent does not merely identify objects, classify data, or predict labels. It must decide what to do, observe what happens, learn from the consequences, and improve its future decisions. The consequences may be immediate or may appear much later, and the agent may have to learn despite uncertainty and limited data.
Reinforcement learning is therefore both:
- a central part of artificial intelligence, because intelligence requires decision-making; and
- a practical approach for solving difficult real-world and computational problems.
Why Decision-Making Matters for Intelligence
Many advances in machine learning have focused on perception: recognizing faces, identifying cars, detecting cats, or interpreting language. Perception answers questions such as “What is present?” or “What does this input represent?”
Intelligent behavior also requires answering a different question: “What should be done next?”
A system might recognize a pedestrian in front of a self-driving car, for example, but recognition alone does not determine whether the car should brake, turn, or continue. Similarly, a medical system may identify a patient’s condition but still need to decide which treatment to recommend. A language model may understand a prompt but still need to produce a useful, safe, and appropriate response.
Reinforcement learning focuses on this decision-making problem. The agent attempts to choose actions that produce desirable outcomes over time. This makes reinforcement learning important for broader efforts toward artificial intelligence, since a generally intelligent system must be able to use information to choose effective actions.
The question of how to learn good decisions under uncertainty and with limited data has been studied since at least the 1950s. A particularly important influence was the work on dynamic decision-making and optimization associated with Richard Bellman. Bellman’s ideas provide a foundation for reasoning about how current decisions affect future rewards.
Practical Successes of Reinforcement Learning
Reinforcement learning has become practically important because it has produced strong results in several challenging domains.
Playing Go
Go is a board game with an enormous number of possible positions and strategies. Its search space is much larger than that of chess, and for many years it was considered a major unresolved challenge for artificial intelligence.
A successful Go-playing system combined reinforcement learning with Monte Carlo Tree Search. The system learned to choose moves and used search to explore possible future game positions. It eventually achieved performance beyond the strongest human players.
This example demonstrated two important strengths of reinforcement learning:
- An agent can improve through experience rather than relying only on rules written by humans.
- An agent can discover effective strategies that human experts had not previously identified.
Controlling Fusion Systems
Fusion science investigates potential ways to produce energy through nuclear fusion. One difficult control problem involves manipulating magnetic coils to control the shape of plasma inside a vessel.
A reinforcement-learning system can learn how to command these coil controllers so that the plasma takes desired shapes. Deep reinforcement learning made it possible to find flexible control strategies that had not previously been expected.
The important idea is that reinforcement learning can control complex physical systems whose behavior is difficult to describe with simple hand-written rules.
Allocating COVID-19 Tests
During the COVID-19 pandemic, some regions had limited testing resources and needed to decide whom to test. Testing every person was not always possible, so testing policies had to use available information strategically.
A reinforcement-learning approach was used at borders in Greece. The system used changing data to decide which travelers should be tested in order to help control the spread of the epidemic.
This example illustrates that reinforcement learning can be useful when:
- resources are limited;
- the environment changes over time;
- decisions influence future information; and
- the best strategy must be learned from data.
ChatGPT and Reinforcement Learning from Human Feedback
Large language models initially learned largely through exposure to text and supervised examples. A central method used in systems such as ChatGPT is reinforcement learning from human feedback, commonly abbreviated RLHF.
The process can be understood as several stages.
Stage 1: Imitation Learning
First, a language model is trained using examples of prompts and responses. For example:
- Prompt: “Explain reinforcement learning to a six-year-old.”
- Example response: “Reinforcement learning is like giving rewards and punishments to teach a system what to do.”
The model learns to produce responses resembling the examples. This is a form of behavior cloning or imitation learning, because the model imitates observed behavior.
Although this is commonly implemented using supervised learning, the data concerns decisions or actions—in this case, which response should be generated.
Stage 2: Learning a Preference or Reward Model
Not every response found in human-generated text is equally useful. Therefore, people can compare multiple responses and indicate which one they prefer.
For example, a person might rank:
- a response that is accurate, clear, and relevant;
- a response that is partially correct but confusing; and
- a response that is incorrect or inappropriate.
These comparisons are used to train a preference model, also called a learned reward model. The model estimates how desirable a response is according to human judgments.
Stage 3: Reinforcement Learning Using the Learned Reward
The language model then generates responses and receives scores from the learned reward model. Reinforcement learning adjusts the model so that it increasingly produces responses with high predicted value.
This procedure is called reinforcement learning from human feedback because the reward signal originates from human preferences.
RLHF is different from ordinary imitation learning:
- Imitation learning treats demonstrated responses as examples to copy.
- RLHF uses human comparisons to learn what makes one response preferable, then optimizes the model toward that preference.
Imitation can be useful, but it may limit performance to the quality of the demonstrations. If the demonstrations contain mistakes or merely represent average human behavior, imitation may reproduce those limitations. Reinforcement learning can potentially discover behavior that is better than the demonstrations, provided the reward signal and learning process support that improvement.
Four Central Features of Reinforcement Learning
Four ideas commonly characterize reinforcement learning:
- optimization;
- delayed consequences;
- exploration; and
- generalization.
These features often appear together, although different applications may emphasize them differently.
Optimization
Reinforcement learning is concerned with choosing the best actions according to some notion of utility, reward, or value.
Suppose a system must find a route between two cities. If one route has distance 100 kilometers and another has distance 150 kilometers, the first route is preferred because it has lower cost. The alternatives can be directly ranked.
In reinforcement learning, optimization means that the agent is not merely trying to predict what will happen. It is trying to select actions that lead to better outcomes.
A reward is often represented as a numerical quantity. Larger rewards indicate more desirable outcomes, while smaller or negative rewards indicate less desirable outcomes. The numerical scale allows different possible decisions or trajectories to be compared.
Delayed Consequences
An action may have consequences far beyond the current time step.
Saving money for retirement provides a familiar example. Saving may reduce spending in the present, but it can produce a larger benefit in the future. In a video game, an early action may seem unhelpful but later create an important advantage.
Delayed consequences create two major difficulties.
Planning Difficulty
Even when the rules of the environment are known, it can be difficult to determine which action is best because each action changes the future situation.
Chess illustrates this problem. The rules are known, but selecting a strong move requires considering a large number of possible future positions and responses. Long-term planning is difficult because the consequences of an action branch into many possibilities.
Temporal Credit Assignment
When the agent receives a reward much later, it must determine which earlier actions deserve credit or blame. This problem is called temporal credit assignment.
For example, suppose an agent takes a series of actions and eventually receives a large reward. Which action caused the success? Perhaps the most recent action was important, or perhaps an earlier decision created the conditions for success.
Human life contains the same difficulty. A successful outcome may result from many earlier choices, such as practicing, sleeping well, studying, or making a particular application decision. If the reward arrives only at the end, identifying the contribution of each earlier choice is challenging.
Effective reinforcement learning must use later outcomes to improve decisions that occurred earlier in the sequence.
Exploration
A reinforcement-learning agent often learns about the world only by trying actions. This creates a tension between exploiting actions that already seem good and exploring actions whose value is uncertain.
Learning to ride a bicycle illustrates exploration. A learner must attempt different movements, experience failures, and gradually discover how to balance and steer. The necessary information comes from direct interaction.
A crucial feature of exploration is that information is censored: the agent learns about what it tries, but not directly about what it does not try.
This creates a counterfactual problem. If a person chooses one university, that person generally cannot observe exactly what life would have been like at another university. Similarly, if a company gives a promotion to a customer, it cannot observe what would have happened to that same customer without the promotion.
Observing one customer without a promotion does not completely solve the problem, because that customer may differ from the customer who received the promotion. The desired comparison concerns the same situation under two different possible actions, but only one action is actually observed.
Exploration is therefore necessary for discovering information, but it can also involve risk. An agent may need to try actions whose outcomes are uncertain in order to learn whether they are better than familiar alternatives.
Generalization
The number of possible situations in a realistic environment can be extremely large. A policy is a rule that maps the agent’s information to an action. In a small environment, the policy might be written as a table:
- If the robot is in location S1, move right.
- If the robot is in location S2, move left.
- If the robot is in location S3, remain still.
This approach becomes impossible when the input space is large. Consider a video game with an image of size 300×400 pixels and at least 256 possible colors per pixel. The number of possible images is at least
256300×400.A policy cannot realistically list a separate action for every possible image. The agent must instead generalize from situations it has experienced to new situations it has not seen exactly before.
Deep neural networks and other function-approximation methods can help represent policies in these large spaces. Rather than storing an independent decision for every input, a model learns patterns that apply across related inputs.
Generalization creates a trade-off. A small, simple representation may be fast to learn but may fail to capture important details. A highly expressive representation may model the environment more accurately but require more data and computation.
How Reinforcement Learning Differs from Other Approaches
Reinforcement learning overlaps with several areas of artificial intelligence, but its combination of features is distinctive.
AI Planning
Planning generally assumes that the system knows how the world works and tries to choose a sequence of actions that optimizes an objective.
Planning can involve:
- optimization;
- delayed consequences; and
- generalization when the state space is large.
Reinforcement learning includes these concerns but usually adds learning from interaction, uncertainty about the environment, and exploration.
Supervised Learning
In supervised learning, a system receives examples with correct labels. For instance, an image may be labeled “cat” or “not cat.” The system learns to predict the correct label for new examples.
Supervised learning primarily involves:
- learning from data; and
- generalizing to new inputs.
The loss function in supervised learning measures how closely the prediction matches the label. This is different from a reinforcement-learning utility, which evaluates the desirability of an action or outcome in a decision process.
Unsupervised Learning
In unsupervised learning, the data does not come with explicit correct labels. The system attempts to discover useful structure or representations in the data.
Unsupervised learning involves:
- learning from observed data; and
- generalization.
It normally does not directly specify a utility for choosing actions.
Imitation Learning and Behavior Cloning
Imitation learning uses examples of good behavior to train an agent. These examples are often called demonstrations or expert trajectories.
A demonstration is a sequence showing what an expert did in different situations. For example, a human driver could operate a car while recording:
- the visual input;
- the vehicle’s state; and
- steering, braking, and acceleration actions.
A model could then learn to map situations to actions that resemble the expert’s behavior.
The simplest form of imitation learning reduces the decision problem to supervised learning:
- observe the expert’s situation;
- record the expert’s action;
- train a model to predict that action in similar situations.
This approach avoids some of the difficulty of reinforcement learning because the learner does not need to explore the environment to find useful behavior. However, it also has limitations:
- the demonstrations may contain errors;
- the learner may not encounter exactly the same situations as the expert;
- the learner generally cannot exceed the quality of the demonstrations; and
- imitation does not automatically determine the underlying reward or objective.
More advanced imitation methods may attempt to infer the reward function that would explain the expert’s behavior. That requires techniques beyond simply copying the demonstrated actions.
Reinforcement learning is especially promising when there are no demonstrations, when the demonstrations are poor, or when performance beyond the demonstrated behavior is desired.
Reward Hacking and Objective Design
A reinforcement-learning agent optimizes the reward it is given, not necessarily the designer’s unstated intention. If the reward is poorly specified, the agent may find an unintended way to maximize it. This is called reward hacking.
Consider an educational tutor that receives a reward of +1 when a student answers correctly and −1 when the student answers incorrectly. The tutor can choose whether to give addition or subtraction problems.
If the tutor only cares about immediate correctness, it may discover that very easy addition problems produce more positive rewards than difficult subtraction problems. The tutor may then give only easy questions. That behavior maximizes the specified reward but fails to achieve the broader goal of helping the student learn both addition and subtraction.
A robotics example has the same structure. Suppose a robot receives a positive reward when there are no dishes on a counter. The robot might push the dishes onto the floor. The counter is empty, so the reward condition is technically satisfied, but the intended task—cleaning the kitchen—has not been accomplished.
A better reward would evaluate whether the dishes were placed in the dishwasher and whether the dishwasher completed its cycle. The reward must reflect the actual goal rather than an incomplete proxy.
Reward design is difficult because real objectives are often complex, while reward functions must be specified in a form that an algorithm can optimize.
A reward function is a formal objective, not a complete statement of human intention. If the formal objective is incomplete, optimization may produce undesirable behavior that still earns high reward.
Sequential Decision-Making Under Uncertainty
A reinforcement-learning problem consists of an agent interacting with an environment over a sequence of time steps.
At each time step:
- the agent selects an action;
- the environment changes in response;
- the agent receives an observation;
- the agent receives a reward; and
- the agent uses the new information to select its next action.
This forms a feedback loop. The agent’s actions affect the environment, and the environment’s responses provide information for future decisions.
The objective is generally to maximize the total expected future reward. This means that an agent must often balance short-term and long-term outcomes.
Examples
Web Advertising
A website may choose which advertisement or product recommendation to display. It can observe:
- how long a person views the content;
- whether the person clicks;
- whether the person makes a purchase; and
- the resulting revenue.
The objective might be to maximize clicks, viewing time, purchases, or revenue.
Robotics
A robot may choose how to move one of its joints. It may receive camera images as observations and a reward related to whether it successfully completes a task, such as placing dishes into a dishwasher.
Blood Pressure Control
An agent may recommend exercise, medication, or another intervention. It can observe blood-pressure measurements and receive a reward for keeping pressure within a healthy range. A penalty could be assigned when measurements move outside that range.
In each example, the agent is making repeated decisions in an uncertain environment, and actions may affect later states and rewards.
Histories, Observations, and States
A history is the complete sequence of information available up to a particular time. A history at time t can be represented generally as
ht=(o1,a1,r1,o2,a2,r2,…,ot),where oi represents an observation, ai an action, and ri a reward. The exact ordering depends on the convention being used.
An observation is the information received at a particular time step. For the educational tutor, the observation might be whether the student answered the most recent problem correctly.
The history includes all prior observations, actions, and rewards. Because histories can grow without bound, directly storing the entire history may be impractical.
A state is a representation of the situation used to make decisions. Ideally, the state summarizes the history sufficiently well that the older history is no longer needed.
The Markov Property
A state is Markov when the future depends on the past only through the current state. Formally, the state satisfies the Markov property if
P(St+1∣St,At,Ht)=P(St+1∣St,At),where Ht is the prior history.
In words:
Given the present state and action, the past provides no additional information about the next state.
This is often expressed as “the future is independent of the past, given the present.”
Using the entire history as the state always makes the representation Markov in principle, because the history contains everything that has happened. However, that representation may be unnecessarily large. A more useful state is a compact sufficient statistic of the history.
For example, a health-control system might not need every blood-pressure measurement ever recorded. Recent measurements may be sufficient for predicting the next state and selecting an action.
State and Observation Are Not Always the Same
An observation is what the agent receives directly. The state is the information needed to predict the future and make good decisions. These can differ.
In a video game, a single image may not reveal the velocity of moving objects. Two identical images could correspond to an object moving left or right. Including several consecutive frames can provide information about motion.
For example, an agent might use the last four frames rather than only the most recent frame. Differences between the frames can reveal velocity or acceleration.
In educational tutoring, the student’s actual knowledge may be hidden. The tutor cannot directly observe whether the student has mastered addition. It only observes answers, which are noisy indicators because a student may guess correctly or make an occasional mistake despite understanding the topic.
This is a partially observable setting: the underlying state exists, but the agent cannot observe it directly.
A robotics system can face the same issue. A laser rangefinder may measure distances to nearby walls, but rooms with similar shapes may produce identical measurements. The robot may be unable to determine whether it is on the second floor or the third floor. Its observations do not uniquely identify its true state.
Deterministic and Stochastic Environments
A process is deterministic when an action in a given state always produces the same result. Placing a Go piece on a legal board position is approximately deterministic: the piece goes where it is placed.
A process is stochastic when an action can lead to multiple possible outcomes. Flipping a coin is the standard example. The action is known, but the result is uncertain.
Reinforcement-learning models commonly allow stochastic transitions because real environments contain uncertainty, imperfect control, and random events.
Bandits and Sequential Effects
In some problems, an action affects only the immediate reward and does not change the future state. This is the structure of a bandit problem.
For example, a website may show an advertisement to one customer. The customer may click or purchase, generating an immediate reward. If that decision does not influence the next customer’s preferences or situation, the action affects the current reward but not the next state.
In a full sequential decision problem, actions can change future states. A medical treatment can affect later health, a tutoring question can affect later knowledge, and a robot’s movement can change its future position.
The distinction matters because sequential problems require reasoning about how actions influence future opportunities and consequences.
Markov Decision Processes
A Markov decision process, or MDP, is a formal model for sequential decision-making. It contains:
- a set of states;
- a set of actions;
- a dynamics model describing state transitions;
- a reward model; and
- often a discount factor.
Dynamics Model
The dynamics model describes how the state changes after an action. It specifies a probability distribution over the next state:
P(St+1=s′∣St=s,At=a).For example, a Mars rover might be in state S1 and attempt to move right. It may reach S2 with probability 0.5 and remain in S1 otherwise.
The dynamics model represents the agent’s model of how the world works. It may be inaccurate because the agent has limited experience, the environment is complex, or the model was estimated incorrectly.
Reward Model
The reward model describes the immediate reward associated with a transition. Different conventions are possible. Reward may be represented as:
R(s),depending only on the current state;
R(s,a),depending on the current state and action; or
R(s,a,s′),depending on the current state, action, and next state.
The last two forms are especially useful when the action or the resulting transition affects the reward.
Policies
A policy is a rule for selecting actions. A deterministic policy maps each state to one action:
π(s)=a.A stochastic policy specifies a probability distribution over actions:
π(a∣s)=P(At=a∣St=s).For example, a rover policy might always attempt to move right. An advertising policy might show one advertisement with probability 0.9 and another with probability 0.1 for a particular type of customer.
Stochastic policies are useful when randomization supports exploration or when several actions may be similarly valuable.
Mars Rover Example
Consider a simplified Mars environment with seven locations. The rover’s state is its current location. Its actions are “try left” and “try right.” Because the rover is imperfect, an attempted movement may fail.
Some locations contain scientifically valuable sites:
- one location gives reward +1;
- another gives reward +10;
- all other locations give reward 0.
The dynamics model describes where the rover goes after each attempted movement. The reward model describes the value of being in or reaching each location. A policy specifies what movement the rover should attempt in every possible location.
The central learning problem is to determine which policy maximizes expected long-term reward.
Evaluation, Control, Planning, and Learning
Two fundamental reinforcement-learning tasks are policy evaluation and policy control.
Policy Evaluation
Policy evaluation asks:
How good is a fixed policy?
The policy is already specified, and the goal is to estimate the expected reward that will result from following it.
Policy Control
Policy control asks:
Which policy is best?
The agent must search among possible policies and identify one that maximizes expected long-term reward. This usually requires trial and error, exploration, and some method for estimating the value of different choices.
Evaluation is often part of control. If the agent can estimate how well a policy performs, it can use that information to improve the policy.
Planning
In planning, the state space, action space, reward model, and dynamics model are given. The system uses the known model to compute a strong policy.
Learning
In reinforcement learning, the agent does not necessarily know the dynamics or rewards in advance. It must interact with the environment, collect experience, and use that experience to identify a good policy.
The agent’s choices affect not only its rewards but also the information it obtains. This is why exploration is central to learning.
Markov Chains and Markov Reward Processes
A useful progression begins with a Markov chain, adds rewards to form a Markov reward process, and then adds actions to form an MDP.
Markov Chains
A Markov chain is a memoryless stochastic process with a finite set of states and no actions or rewards.
Its transition model can be written as a matrix. Each entry gives the probability of moving from one state to another. For a transition matrix P,
Pij=P(St+1=j∣St=i).Every row must sum to 1 because, starting from a given state, the probabilities of all possible next states must account for every outcome:
j∑Pij=1.The columns do not generally need to sum to 1.
An episode can be generated by selecting an initial state and repeatedly sampling the next state from the transition probabilities.
Markov Reward Processes
A Markov reward process is a Markov chain augmented with rewards and a discount factor. It still has no actions; the transition process is fixed.
The reward function can be written as a vector, with one reward associated with each state. For example, a process might assign reward +1 to one state, reward +10 to another, and reward 0 elsewhere.
Return
The return is the total reward accumulated from a particular time step onward. With discount factor γ, the return at time t is
Gt=Rt+1+γRt+2+γ2Rt+3+⋯.For a finite horizon ending at time T, this becomes
Gt=k=0∑T−t−1γkRt+k+1.The return is the actual reward total from one realized trajectory. Because the process may be stochastic, different trajectories can produce different returns.
Value Function
The value function measures the expected return from a state:
V(s)=E[Gt∣St=s].The value is generally not the same as one observed return. A particular trajectory may receive unusually high or low rewards because of randomness, while the value averages over possible future trajectories.
Discounting
The discount factor γ determines how much future rewards matter relative to immediate rewards.
- If γ is close to 0, immediate rewards receive much more weight.
- If γ is close to 1, distant rewards matter almost as much as immediate rewards.
- If γ=1, all rewards are counted equally in a finite-horizon problem.
Discounting is useful for several reasons:
- It can represent the tendency to value immediate outcomes more highly than distant outcomes.
- It keeps infinite-horizon sums mathematically manageable.
- When rewards are bounded and γ<1, the total discounted return remains bounded.
- It makes it possible to compare policies without treating every infinite reward total as indistinguishable.
For an infinite-horizon process, the discounted return is typically written as
Gt=k=0∑∞γkRt+k+1,0≤γ<1.The Markov reward process provides the foundation for evaluating policies. Adding actions and policies leads to MDPs, where the central challenge becomes selecting actions that maximize expected discounted future reward.
Comprehensive Review
Reinforcement learning studies agents that learn through experience to make decisions that produce good outcomes. Unlike perception-focused machine learning, it must address action, consequences, utility, and long-term effects.
Its defining challenges include:
- optimization, because actions must be ranked by desirability;
- delayed consequences, because current actions can affect distant rewards;
- temporal credit assignment, because later outcomes must be connected to earlier decisions;
- exploration, because the agent learns primarily about actions it actually tries; and
- generalization, because realistic state spaces are too large for a separate decision in every possible situation.
Reinforcement learning has been applied to games, scientific control, epidemic testing, robotics, advertising, health management, and language-model alignment. Imitation learning can simplify learning by copying expert demonstrations, while RLHF improves on simple imitation by learning a reward or preference model from human comparisons.
A reinforcement-learning problem is commonly represented as an MDP with states, actions, transitions, rewards, and a policy. The Markov assumption allows the current state to summarize the relevant past: once the present state and action are known, earlier history does not provide additional information about the next state. When observations do not reveal the true state, the problem becomes partially observable.
Finally, a Markov chain describes stochastic state transitions without rewards or actions. Adding rewards creates a Markov reward process, whose return is a discounted sum of future rewards and whose value function is the expected return from a state. Adding actions and policies produces the full decision-making framework in which an agent must evaluate and improve behavior over time.

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