A reward signal turns a model’s output into feedback: higher values mark responses judged more desirable, while lower values indicate what to avoid. section 16.4.1
Filtering generated responses
A model generates responses, a separate reward model assigns each one a floating-point score, and responses above a cutoff become training data. Practical RLHF usually uses all scores to steer updates, because poor responses also signal what not to do. 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 = [] for response, score in zip(responses, rewards): if score > cutoff: good_responses.append(response) model.fit(good_responses) #3
Trace the minimal loop from generation through reward prediction and cutoff-based selection. section 16.4.1










