Editing
Reinforcement Learning
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
<div style="background-color: #4B0082; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;"> {{BloomIntro}} Reinforcement Learning (RL) is a paradigm of machine learning in which an agent learns to make decisions by interacting with an environment, receiving feedback in the form of rewards and penalties. Unlike supervised learning, there are no labeled examples β the agent must discover which actions lead to long-term success through trial and error. RL underlies breakthrough systems like AlphaGo, ChatGPT's RLHF fine-tuning, and robotic control. </div> __TOC__ <div style="background-color: #000080; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;"> == <span style="color: #FFFFFF;">Remembering</span> == * '''Agent''' β The learner and decision-maker that interacts with the environment. * '''Environment''' β Everything the agent interacts with; it receives actions and returns observations and rewards. * '''State (s)''' β A representation of the current situation of the environment. * '''Action (a)''' β A choice made by the agent at each time step. * '''Reward (r)''' β A scalar signal provided by the environment indicating how good or bad an action was. * '''Policy (Ο)''' β A mapping from states to actions, defining the agent's behavior. * '''Value function (V)''' β An estimate of the expected cumulative future reward from a given state when following a policy. * '''Q-function (Q)''' β An estimate of the expected cumulative reward from taking action a in state s, then following policy Ο. * '''Episode''' β A sequence of states, actions, and rewards from an initial state to a terminal state. * '''Discount factor (Ξ³)''' β A value between 0 and 1 that reduces the weight of future rewards relative to immediate ones. * '''Exploration vs. exploitation''' β The trade-off between trying new actions (exploration) and repeating known good actions (exploitation). * '''Markov Decision Process (MDP)''' β The mathematical framework for RL problems, defined by states, actions, transitions, and rewards. * '''Model-free RL''' β Methods that learn directly from interaction without building an explicit model of the environment. * '''Model-based RL''' β Methods that learn a model of the environment's dynamics and use it to plan. * '''PPO (Proximal Policy Optimization)''' β A widely-used policy gradient algorithm known for stability and efficiency. * '''DQN (Deep Q-Network)''' β A Q-learning algorithm using a neural network to approximate the Q-function. </div> <div style="background-color: #006400; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;"> == <span style="color: #FFFFFF;">Understanding</span> == The core RL loop is: observe state β choose action β receive reward β update policy. The agent's goal is to maximize the expected cumulative discounted reward over time, called the '''return''': G''t = r''{t+1} + Ξ³Β·r''{t+2} + Ξ³Β²Β·r''{t+3} + ... The discount factor Ξ³ controls how myopic the agent is. Ξ³=0 means only immediate rewards matter; Ξ³β1 means the agent considers the long-term future. '''The Exploration-Exploitation Dilemma''' is fundamental: if an agent only exploits what it knows, it may miss better strategies. If it only explores, it never uses what it learns. The Ξ΅-greedy strategy is a simple solution β with probability Ξ΅, take a random action (explore); otherwise, take the best known action (exploit). Ξ΅ is typically annealed from high to low over training. '''Policy gradient methods''' directly optimize the policy by adjusting its parameters to increase the probability of actions that led to high returns. Think of it as hill-climbing in policy space. '''Value-based methods''' learn the Q-function first, then derive the policy as "always take the action with the highest Q-value." DQN famously stabilized this with two innovations: experience replay (sampling random past transitions to break correlation) and a target network (a frozen copy of the Q-network updated periodically). '''Actor-Critic methods''' combine both: an Actor (policy network) decides actions, while a Critic (value network) evaluates them. The Critic provides a baseline that reduces variance in learning β rather than waiting for sparse, delayed rewards, the agent gets a dense signal from the learned value estimate. </div> <div style="background-color: #8B0000; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;"> == <span style="color: #FFFFFF;">Applying</span> == '''Setting up a basic RL training loop with Gymnasium and Stable-Baselines3:''' <syntaxhighlight lang="python"> import gymnasium as gym from stable_baselines3 import PPO # Create environment env = gym.make("CartPole-v1") # Instantiate agent with PPO algorithm model = PPO( "MlpPolicy", env, learning_rate=3e-4, n_steps=2048, batch_size=64, n_epochs=10, gamma=0.99, verbose=1 ) # Train for 100,000 steps model.learn(total_timesteps=100_000) # Evaluate obs, _ = env.reset() for _ in range(1000): action, _ = model.predict(obs, deterministic=True) obs, reward, done, truncated, _ = env.step(action) if done or truncated: obs, _ = env.reset() </syntaxhighlight> ; Common RL algorithm selection guide : '''Discrete actions + simple environments''' β DQN, Double DQN : '''Continuous control (robotics, locomotion)''' β SAC (Soft Actor-Critic), TD3 : '''General purpose, on-policy''' β PPO, A3C : '''RLHF for LLMs''' β PPO with KL divergence penalty from reference model : '''Game environments''' β AlphaZero-style MCTS + RL for perfect-information games </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;"> == <span style="color: #FFFFFF;">Analyzing</span> == {| class="wikitable" |+ RL Algorithm Comparison ! Algorithm !! On/Off Policy !! Action Space !! Sample Efficiency !! Stability |- | DQN || Off || Discrete || Medium || Moderate |- | PPO || On || Both || Low || High |- | SAC || Off || Continuous || High || High |- | TD3 || Off || Continuous || High || High |- | A3C || On || Both || Low || Moderate |} '''Failure modes and pitfalls:''' * '''Reward hacking''' β The agent finds unintended ways to maximize the reward signal that violate the spirit of the task. Example: a boat-racing agent learned to spin in circles collecting bonuses rather than completing the race. * '''Sparse rewards''' β If reward is only given at episode completion, learning is extremely slow. Mitigate with reward shaping, curriculum learning, or intrinsic motivation (curiosity). * '''Sample inefficiency''' β Model-free RL requires enormous amounts of interaction data. AlphaGo needed millions of self-play games. Real-world robots can't afford this β use simulation or model-based approaches. * '''Catastrophic forgetting''' β As the agent improves, early experiences become less representative. Experience replay buffers and periodic re-evaluation mitigate this. * '''Distribution shift''' β The policy changes during training, meaning the data collected under an old policy becomes stale for the new policy. </div> <div style="background-color: #483D8B; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;"> == <span style="color: #FFFFFF;">Evaluating</span> == Experts evaluate RL systems along dimensions that casual practitioners often overlook: '''Sample efficiency vs. wall-clock time''': The number of environment interactions required to reach a target performance level. A method that converges in 1M steps may be preferred over one that converges in 500k if the latter requires a larger compute budget per step. '''Stability and reproducibility''': RL training is notoriously sensitive to random seeds, hyperparameters, and implementation details. Expert-level evaluation runs multiple seeds and reports mean Β± standard deviation, not just the best run. '''Policy interpretability''': For safety-critical applications, can you explain why the agent takes a given action? Experts use visualization, attention maps, or mechanistic analysis to build trust. '''Transfer and generalization''': Does the policy hold up in environments slightly different from training? Evaluate on held-out environment variants. Domain randomization during training is a key technique for robustness. A common expert mistake is '''Goodhart's Law''' in reward design β "When a measure becomes a target, it ceases to be a good measure." The reward specification must be treated as rigorously as any other design document. </div> <div style="background-color: #2F4F4F; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;"> == <span style="color: #FFFFFF;">Creating</span> == Designing an RL system from scratch requires careful specification of each MDP component: '''1. State space design''' * What information does the agent need to make good decisions? * Raw pixels vs. hand-crafted features vs. learned embeddings? * Partial observability? β Use recurrent policy (LSTM-based) or frame stacking '''2. Action space design''' * Discrete (choose from N options) vs. continuous (output a vector)? * Action parameterization matters: joint angles vs. end-effector positions in robotics '''3. Reward function design''' * Dense vs. sparse: prefer dense when possible * Normalize rewards to [-1, 1] or [0, 1] * Potential-based shaping guarantees policy invariance '''4. Pipeline architecture for RLHF:''' <syntaxhighlight lang="text"> [Human Preference Data] β [Train Reward Model (RM)] β [Freeze RM] + [Reference LLM (frozen)] β [PPO: Fine-tune LLM with RM signal + KL penalty] β [Evaluated LLM Policy] </syntaxhighlight> '''5. Infrastructure checklist''' * Vectorized environments (run N envs in parallel) for throughput * GPU for policy/value network updates * Logging: episode return, episode length, entropy, value loss, policy loss * Curriculum: start with easier versions of the task, increase difficulty as agent improves [[Category:Artificial Intelligence]] [[Category:Machine Learning]] [[Category:Reinforcement Learning]] </div>
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Template:BloomIntro
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information