1 option
A Practical Guide to Reinforcement Learning from Human Feedback : Foundations, aligning large language models, and the evolution of preference-based methods / Sandip Kulkarni.
- Format:
- Book
- Author/Creator:
- Kulkarni, Sandip.
- Language:
- English
- Subjects (All):
- Reinforcement learning.
- Artificial intelligence.
- Physical Description:
- 1 online resource (404 pages)
- Edition:
- 1st ed.
- Place of Publication:
- Birmingham : Packt Publishing, Limited, 2026.
- Summary:
- Understand and apply Reinforcement Learning from Human Feedback (RLHF) in AI alignment and machine learning applications.Learn how human-in-the-loop training aligns large language models (LLMs) with human preferences and AI safety.
- Contents:
- Intro
- A Practical Guide to Reinforcement Learning from Human Feedback
- Foundations, aligning large language models, and the evolution of preference-based methods
- Contributors
- About the author
- About the reviewers
- Table of Contents
- Preface
- Who this book is for
- What this book covers
- To get the most out of this book
- Download the example code files
- Conventions used
- Get in touch
- Free benefits with your book
- How to Unlock
- Share your thoughts
- Part 1
- Foundations of Feedback-Driven Learning
- 1
- Introduction to Reinforcement Learning
- Technical requirements
- Essentials of reinforcement learning
- Understanding RL algorithms
- Navigating RL environments - a grid-world environment
- Q-learning
- Visualization and tracking progress
- Designing reward functions and transfer learning
- Transfer learning
- Reinforcement learning from human feedback
- Summary
- References
- Get this book's PDF version and more
- 2
- Role of Human Feedback in Reinforcement Learning
- Enhancing learning efficiency with human feedback in RL
- Incorporating human expertise
- Types of human feedback in RL
- Learning from human reward or evaluative reinforcement
- Preference-based RL
- Human feedback for defining reward models
- Semi-supervised RL with absolute feedback on a subset of experiences
- Incorporating human preferences into RL
- Collecting human preferences
- Utilizing human preferences
- Evaluating and auditing human preferences
- Bias and other challenges
- Anonymization
- Empowering feedback providers
- Transparency of data usage
- Bias and unfairness
- Techniques for removing bias in data collection
- Techniques for data preprocessing
- Algorithmic techniques
- Human feedback calibration
- References.
- Join our community on Discord
- 3
- Reward Modeling Based Policy Training
- The importance of reward in reinforcement learning
- Extrinsic and intrinsic rewards
- Reward shaping and how it accelerates training
- Challenges in reward specification
- Misaligned objectives
- Sparse and delayed rewards
- Reward hacking
- Design complexity
- Trade-offs and balancing for multiple objectives
- Scalability
- Techniques for reward modeling
- Preference-based learning
- Absolute rating models
- Multi-objective reward models
- Inverse Reinforcement Learning (IRL)
- RewardModel class
- Incorporating human feedback in reward design
- Examples of direct feedback integration
- Collecting human feedback
- Training the reward model
- Integrating with RL policy training
- 4
- Policy Training and Human Guidance
- Policy training
- Mountain Car environment
- State space
- Action space
- Transition dynamics
- Transition to algorithms
- DQN
- Function approximation
- Experience replay
- Target network
- Scalability and performance
- Implementation steps for DQN
- Step 1 - Environment setup
- Step 2 - Argument parsing
- Step 3 - Q-network definition
- Step 4 - Network initialization
- Step 5 - Target network
- Step 6 - Optimizer and loss function
- Step 7 - Replay memory
- Step 8 - Environment reset
- Step 9 - Select action
- Step 10 - Store experience
- Step 11 - Update Q-network
- Step 12 - Update target network
- Step 13 - Decay epsilon
- Training loop
- Policy training methods: policy gradients and actor-critic methods
- Policy gradient methods
- Log-likelihood method
- Policy update rule
- A2C: Variance reduction using baseline subtraction
- Generalized advantage estimation.
- Application of proximal policy optimization
- Introducing the continuous Mountain Car simulation environment
- Accelerating training using vectorized environments
- Key updates for implementing PPO
- PPO implementation overview
- Project structure
- Agent class (agent.py)
- Initialization (__init__ method)
- Critic network
- Actor network
- Handling continuous actions
- Methods
- Training parameters (args.yaml)
- PPO training (training.py)
- Training setup and initialization
- Checkpointing and restarting
- Annealing learning rate
- Collecting rollouts
- Compute advantages and returns
- Mini-batch sampling and PPO update
- Value function and entropy loss
- Gradient clipping
- KL divergence check
- Logging and saving
- main.py
- How the agent fits into the PPO loop
- Sparse rewards and exploration
- Using human guidance
- Repository setup for guided PPO
- Collecting human demonstrations
- Augmenting expert data
- Behavioral cloning
- Setting up BC
- Testing and inference
- Integration with PPO and model initialization
- Join our community on Discord
- Part 2
- Reinforcement Learning from Human Feedback for Language Models
- 5
- Introduction to Language Models and Fine-Tuning
- Introduction to language models
- Early LMs: N-grams
- Statistical and neural LMs
- Recurrent Neural Networks (RNNs)
- The emergence of transformers
- Large Language Models (LLMs)
- The transformer architecture
- Embedding the input
- Positional encoding
- Self-attention: learning word relationships
- Multi-head attention: seeing from multiple perspectives
- Feed-forward network
- Residual connections and layer normalization
- Encoder-decoder structure
- Fine-tuning LMs
- Setup
- Datasets
- Tokenization
- Model inference
- Fine-tuning
- Evaluation
- RLHF in fine-tuning.
- Using TRL from Hugging Face's TRL library
- Customizing Trainer with reward-driven loss
- Using reinforcement learning libraries
- Using OpenAI's spinningup or a custom PPO implementation
- Evaluation and challenges in fine-tuning
- 6
- Parameter Efficient Fine Tuning
- Required software and libraries
- Installation
- GPU acceleration
- Getting the code
- Introduction to PEFT
- Applying the SFT process using Hugging Face's TRL library
- Model choice
- Fine-tuning using SFTTrainer
- Understanding the LoRA technique
- LoRA using the PEFT library
- LoRA using SFTTrainer
- Inferencing and evaluating PEFT models
- 7
- Reward Modeling for Language Model Tuning
- Overview of reward modeling for language
- Data preprocessing and preference data collection
- Raw data from collections
- Preprocessing data
- Data tokenization
- Exploring techniques for reward modeling
- Reward modeling using TRL's RewardTrainer and RewardConfig
- Adding margin to loss
- Data quality, balance, and diversity
- Other considerations for reward modeling
- Context and chat history in reward modeling
- Dealing with underspecification and overoptimization
- Model evaluation and iteration
- Evaluation steps and metrics
- Accuracy or agreement rate
- Rank correlation metrics
- Root Mean Squared Error (RMSE) and Mean Absolute Error (MAE)
- Out-of-distribution robustness
- Policy performance
- Indicators of poor RM-induced policy behavior
- Strategies to address poor policy performance
- 8
- Reinforcement Learning for Tuning Language Models
- Required software and libraries.
- Installation
- GPU acceleration and hardware expectations
- Integration of reward models with reinforcement learning
- PPO algorithm for RLHF
- PPO policy update using reward models
- Modifications needed to adapt PPO for RLHF
- RLHF for natural language applications
- Reward and feedback
- Training process
- Challenges in PPO for chat applications
- Fine-tuning using PPO Trainer in TRL
- RLHF-based fine-tuning libraries and resources
- Step 1: Enable and verify GPU access in Colab
- Step 2: Install the required libraries
- Step 3: Use a lightweight language model
- Step 4: Optimize for memory efficiency
- Adapting to other environments
- Settings and configurations for memory optimization and reproducibility
- Data preparation
- Reward model setup
- Using LoRA for efficient fine-tuning
- Model initialization
- RLHF training loop
- Structuring data and PPOTrainer instantiation
- Setting up the training loop
- Metrics to track
- KL divergence
- Reward score
- Entropy
- Episode length or token count
- Loss values
- Evaluating the fine-tuned model
- Part 3
- The Evolution of Alignment
- 9
- Reinforcement Learning from AI Feedback and Constitutional AI
- Motivation: why RLAIF?
- Challenges of RLHF that motivate AI feedback
- AI feedback as a natural research and development progression
- AI-generated feedback in RL
- Canonical RLAIF
- Direct RLAIF
- Teacher-critic
- Contrastive learning methods
- RL from contrastive distillation (RLCD)
- Direct large model alignment (DLMA)
- Self-improving methods
- Rewindable auto-regressive inference
- Reinforced self-training
- Principle-driven and minimal supervision approaches
- Self-Align methodology
- UltraFeedback
- Comparing the models.
- Introduction to Constitutional AI.
- Notes:
- Description based upon print version of record.
- DQN
- Description based on publisher supplied metadata and other sources.
- Part of the metadata in this record was created by AI, based on the text of the resource.
- Other Format:
- Print version: Kulkarni, Sandip A Practical Guide to Reinforcement Learning from Human Feedback
- ISBN:
- 9781835880517
- 9781835880500
- OCLC:
- 1581080133
The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.