Reinforcement learning: agents, rewards and trial and error
Reinforcement learning is a machine learning technique in which an agent learns to make decisions by interacting with an environment and receiving rewards as feedback. The agent's goal is to maximize its cumulative reward, and it improves its behavior through trial and error without labeled examples.

What is reinforcement learning?
Reinforcement learning (RL) is a machine learning approach where models learn to make decisions by repeatedly trying actions and receiving feedback. Actions that help achieve a goal are encouraged through positive reinforcement, while those that hinder progress are not, according to the AWS explanation of reinforcement learning.
Reinforcement learning is based on the concept that an agent learns by interacting with its environment, trying different actions, and receiving rewards as feedback. With no human supervision, the agent gradually improves its performance, as demonstrated in the Hugging Face deep RL course introduction.
Reinforcement learning differs from supervised and unsupervised learning. In supervised learning, models are trained with labeled datasets to make predictions, while unsupervised learning finds patterns in unlabeled data. Reinforcement learning instead uses trial and error and a reward signal, as explained in the IBM overview of reinforcement learning.
Key concepts and terminology
In reinforcement learning, the agent and the environment are the two primary components. The environment is the external world the agent interacts with. At each step, the agent observes either the full state or a partial observation, chooses an action, and then receives a reward that reflects how good the resulting state is, as detailed in the OpenAI Spinning Up introduction to RL.
A state is a complete description of the world, while an observation is a partial description. The set of all valid actions is called the action space, which can be discrete, such as four directions in a platform game, or continuous, such as a car steering angle. The policy is the rule used by the agent to decide actions, and it can be deterministic or stochastic. In deep RL, policies are parameterized functions, such as neural networks.
Four principal sub-elements characterize RL problems: the policy, the reward signal, the value function, and the model of the environment. The policy defines behavior by mapping states to actions, the reward signal designates the goal, and the value function specifies what is good in the long run.
The learning process and the reward hypothesis
The RL process is a loop of state, action, reward, and next state. The agent receives a state from the environment, takes an action, the environment moves to a new state, and the agent receives a reward. This loop generates a sequence, and the agent's goal is to maximize its cumulative reward, called the expected return, as outlined in the Hugging Face reinforcement learning framework.
The reward hypothesis states that all goals can be described as the maximization of the expected return. To handle the unpredictability of future rewards, a discount rate gamma, between 0 and 1, is used. A larger gamma means the agent cares more about long-term reward, while a smaller gamma focuses on short-term rewards. The RL process is often formalized as a Markov decision process (MDP), where the agent needs only the current state to decide the next action, not the full history.
Because an RL agent has no labeled input data, it must explore its environment, attempting new actions to discover those that receive rewards. However, it must also exploit known actions that yield high rewards. This exploration-exploitation trade-off is central to RL algorithms.
Applications and examples
Reinforcement learning has been used to create breakthrough AI for complex strategy games. AlphaGo, for example, combined deep neural networks with advanced search algorithms. A policy network selects the next move, and a value network predicts the winner. AlphaGo was introduced to thousands of expert games and then played against itself thousands of times, learning from its mistakes, as described on the Google DeepMind AlphaGo page.
In deep reinforcement learning, a convolutional neural network can learn control policies directly from high-dimensional sensory input. A model trained with a variant of Q-learning used raw pixels as input and output a value function estimating future rewards. Applied to seven Atari 2600 games, it outperformed all previous approaches on six games and surpassed a human expert on three, as reported in the arXiv paper Playing Atari with Deep Reinforcement Learning.
| Type | Data used | Feedback | Objective |
|---|---|---|---|
| Reinforcement | Interactions with environment | Rewards and punishments | Maximize cumulative reward |
| Supervised | Labeled examples | Correct outputs | Predict labels accurately |
| Unsupervised | Unlabeled data | No explicit feedback | Find hidden patterns |
Frequently asked questions
What is the reward hypothesis in reinforcement learning?
The reward hypothesis states that all goals can be described as the maximization of the expected return, or expected cumulative reward. It is why the agent's objective is to maximize the sum of rewards it receives over time, as outlined in the Hugging Face framework.
What is the exploration-exploitation trade-off?
The agent must explore new actions to discover which ones yield rewards, but it must also exploit known actions that have produced high rewards in the past. A balance between exploration and exploitation is necessary because relying solely on either would prevent optimal learning, as explained by IBM and AWS.
How does reinforcement learning differ from supervised learning?
Supervised learning uses manually labeled examples to teach a model correct predictions, while reinforcement learning has no labeled examples. Instead, the agent learns by interacting with the environment and receiving rewards as feedback, as noted in the IBM overview.
What are the key components of an RL problem?
The key components are the policy, which determines the agent's actions; the reward signal, which defines the goal; the value function, which estimates long-term reward; and the environment model, which describes how the environment changes, as described in the IBM overview.
What is a Markov decision process in reinforcement learning?
A Markov decision process (MDP) is a mathematical framework used to describe the RL environment. It relies on the Markov property, meaning the agent needs only the current state to decide the next action, not the entire history of states and actions, as explained in the Hugging Face framework.