- Key idea
- Odds, log-odds, the sigmoid, and the logistic loss
- Real world
- Chess ratings. A player rated 200 points higher is expected to win about 76% of the time; 400 points higher, about 91%. A rating gap becomes a win probability through an S-shaped curve.
- In an LLM
- A reward model gives two answers scores. The chance a person prefers the first is the sigmoid of the score gap. Reward-model training and DPO are both built on this.
Odds and log-odds
Odds compare the chance something happens with the chance it doesn't: probability 0.8 is odds of 0.8 : 0.2, or 4 to 1.
The log-odds is the log of that ratio: . Log-odds run from minus infinity (impossible) through 0 (even odds) to plus infinity (certain), which makes them a natural thing for a model to output as a plain score.
The sigmoid
The sigmoid turns log-odds back into a probability:
- : a gap of zero is a coin flip.
- Large positive : close to 1. Large negative: close to 0.
- Each +1 in multiplies the odds by .
Try it
Elo uses the same curve with base 10 and a scale of 400 points:
A gap of 200 gives .
A reward model scores answer A at 2.1 and answer B at 0.9. The gap is 1.2:
If people did prefer A, the training loss is . Training adjusts the scores to make preferred answers' gaps larger.
Why the loss stops pushing
The loss for a correct comparison is . Its gradient is proportional to , the probability the model still gives the wrong answer. At gap 0 that's 0.5; at gap 3 it's 0.05: the dashed curve in the widget. Pairs the model already gets right barely affect training, so learning concentrates on the ones it gets wrong.
Softmax with two options
A sigmoid is a softmax over two choices: with logits and , softmax gives the first . Only the gap matters, just as with softmax.
Where this shows up
- Bradley–Terry reward models: reward models and RLHF.
- DPO's loss is a sigmoid of the implicit reward gap: DPO.