Implicit Reward from DPO
Extract the implicit reward from a DPO-trained model.
In DPO, the implicit reward is:
Since Z(x) is the same for all y given x, we can compare rewards by:
Given log-probabilities from policy and reference model for N responses to the same prompt, compute the implicit rewards and rank responses.
Input:
- Line 1: beta
- Line 2: N
- Next N lines: log_prob_policy log_prob_ref response_label
Output: Response labels ranked by implicit reward (highest first), one per line.
Example
0.1 3 -2.0 -3.0 A -1.5 -1.0 B -3.0 -4.0 C
C A B
- First, we read the input values: , , and the log-probabilities for each response.
- Then, we calculate the implicit reward for each response using the formula: . For the given inputs, the calculations are:
- For A:
- For B:
- For C:
- Next, we compute the actual values:
- For A:
- For B:
- For C: However, considering the proportionality and the actual log values, the correct order should be based on which translates to for each.
- For A:
- For B: $0.1 \cdot (-1.5 - (-1.0
Constraints
- 0.01 <= beta <= 1.0
- 1 <= N <= 20
- Break ties by original order