4.4.2 · D1Alignment, Prompting & RAG

Foundations — Reward modeling

2,460 words11 min readBack to topic

This page assumes nothing. Every symbol in the parent note, , , , , , even the little — is built here from the ground up, in the order you need to meet them. If a symbol scared you in the parent note, it will not after this.


0 · The characters in the story (before any math)

Reward modeling has exactly four "nouns". Meet them first as pictures, then we'll name them.

Figure — Reward modeling

Everything else on this page is just notation for these four things, or machinery for turning "human picked " into "make the score of bigger".


1 · Subscripts and letters: , , ,

Why the topic needs this: the whole dataset is triples — "for this prompt, this beat that". No winner/loser distinction, no way to learn preference.


2 · The "beats" symbol


3 · A function and its scoring:

This is the star of the show. Let's dismantle it piece by piece.

Figure — Reward modeling

Why the topic needs this: the reward model is literally this function. Learning to score = learning the knobs .


4 · The sigmoid — turning a difference into a probability

Before the loss, we need to convert "the winner scored more than the loser" into "the chance a human picks the winner". That converter is .

Figure — Reward modeling

This is the exact same curve used in Logistic regression; a reward model's loss is a logistic loss on the score difference.


5 · The difference


6 · — the surprise meter

Figure — Reward modeling

7 · — the averaging symbol


8 · The leash symbols: , , ,

These appear only in the usage stage (feeding the RM into RLHF via PPO). Meet them lightly so the parent's final equation isn't a wall of Greek.


How the foundations feed the topic

Prompt x and response y

Function r_theta scores a response

Preference pair y_w beats y_l

Difference Delta = r_w minus r_l

Sigmoid squashes Delta into a probability

Bradley-Terry preference model

Minus log makes small-when-right loss

Pairwise reward-model loss

Expectation averages over all data

Train the knobs theta

Use r_theta with a KL leash in RLHF

Read it top to bottom: the four nouns (top) build the score, the score builds the difference, the difference plus sigmoid builds a probability, plus averaging build the loss, and the trained reward finally drives the policy under a leash.


Worked micro-checks (numbers you can verify)


Common confusions cleared early


Equipment checklist

Self-test: cover the right side and answer each. If any stumps you, reread its section above.

What does the subscript in stand for, and is it multiplication?
It means "winner" (the preferred response); it is a label, not multiplication.
What single object does output?
One real number — the score of response for prompt , given the current knobs .
What does tell you about that output?
It is an ordinary real number and may be negative.
What is the sigmoid and what range does it output?
; it squashes any number into the interval .
Why is a sigmoid used instead of a straight line to make a probability?
A line would leave ; the sigmoid always stays a valid probability, is symmetric, and gives at a tie.
What does equal and what does its sign mean?
; positive means the model ranks the winner higher (right), negative means wrong.
State the reflection identity of the sigmoid.
.
Why take of the correct-choice probability?
To build a loss that is near zero when the model is confident-correct and explodes when it is wrong.
What does do?
Averages the quantity over all preference examples in the dataset.
What is the difference between and ?
= reward-model knobs (frozen after training); = policy knobs (trained later against the reward).
In one line, what does the KL term with do in RLHF?
It leashes the policy near a frozen reference so it can't exploit regions where the reward model is wrong.

Recall One-breath summary of the foundations

Four nouns (prompt , response , winner , loser ) → one scoring machine with knobs → a difference → squash it with into "chance the human picks the winner" → punish with → average with → that is the reward-model loss. Later, use the frozen to steer a policy , held on a KL leash of strength .