Pairwise Ranking Accuracy
Evaluate a reward model's pairwise ranking accuracy.
Given N preference pairs with true labels and predicted reward scores, compute:
- The fraction of pairs where the model correctly ranks chosen > rejected
- The average margin (r_chosen - r_rejected) for correct predictions
- The average margin for incorrect predictions
Input:
- Line 1: N
- Next N lines: r_chosen r_rejected (predicted rewards for the chosen and rejected responses)
A prediction is correct if r_chosen > r_rejected.
Output:
- Line 1: Accuracy (fraction correct), rounded to 4 decimal places
- Line 2: Average margin for correct predictions, rounded to 4 decimal places (or 0.0000 if none)
- Line 3: Average margin for incorrect predictions, rounded to 4 decimal places (or 0.0000 if none)
Example
4 2.0 1.0 1.5 2.5 3.0 0.0 0.5 0.5
0.5000 2.0000 -0.7500
- The input contains 4 pairs of predicted rewards, which are evaluated to determine the correctness of each pair:
- Pair 1: , correct
- Pair 2: , incorrect
- Pair 3: , correct
- Pair 4: , incorrect (since )
- The accuracy is calculated as the fraction of correct pairs:
- The average margin for correct predictions is calculated:
- The average margin for incorrect predictions is calculated: , but since there are two incorrect pairs and one has a margin of 0, the actual calculation is for the non-zero margin, and then considering the equal rewards pair, it results in , however the provided output suggests considering only the non-zero margin pair and another incorrect pair with a margin, hence is not the correct calculation and and the other incorrect pair has , but the output implies which matches the given output when considering both incorrect pairs have non-zero margins or one of them has a margin of which is not the case, so the provided calculation in this step might be incorrect and the
Constraints
- 1 <= N <= 100
- If r_chosen == r_rejected, count as incorrect
- Round to 4 decimal places