liveBook · Manning

Reinforcement learning with human feedback

As explained in How Large Language Models Work

Reinforcement learning from human feedback is a technique that optimizes a model's behavior using human evaluations as a source of reward or preference information.

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.
figure

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.
figure

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

How How Large Language Models Work covers it

How deep it goes
Explains agents, rewards, scoring, token probabilities, reward models, and stability, while deferring detailed RLHF mathematics.
Examples
Uses chatbot satisfaction, good-or-bad conversations, joke scoring, code assistants, and coding-platform data as teaching examples.
What it assumes
Assumes basic familiarity with LLMs and fine-tuning, while defining reinforcement-learning terms and reward mechanics from the ground up.
What you can do after
Evaluate when human-feedback fine-tuning can target abstract behavior and recognize reward hacking, novelty, and unknown-risk limitations.
How it connects
Connects reinforcement learning with human feedback to fine-tuning, supervised fine-tuning, reward models, Goodhart’s law, and adversarial machine learning.

Also explained in

Compare how 14 books explain reinforcement learning with human feedback →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of How Large Language Models Work. The section links point to the parts of the book it draws on.