Reinforcement Learningintermediatemust-know5 min

Value-Based vs Policy-Based Methods

Learn how good each action is, or learn what to do directly?

Reinforcement Learning algorithms divide into Value-Based methods (Q-Learning, DQN) and Policy-Based methods (REINFORCE, PPO). Value-based methods learn action-value function Q(s, a), deriving implicit greedy policies a = argmax_a Q(s, a). Policy-based methods parameterize policy π_θ(a|s) directly, optimizing parameters θ via gradient ascent on expected return. Actor-Critic methods combine both: an Actor policy π_θ(a|s) and a Critic value function V_ϕ(s).

Reinforcement Learningintermediatemust-know4 min

Multi-Armed Bandits

Choosing between slot machines, which is secretly how A/B tests and feeds work.

A Multi-Armed Bandit (MAB) is a simplified Reinforcement Learning framework where an agent chooses among K independent actions ("arms") to maximize cumulative reward. Unlike full MDPs, bandits have no state transitions—each action choice is stateless and independent. MABs replace traditional static A/B testing in digital marketing, ad click optimization, and website UI layout experiments by dynamically routing traffic to high-performing variations while continuously testing alternatives.

Reinforcement Learningadvancedmust-know5 min

Proximal Policy Optimization

The workhorse of reinforcement learning, and the algorithm behind classic RLHF.

PPO is the go-to reinforcement learning algorithm, and it is the one used in classic RLHF for chatbots. Plain policy gradient methods can take one oversized update and wreck a policy that was working well. PPO prevents that by limiting how much the probability of any action can change in a single update. If an update would move it by more than a small amount, the extra change is ignored. That keeps learning steady, and it is far simpler than earlier methods with the same aim.

Reinforcement Learningintermediate4 min

Markov Decision Processes

The simple framework behind every reinforcement learning problem.

A Markov Decision Process (MDP) is the mathematical foundation of Reinforcement Learning. An MDP is defined as a 5-tuple (S, A, P, R, γ): States S, Actions A, Transition Probability P(s'|s,a), Reward function R(s,a,s'), and Discount factor γ ∈ [0, 1). The core assumption is the Markov Property: future state s_{t+1} depends ONLY on current state s_t and action a_t, independent of past history.

Reinforcement Learningintermediate5 min

Bellman Equations

The value of where you are equals the reward now plus the value of what comes next.

Bellman Equations form the recursive foundation of dynamic programming and Reinforcement Learning. They express the value of a state V(s) or state-action pair Q(s,a) as the immediate reward plus the discounted expected value of successor states. Bellman Expectation Equations evaluate a fixed policy π; Bellman Optimality Equations define the unique optimal value functions V*(s) and Q*(s,a). Dynamic Programming methods (Policy Iteration, Value Iteration) solve Bellman equations iteratively.

Reinforcement Learningintermediate4 min

Q-Learning

Learning the best action in every situation, purely by trial and error.

Q-learning teaches an agent which action is best in each situation, purely by trial and error, without needing a model of how the world works. It keeps a score for every situation and action, estimating the total future reward of taking that action there. After each move it nudges that score toward the reward it just got plus the best score available from where it landed. It learns the best behaviour even while still exploring with random moves, which is why it is called off-policy.

Reinforcement Learningintermediate5 min

ε-greedy, UCB & Thompson Sampling

Stick with what works, or try something that might be better?

Every learning system that chooses actions faces the same dilemma: keep picking what has worked best so far, or try something else that might be better. Epsilon-greedy picks the best option most of the time and a random one occasionally. Upper confidence bound favours options that are either good or still uncertain, giving untried ones the benefit of the doubt. Thompson sampling keeps a belief about how good each option is, and picks each in proportion to its chance of being best.

Reinforcement Learningintermediate5 min

Why RL Is Sample-Inefficient

Why reinforcement learning needs millions of tries, and how to need fewer.

Reinforcement Learning is notoriously sample-inefficient, often requiring tens of millions of environment interaction steps (equivalent to weeks of real-world time) to learn basic control tasks. Sample inefficiency stems from high-variance credit assignment, sparse rewards, non-stationary policy data distributions, and model-free trial-and-error. Mitigation strategies include Off-Policy Replay Buffers (SAC / TD3), Model-Based RL (World Models, MBPO, DreamerV3), Pre-trained Representations, and Reward Shaping.

Reinforcement Learningadvanced5 min

SARSA vs Q-Learning (On vs Off Policy)

Two near-identical algorithms that behave very differently near a cliff edge.

SARSA and Q-Learning are two foundational Temporal Difference (TD) Reinforcement Learning control algorithms. SARSA is On-Policy: its name derives from tuple (S_t, A_t, R_{t+1}, S_{t+1}, A_{t+1}), updating Q(s,a) using the actual next action a_{t+1} selected by the exploratory behavior policy π. Q-Learning is Off-Policy: it updates Q(s,a) using the maximum greedy action max_{a'} Q(s',a') ignoring the actual exploratory action taken. SARSA learns safer policies when exploration risks (e.g. falling off a cliff) carry high negative penalties.

Reinforcement Learningadvanced5 min

Deep Q-Networks & Replay Buffers

How a neural network learned to play Atari straight from the screen.

Deep Q-networks, from DeepMind, combined Q-learning with a neural network and learned to play Atari games straight from screen pixels. Simply plugging a neural network into Q-learning tends to blow up during training, so DQN added two fixes. Experience replay stores past moves and trains on random samples of them, so the network is not fed a stream of near-identical moments. A target network, a frozen copy updated only occasionally, gives learning a stable goal instead of one that shifts every step.

Reinforcement Learningadvanced5 min

Policy Gradients & REINFORCE

Do more of what led to reward, less of what did not. That is the whole idea.

Most reinforcement learning methods score actions and then pick the best one. Policy gradient methods skip that and directly adjust the policy, the rule for choosing actions, to make good outcomes more likely. REINFORCE, the simplest version, plays a whole episode, then raises the probability of every action it took in proportion to how much reward followed. It is easy to understand and needs no model of the world, but its updates are very noisy, so it learns slowly without extra tricks.

Reinforcement Learningadvanced5 min

Actor–Critic Methods

One network picks actions, another judges them, and both learn faster together.

Actor-Critic methods combine Policy-Based (Actor) and Value-Based (Critic) reinforcement learning. The Actor parameterizes policy π_θ(a|s), selecting actions; the Critic parameterizes value function V_ϕ(s) or Q_ϕ(s,a), evaluating action quality. By replacing high-variance Monte Carlo trajectory returns G_t with the Advantage function A(s,a) = Q(s,a) - V(s) estimated via 1-step TD bootstrapping r + γ V(s') - V(s), Actor-Critic architectures achieve significantly lower gradient variance and higher sample efficiency.

Reinforcement Learningadvanced5 min

GRPO & Group-Relative Methods

How DeepSeek trained its reasoning models without a second critic network.

GRPO is a cheaper way to do reinforcement learning on language models, used by DeepSeek for its reasoning models. Standard PPO needs a second large network, the critic, just to estimate how good each answer should be, which roughly doubles memory. GRPO drops the critic. For each prompt it generates a group of answers, scores them all, and judges each answer by how much better or worse it did than the group average. Above-average answers are reinforced and below-average ones discouraged.

Reinforcement Learningadvanced5 min

Advantage Estimation & GAE

Was that action better than expected? Estimating that well is most of the job.

The advantage measures how much better an action was than what the agent expected in that situation, and it drives most policy updates. Estimating it involves a trade-off. Looking only one step ahead gives a steady estimate that can be systematically wrong. Waiting for the whole episode gives an unbiased estimate that is very noisy. Generalised advantage estimation, used in PPO, blends estimates from every horizon in between, with a single setting that chooses where to sit between steady and unbiased.

Reinforcement Learningadvanced5 min

Contextual Bandits in Production

Bandits that personalise each choice to the user in front of them.

Contextual Bandits extend Multi-Armed Bandits by observing a context vector x_t (user profile, location, device, time) before choosing an action a_t. Unlike full MDPs, action choices do not alter future state transitions. Contextual Bandits form the core foundation of production recommendation feeds (news ranking, ad targeting, dynamic push notifications). Algorithms include LinUCB (linear reward modeling with ridge confidence bounds) and Contextual Thompson Sampling (sampling weights from Bayesian ridge regression posteriors).

Reinforcement Learningadvanced5 min

Reward Shaping & Specification Gaming

Reward the wrong thing and the agent will find a loophole, every time.

Reward shaping adds small extra rewards to guide an agent toward its goal faster when the real reward is rare. The danger is that the agent optimises exactly what you reward, not what you meant. In one famous case, a boat-racing agent learned to circle forever collecting bonus points instead of finishing the race. This is called reward hacking. A safe way to shape rewards is to base them on progress toward the goal, a method proven not to change which behaviour is truly best.

Reinforcement Learningadvanced5 min

Offline RL

Learning to act well from old logs, without trying anything new.

Offline Reinforcement Learning (Batch RL) trains policies exclusively on static, pre-collected datasets D = {(s, a, r, s')} without any real-time environment interaction. Standard off-policy algorithms (DQN, SAC) fail catastrophically in offline settings due to Out-of-Distribution (OOD) Action Extrapolation Error: the Q-function overestimates un-observed actions (argmax_a Q(s,a)), causing the policy to choose catastrophic OOD actions. Offline RL algorithms (CQL, IQL, TD3+BC) constrain policy updates to stay within the empirical data distribution.

Reinforcement Learningadvanced5 min

Imitation & Inverse RL

Learning by copying an expert, instead of designing a reward.

Imitation Learning trains an agent policy to mimic expert human behavior from demonstration trajectories D_{expert} = {(s_0, a_0), (s_1, a_1), ...}. Behavioral Cloning (BC) frames imitation as supervised regression/classification, but suffers from Compounding Covariate Shift errors. DAgger (Dataset Aggregation) resolves compounding errors by iteratively querying human experts on agent-visited states. Inverse Reinforcement Learning (IRL - GAIL) infers the implicit reward function R(s,a) optimized by the expert, using adversarial training to match expert state-action distributions.

SCROLL · SAVE · TAP TO GO DEEPER