liveBook · Manning

Reward model

As explained in Deep Learning with R, Third Edition

A reward model is a model that assigns a scalar score representing the desirability of a response to an input.

A reward model assigns a scalar score to a prompt–response pair: higher scores represent responses judged more desirable. It acts as a proxy for human preference when improving a language model. section 16.4.1

A typical preference-modeling workflow proceeds as follows:

  • Collect prompts and several candidate responses, including handwritten or model-generated responses. section 16.4.1
  • Have human evaluators rank each response from most helpful to least helpful. section 16.4.1
  • Train a usually smaller Transformer to read the whole sequence and output one floating-point rating. section 16.4.1
  • Use predicted rewards to guide reinforcement learning, treating generated responses as actions and scores as feedback. section 16.4.1
Listing 16.15 Pseudocode for the simplest possible RLHF algorithm
for (prompts in dataset) {
  responses <- model$generate(prompts)  #1
  rewards <- reward_model |> predict(responses)  #2
  good_responses <- responses[rewards > cutoff]
  model |> fit(good_responses)  #3
}

The pseudocode makes the core loop concrete: generate responses, score them, keep responses above a cutoff, and fit the model on them. section 16.4.1

How Deep Learning with R, Third Edition covers it

How deep it goes
Defines prompt–response scoring and outlines its training loop, but defers most reinforcement-learning details.
Examples
Uses ranked candidate responses, a smaller Transformer scorer, and reward-threshold pseudocode.
What it assumes
Assumes a supervised-fine-tuned baseline and introduces preference ranking as the necessary data-collection step.
What you can do after
Apply it via reinforcement learning to score generated responses and select outputs receiving higher rewards.
How it connects
Connects supervised fine-tuning, human feedback, reinforcement learning, Transformers, and language-model generation.

Also explained in

Compare how 5 books explain reward model →

Related concepts

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