liveBook · Manning

Reinforcement learning with human feedback

As explained in Natural Language Processing in Action, Second Edition

Reinforcement learning with human feedback is a model-training technique that uses human evaluations to optimize a system's behavior.

Reinforcement learning with human feedback (RLHF) tunes a language model using people’s reactions to its answers. Positive feedback gradually adjusts model weights, encouraging next-word predictions that users find more useful or likable. section 10.1

The Like button as a training signal

A user’s Like tells the system that an answer was satisfactory. Repeated feedback creates pressure toward likable responses, much as rewarding an animal for an answer can make it reproduce patterns correlated with approval rather than genuine understanding. section 10.1

Listing 10.1 Counting cow legs with GPT-2
>>> from transformers import pipeline, set_seed
>>> generator = pipeline('text-generation', model='openai-gpt')
>>> set_seed(0)                                                    #1
>>> q = "There are 2 cows and 2 bulls, how many legs are there?"
>>> responses = generator(
...     f"Question: {q}\nAnswer: ",
...     max_new_tokens=5,                   #2
...     num_return_sequences=10)    #3
>>> answers = []
>>> for resp in responses:
...     text = resp['generated_text']
...     answers.append(text[text.find('Answer: ')+9:])
>>> answers
['four', 'only', '2', 'one', '30', 'one', 'three', '1', 'no', '1']

The counting example demonstrates why plausible language and positive feedback do not guarantee reliable arithmetic or reasoning. section 10.1

RLHF can improve answers after launch, but optimizing likability may reward popularity, hype, or agreement instead of truth. Models can still make obvious errors, produce nonsense, or be coaxed into unsafe behavior. section 10.1

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Explains feedback, incentives, and weight adjustment through analogy, but stops short of detailing the RLHF training pipeline.
Examples
Uses ChatGPT’s Like button, animal-training analogies, and GPT-2’s inconsistent cow-leg answers.
What it assumes
Assumes familiarity with language models and next-word prediction while introducing human feedback through everyday approval signals.
What you can do after
Evaluate why feedback can improve likability without guaranteeing mathematical ability, factual accuracy, or safe behavior.
How it connects
Connects large language models with next-word prediction, user feedback, jailbreaks, and objective-function design.

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 Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.