Train a reward model on a full ranking of K answers
Why it matters Using every pair from a K-way ranking gets much more training signal per labelled prompt.
When labellers rank K answers instead of picking one of two, every pair from the ranking becomes a comparison for the reward model.
Write ranking_loss(scores). scores is (B, K): row b holds the reward model's scores for K answers listed from best to worst. For every pair i < j in a row the better answer is i. The row loss is the mean over all K * (K - 1) / 2 pairs of -log sigmoid(s_i - s_j). Return the mean row loss over the batch as a float (stable log-sigmoid).
def ranking_loss(scores)Example
ranking_loss([[2, 1, 0]]) is about 0.2512.
Understand the idea
A ranking of K answers contains many pairwise facts. If A > B > C, then also A > C. A reward model trained with the Bradley-Terry loss can learn from every one of those pairs, like a league table built from every match, not just neighbouring teams.
Example: scores [2, 1, 0] for answers ranked best to worst. Pairs: (2 vs 1), (2 vs 0), (1 vs 0), with differences 1, 2, 1. -log sigmoid(1) = 0.313 and -log sigmoid(2) = 0.127. The mean is (0.313 + 0.127 + 0.313) / 3 = 0.251.
Rule: row loss = mean over i < j of -log sigmoid(s_i - s_j); batch loss = mean of row losses.
The InstructGPT reward model was trained on rankings of several answers per prompt in this way, treating all the pairs from one prompt together. Averaging per row keeps prompts with many answers from dominating the batch.
Shapes and data flow
scores (B, K) -> pair diffs (B, K(K-1)/2) -> row losses (B,) -> scalar