reinforcement learning

**Reinforcement Learning (RL)** is the **machine learning paradigm where an agent learns to make sequential decisions by interacting with an environment and receiving reward signals** — enabling AI systems to master complex tasks from game-playing to robotic control to LLM alignment without requiring labeled demonstration data for every situation. **What Is Reinforcement Learning?** - **Definition**: An agent observes the current state of an environment, takes an action, receives a reward signal, transitions to a new state, and updates its policy to maximize cumulative future reward — learning through trial-and-error experience. - **Key Distinction**: Unlike supervised learning (learn from labeled examples) or unsupervised learning (find patterns in data), RL learns from interaction — the agent creates its own training signal through exploration. - **Temporal Credit Assignment**: RL's core challenge — actions taken now may cause rewards or penalties many steps later, requiring the agent to learn which past decisions led to current outcomes. - **Exploration vs. Exploitation**: The fundamental trade-off — exploit current best-known actions to earn reward, or explore unfamiliar actions that might yield higher future reward. **Why Reinforcement Learning Matters** - **Superhuman Game Play**: AlphaGo, AlphaZero, and OpenAI Five mastered Go, Chess, Shogi, and Dota 2 through RL — achieving performance impossible with human demonstration data alone. - **Robotic Control**: RL trains locomotion and manipulation policies in simulation then transfers to physical robots — enabling Boston Dynamics Spot's agile movements and dexterous manipulation systems. - **LLM Alignment (RLHF)**: RL from Human Feedback is the key technique that transformed GPT-3 into ChatGPT — aligning language model outputs with human preferences for helpfulness and safety. - **Industrial Optimization**: Google DeepMind used RL to reduce Google data center cooling energy 40% — treating HVAC systems as RL environments with energy efficiency as reward. - **Drug Discovery**: Molecular generation models use RL to optimize compounds for desired properties — guiding generative models toward synthesizable, drug-like candidates. **Core RL Framework** **Agent**: The decision-maker. Observes state, selects action, receives reward. **Environment**: Everything the agent interacts with. Produces next state and reward in response to actions. **State (S)**: The agent's observation of the environment at time t. **Action (A)**: The decision the agent takes. Discrete (move left/right) or continuous (steering angle). **Reward (R)**: Scalar feedback signal — positive for good outcomes, negative for bad. The only learning signal. **Policy (π)**: The agent's decision function — maps states to actions. The output of RL training. **Value Function (V)**: Predicts expected cumulative future reward from a given state. **Q-Function (Q)**: Predicts expected cumulative future reward from a given state-action pair. **RL Algorithm Families** **Model-Free (learn from experience directly)**: - **Value-Based (Q-Learning, DQN)**: Learn Q-values mapping (state, action) → expected reward; take action with highest Q-value. - DQN (Deep Q-Network): Q-learning with neural network function approximation. Trained from raw pixels to play Atari at superhuman level. - **Policy Gradient (REINFORCE, PPO, A3C)**: Directly parameterize and optimize the policy π using gradient ascent on expected reward. - **Actor-Critic (SAC, TD3, PPO)**: Simultaneously maintain policy (actor) and value function (critic) — reduces variance of policy gradient updates. **Model-Based (learn a world model)**: - Learn a model of environment dynamics (predict next state given current state + action). - Plan using the model — dramatically more sample-efficient than model-free. - MuZero (DeepMind): Model-based RL achieving superhuman performance on Atari, Go, Chess without human knowledge. **RL in LLM Training (RLHF)** **Stage 1 — Supervised Fine-Tuning (SFT)**: Fine-tune base model on high-quality human demonstrations. **Stage 2 — Reward Model Training**: Train a reward model on human preference comparisons (A > B). **Stage 3 — RL Optimization**: Use PPO to optimize LLM policy to maximize reward model score while staying close to SFT baseline (KL penalty). **Key Algorithms** | Algorithm | Type | Best For | Key Innovation | |-----------|------|----------|----------------| | DQN | Value-based | Discrete actions | Neural Q-function | | PPO | Policy gradient | Continuous/discrete | Clipped objective, stability | | SAC | Actor-critic | Continuous control | Entropy maximization | | TD3 | Actor-critic | Robotics | Twin critics, delayed policy | | MuZero | Model-based | Planning | Learned world model | | AlphaZero | Model-based | Board games | MCTS + self-play | Reinforcement learning is **the algorithm of autonomous improvement — the mechanism through which AI systems transcend their training data to discover strategies beyond human imagination** — from mastering ancient board games to aligning trillion-parameter language models with human values, RL is the engine driving AI's most transformative capabilities.

Go deeper with CFSGPT

Get AI-powered deep-dives, save terms, and run advanced simulations — free account.

Create Free Account