Reinforcement learning from human feedback (RLHF) changes an LLM’s behavior by using human judgments as rewards. It is more complex than supervised fine-tuning but can target abstract goals such as being a helpful chatbot, rather than only learning new information or a domain style. section 5.2 section 5.6
Figure 5.4 RL is about iterative interactions, where the reward for your actions may not materialize for a long time and requires multiple steps to achieve. For a chatbot like ChatGPT, the environment is the conversation with a user, and the actions are the infinite possible texts that ChatGPT might complete. The reward becomes, in some sense, the user’s satisfaction with the chatbot at the end of the conversation.
Use the interaction diagram to trace the LLM as agent, generated text as action, conversation as environment, and user satisfaction as a delayed reward. section 5.2.2
A high-level RLHF process combines several ingredients:
- Define the interaction: the LLM is the agent, its possible text outputs are actions, and the conversation with a user is the environment. section 5.2.2
- Collect human judgments, such as positive scores for helpful, honest conversations and negative scores for harmful or poor responses. section 5.2.2 section 5.3.1
- Use generated-token probabilities to give the reinforcement-learning algorithm more information than a simple good-or-bad label. section 5.3.1
- Train a reward model so human feedback can be reused to score many prompts instead of requiring a person to judge every new output. section 5.3.3
- Balance quality against similarity to the original model; otherwise, maximizing the quality score alone can produce gibberish or nonsensical outputs. section 5.3.3
Scoring a joke
Given the prompt “Tell me a joke,” a joke-like response might receive +1, while “Dogs are evil” might receive -1 because it does not attempt the task. Such coarse scores illustrate both the usefulness and subjectivity of human rewards; token probabilities add detail for the learning algorithm. section 5.3.1
Figure 5.8 The full version of RLHF. The dashed lines are text and require RL to update the parameters. The original LLM is the base model without any alterations, while the LLM to fine-tune starts as the base model but is altered to improve the quality of its outputs. The similarity and quality reward components are provided with word probabilities to improve calculation. RL adjusts the parameters by combining the quality and similarity scores.
Use the full pipeline diagram to compare the original base model with the model being fine-tuned and see how quality and similarity rewards jointly update parameters. section 5.3.3
RLHF is not a general solution to every failure. It is effective at avoiding known, specific problems, but it does not give the model new tools for novel problems. Optimizing a reward can also exploit weaknesses in that measurement, a form of Goodhart’s law. Testing remains incomplete because unknown risks cannot all be enumerated. section 5.3.3 section 9.1.1
RLHF commonly follows supervised fine-tuning rather than replacing it. It generally needs more examples—often tens of thousands—and can be applied sequentially with supervised fine-tuning. For code assistants, code data and supervised fine-tuning establish coding ability, while RLHF improves usefulness. section 5.2.3 section 6.1.1













