liveBook · Manning

Reinforcement learning

As explained in Deep Learning with Python, Third Edition

A learning setup where an agent improves by interacting with an environment and receiving feedback, used here as a way to keep generating fresh training problems for LLMs.

Reinforcement learning lets a model improve through interaction: it generates responses, receives feedback or rewards, and favors behavior associated with higher scores. For language models, the practical motivation is to optimize preferences that are difficult to express directly as a loss function. section 16.4.1 section 16.5

A simplified RLHF workflow turns human preference into a training signal:

  • Start with supervised fine-tuning on handwritten prompts and responses to establish a baseline. section 16.4.1
  • Collect several responses for prompts and have evaluators rank them from most helpful to least helpful. section 16.4.1
  • Train a reward model that reads a prompt-response pair and returns a floating-point preference score. section 16.4.1
  • Use the reward model to score generated responses and tune the language model toward higher-reward behavior. section 16.4.1

A minimal reward-filtering loop

For each prompt batch, generate responses, predict their rewards, retain responses above a cutoff, and fit the model on the retained set. This pseudocode captures the feedback loop without developing the deeper reinforcement-learning machinery. section 16.4.1

The same idea can extend beyond preference rankings: a difficult, self-contained environment can continually generate new problems for an LLM, allowing training from model interaction rather than an ever-larger supply of public text. section 16.5

How Deep Learning with Python, Third Edition covers it

How deep it goes
Defines the RLHF workflow through reward modeling and pseudocode, but stops short of deeper reinforcement-learning details.
Examples
Uses ranked response preferences, scalar reward predictions, cutoff filtering, and self-contained environments that generate new problems.
What it assumes
Assumes familiarity with supervised fine-tuning and introduces preference ranking and reward modeling without requiring deep reinforcement-learning knowledge.
What you can do after
Evaluate how RLHF converts human preferences into reward-guided LLM tuning and recognize its simplified training loop.
How it connects
Links reinforcement learning to RLHF, supervised fine-tuning, reward models, human feedback, and language-model training.

Also explained in

Compare how 18 books explain reinforcement learning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.