AI Wiki中文/EN

Reward models: a score learns comparisons, not truth

奖励模型

Fit preference odds, expose unidentified scores and watch proxy optimization damage a separate goal.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

The same comparisons can support very different scores

A wins against B in four out of five comparisons. Does that make A’s reward 0.8? Not necessarily. The comparison frequency concerns two answers, whereas a reward score belongs to an answer under a prompt. Many pairs of scores produce the same probability. An answer never compared with anything is even less constrained.

A reward model maps an input and a candidate behavior to a scalar used for evaluation or optimization. This article focuses on preference-trained reward models. Christiano and colleagues, section 2.2.3, learn a score from trajectory comparisons. Rafailov and colleagues, section 3, state the corresponding response-level preference likelihood. Neither construction makes the score an objective measure of correctness, safety or human welfare.

The executable example fits three tabular rewards, introduces an unobserved answer, and optimizes a deliberately imperfect proxy. Every label and utility in the example is synthetic.

A rising proxy score can conceal falling utility in this authored three-answer example.
A rising proxy score can conceal falling utility in this authored three-answer example.

Only differences appear in the likelihood

For answers i,ji,j to the same prompt, a Bradley–Terry model uses:

pij=P(i≻j)=σ(ri−rj),σ(z)=11+e−z.p_{ij}=P(i\succ j)=\sigma(r_i-r_j),\qquad \sigma(z)=\frac1{1+e^{-z}}.

This assumes a scalar preference scale and a particular noise model. A score difference of zero gives probability 0.5; a difference of log⁡4\log4 gives 0.8. For trajectory segments, the scores can be sums of per-step predicted rewards. Context and segment definition remain part of the model.

For NN comparisons with soft targets tnt_n, let δn=rin−rjn\delta_n=r_{i_n}-r_{j_n}. The mean negative log-likelihood can be evaluated stably as:

L=1N∑n[log⁡(1+eδn)−tnδn].\mathcal L=\frac1N\sum_n[\log(1+e^{\delta_n})-t_n\delta_n].

logaddexp(0, delta) computes the first term without forming an enormous exponential. For actual repeated binary judgments, a count-weighted likelihood preserves the number of observations; equal weighting of distinct pair frequencies is a different objective. Our three authored pair frequencies receive equal weight, and are not reported as collected observations.

The gradient with respect to tabular scores is:

∇rL=1N∑n(pinjn−tn)(ein−ejn).\nabla_r\mathcal L=\frac1N\sum_n(p_{i_nj_n}-t_n)(e_{i_n}-e_{j_n}).

Each comparison adds and subtracts the same residual. The gradient therefore sums to zero, and zero initialization keeps the mean score zero. This fixes one convenient convention; the data itself cannot fix the shared offset:

σ((ri+c)−(rj+c))=σ(ri−rj).\sigma((r_i+c)-(r_j+c))=\sigma(r_i-r_j).

If the comparison graph is disconnected, each component has its own unconstrained offset. Regularization or an initialization can select one solution without supplying missing evidence. Our fourth answer has no incident comparison, so assigning it reward −4-4 or 44 leaves the training likelihood identical.

Scale is different from offset. Multiplication generally changes confidence:

σ(a(ri−rj))≠σ(ri−rj)in general when a≠1.\sigma(a(r_i-r_j))\ne\sigma(r_i-r_j)\quad\text{in general when }a\ne1.

Thus centering scores does not calibrate probabilities. Temperature fitting on a separate validation set may adjust confidence, but cannot repair missing features or unsupported behaviors. Hard, perfectly separable preferences can also drive unregularized logistic scores without bound; finite soft targets in this example avoid that case.

Scalar differences must be consistent around a cycle:

(rA−rB)+(rB−rC)+(rC−rA)=0.(r_A-r_B)+(r_B-r_C)+(r_C-r_A)=0.

If all three ordered pairs have target probability 0.8, each asks for difference log⁡4\log4, contradicting the identity. With equal weights, the symmetric optimum has equal scores and loss log⁡2\log2. Disagreement is not always an optimizer bug; the chosen model can be unable to represent the labels.

Finally, consider a policy selected using a proxy reward r^\widehat r, while a separate authored utility uu measures the intended outcome:

pβ=arg⁡max⁡p[∑ipir^i−βDKL(p∥q)],U(p)=∑ipiui.p_\beta=\arg\max_p\left[\sum_i p_i\widehat r_i-\beta D_{\mathrm{KL}}(p\Vert q)\right],\qquad U(p)=\sum_i p_i u_i.

These are different quantities. Nothing in this objective guarantees that increasing proxy reward increases UU. Gao and colleagues, section 2.1, study a related proxy-optimization problem using a larger reward model as synthetic “gold.” Their gold model is not direct access to true human utility; our explicit numerical utility is a separate teaching construction.

Fit, shift, omit, then optimize

Run this complete Python/NumPy program. Three pair targets 0.8,0.8,16/17 recover scores approximately (log⁡4,0,−log⁡4)(\log4,0,-\log4) and loss 0.4081743077. Adding 100 to every score preserves the loss within floating-point precision.

"""Original finite reward fitting: synthetic labels, no human or LLM ratings."""
import json
import numpy as np


def sigmoid(x):
    x = np.asarray(x, dtype=float)
    return np.exp(-np.logaddexp(0, -x))


def softmax(x):
    x = np.asarray(x, dtype=float)
    if x.ndim != 1 or not len(x) or not np.isfinite(x).all():
        raise ValueError("Expected a nonempty finite vector")
    e = np.exp(x - x.max())
    return e / e.sum()


def preferences(scores, pairs):
    return sigmoid(scores[pairs[:, 0]] - scores[pairs[:, 1]])


def pair_loss_grad(scores, pairs, targets):
    scores = np.asarray(scores, dtype=float)
    pairs = np.asarray(pairs, dtype=int)
    targets = np.asarray(targets, dtype=float)
    if (scores.ndim != 1 or pairs.ndim != 2 or pairs.shape[1] != 2
        or len(pairs) == 0 or targets.shape != (len(pairs),)
        or not np.isfinite(scores).all() or not np.isfinite(targets).all()
        or np.any((targets < 0) | (targets > 1))
        or pairs.min() < 0 or pairs.max() >= len(scores)):
        raise ValueError("Invalid scores, pairs or soft labels")
    delta = scores[pairs[:, 0]] - scores[pairs[:, 1]]
    loss = np.mean(np.logaddexp(0, delta) - targets * delta)
    residual = (sigmoid(delta) - targets) / len(pairs)
    gradient = np.zeros_like(scores)
    np.add.at(gradient, pairs[:, 0], residual)
    np.add.at(gradient, pairs[:, 1], -residual)
    return float(loss), gradient


def fit_scores(pairs, targets, size=3, steps=2000):
    scores = np.zeros(size)
    for _ in range(steps):
        _, gradient = pair_loss_grad(scores, pairs, targets)
        scores -= 0.5 * gradient
    return scores


def policy_for_reward(reference, reward, beta):
    reference = np.asarray(reference, dtype=float)
    reward = np.asarray(reward, dtype=float)
    if (reference.ndim != 1 or reference.shape != reward.shape
        or not np.isfinite(reference).all() or not np.isfinite(reward).all()
        or np.any(reference <= 0) or not np.isclose(reference.sum(), 1)
        or not np.isfinite(beta) or beta <= 0):
        raise ValueError("Positive normalized reference and beta are required")
    return softmax(np.log(reference) + reward / beta)


PAIRS = np.array([[0, 1], [1, 2], [0, 2]])


def demo():
    truth = np.array([np.log(4), 0., -np.log(4)])
    target = preferences(truth, PAIRS)
    learned = fit_scores(PAIRS, target)
    cycle = np.array([[0, 1], [1, 2], [2, 0]])
    cyclic = fit_scores(cycle, np.full(3, .8))
    # Candidate 3 is never compared: both scores fit observed data equally.
    low, high = np.r_[learned, -4.], np.r_[learned, 4.]
    q = np.array([.8, .19, .01])
    proxy, gold = np.array([0., 1., 3.]), np.array([0., 1., -1.])
    optimization = []
    for beta in [5., 1., .25]:
        policy = policy_for_reward(q, proxy, beta)
        optimization.append(dict(beta=beta, policy=policy.tolist(),
            proxy=float(policy @ proxy), gold=float(policy @ gold)))
    return dict(targets=target.tolist(), scores=learned.tolist(),
        loss=pair_loss_grad(learned, PAIRS, target)[0],
        shifted_loss=pair_loss_grad(learned+100, PAIRS, target)[0],
        cycle_scores=cyclic.tolist(), cycle_loss=pair_loss_grad(cyclic, cycle, np.full(3,.8))[0],
        unseen_losses=[pair_loss_grad(x, PAIRS, target)[0] for x in [low,high]],
        unseen_probability=[float(policy_for_reward(np.full(4,.25),x,1)[3]) for x in [low,high]],
        optimization=optimization)


if __name__ == "__main__":
    print(json.dumps(demo(), indent=2))

Under a uniform four-answer reference and β=1\beta=1, the unobserved answer’s optimal probability is about 0.003477 if its score is −4-4, or 0.912278 if its score is 44. Both score assignments fit the observed three-answer comparisons equally well. Training loss cannot choose between them.

For the separate proxy experiment, reference probabilities are (0.8,0.19,0.01), proxy scores (0,1,3) and intended utilities (0,1,-1). As β\beta decreases through 5,1,0.25, expected proxy reward rises approximately 0.2730,0.7375,2.9859. Utility moves 0.2036,0.2080,-0.9869: aggressive optimization discovers the proxy’s highly rewarded failure.

Each full fitting update costs O(N+K)O(N+K) for NN comparisons and KK scores; the closed-form policy computation costs O(K)O(K). The program checks finite inputs and labels in [0,1][0,1]. It fits tabular scores only; there is no representation learning, annotation interface or transformer reward head.

Preference prediction and policy evaluation have different distributions

Held-out comparisons should test prompts, candidates and annotators that match the intended claim. Splitting individual pairs can leak the same prompt or response into both sides. Also evaluate generated responses after optimization, because the policy can find regions rarely seen by the reward model.

A single scalar can combine conflicting objectives in a way that hides tradeoffs. Report the annotation rubric, disagreement, abstentions, coverage and calibration. Human comparisons are informative evidence about a stated judgment task; they are not automatically factual verification. A model that prefers polished wording may still reward a wrong answer.

The synthetic counterexample demonstrates possibility, not a measured failure rate of any deployed system. An ensemble or stronger reference penalty may help in some settings, but neither is a certificate that proxy optimization is safe or accurate.

Look for what the data leaves free

  1. Does preference probability 0.8 imply reward 0.8?

Answer: No. It implies a score difference log⁡4\log4 under this model; (log4,0) and (log4+20,20) give the same preference probability.

  1. Why do the −4-4 and 44 assignments to the fourth answer have equal observed loss?

Answer: That answer occurs in no comparison. Its score is absent from every difference in the likelihood, even though it strongly changes a subsequently optimized policy.

  1. Can centering rewards fix overconfident probabilities?

Answer: No. Centering subtracts a common constant, leaving differences and probabilities unchanged. Calibration concerns their scale or a more general mismatch, and must be assessed on appropriate data.

  1. A proxy score improves at every optimization setting. What additional number in the example reveals failure?

Answer: The separately defined expected utility falls to about −0.9869-0.9869 at β=0.25\beta=0.25. Proxy improvement alone hides this reversal; in an actual application the independent outcome measure needs its own evidence and limitations.

Three separate claims to verify

Use Christiano’s method section to study how comparisons supervise a reward, DPO’s preliminaries for the response-level likelihood, and Gao’s synthetic setup to understand what an overoptimization experiment measures. Keep separate the claims that a reward predicts labels, that a policy optimizes that reward, and that the resulting behavior satisfies the intended goal.

Make a prediction, then check

What changes if the same constant is added to both reward scores?

Choose one answer

Learning objectives

  • Derive pairwise likelihood and identify data-coverage limits.
  • Verify the toy calculation and state what it cannot establish.

Prerequisites & connections

Explore related knowledge →

References

  1. Deep Reinforcement Learning from Human Preferences — v1
    Paul F. Christiano; Jan Leike; Tom B. Brown; Miljan Martic; Shane Legg; Dario Amodei · 2017
  2. Direct Preference Optimization: Your Language Model is Secretly a Reward Model — v2
    Rafael Rafailov; Archit Sharma; Eric Mitchell; Stefano Ermon; Christopher D. Manning; Chelsea Finn · 2023
  3. Scaling Laws for Reward Model Overoptimization — v1
    Leo Gao; John Schulman; Jacob Hilton · 2022

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-20 · Single AI author. Section2.2 through2.2.4 opening; PDF5 viewed: trajectory comparisons, soft labels, negative cross-entropy and actual recipe modifications. Sections3/4, PDF3/4 viewed; gradient and procedure text read. BT, KL objective, partition cancellation and DPO; v2 dated2023-12-13. Sections2.1/2.2 and preceding best-of-n text; PDF4 viewed. Synthetic gold RM versus proxy, deterministic comparisons and recalibration; no empirical scaling fit reproduced. Seven paired equations and four explained exercises. Pairwise likelihood gradients, offset invariance, known odds, cyclic preferences, unobserved score freedom and proxy/utility reversal; no objective human-utility claim.

  • Pairwise likelihood gradients, offset invariance, known odds, cyclic preferences, unobserved score freedom and proxy/utility reversal; no objective human-utility claim.
  • Four computed SVG variants per topic;10 numeric/geometry tests and30 responsive cases passed. Ten selected final captures directly viewed. Full article acceptance recorded separately.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.