Outcome and Process Reward Models › From Labels to a Learned PRM
Language AI HandbookAll chapters The hand-worked table used exact labels. In practice you have a learned model. We now build one on the same graph, estimate it from samples, and see which of the qualitative conclusions survive.
The careful policy samples legal successors uniformly. From node 0 it reaches the goal in four legal steps with probability one half at this budget. When a successor exists, the sloppy policy chooses the legal-successor branch with probability 0.7. Otherwise or on the random branch, it samples a node uniformly. A random jump can land on a legal successor. The guesser takes zero, one, or two legal steps before jumping to the goal in the default sampler. None reaches the goal through a fully legal path.
Careful and sloppy provide in-distribution examples. Guesser generates the shifted examples used to distinguish answer success from chain validity.
PythonIn [8]Expand
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_auc_score
START, GOAL = 0, 9
ADJ = {
0: [1, 2],
1: [3, 4],
2: [5, 6],
3: [7],
4: [],
5: [],
6: [8],
7: [9],
8: [9],
9: [],
}
NODES = sorted(ADJ)
OUT_DEG = {u: len(ADJ[u]) for u in NODES}
solvable = {u: False for u in NODES}
solvable[GOAL] = True
changed = True
while changed:
changed = False
for u in NODES:
if not solvable[u] and any(solvable[v] for v in ADJ[u]):
solvable[u] = True
changed = TrueConsoleOut [9]Expand
out-degree: {0: 2, 1: 2, 2: 2, 3: 1, 4: 0, 5: 0, 6: 1, 7: 1, 8: 1, 9: 0}
can still reach goal: {0: True, 1: True, 2: True, 3: True, 4: False, 5: False, 6: True, 7: True, 8: True, 9: True}The backward reachability confirms that nodes 4 and 5 are the only dead ends, exactly as the adjacency suggests.
Next, the sampler and the labeler. Every trajectory stores its path, its per-step labels under both semantics, and its outcome label.
PythonIn [10]Expand
def sample_candidate(rng, policy, max_steps=5):
path = [START]
for _ in range(max_steps):
u = int(path[-1])
if u == GOAL:
break
if policy == "careful":
if not ADJ[u]:
break
v = int(rng.choice(ADJ[u]))
elif policy == "sloppy":
if ADJ[u] and rng.random() < 0.70:
v = int(rng.choice(ADJ[u]))
else:
v = int(rng.integers(0, 10))
elif policy == "guesser":
if len(path) >= int(rng.integers(1, 4)):
v = GOAL
elif ADJ[u]:
v = int(rng.choice(ADJ[u]))
else:
v = GOAL
else:
raise ValueError(policy)
path.append(v)
if v == GOAL:
break
return path
def label_candidate(path):
steps = []
for u, v in zip(path[:-1], path[1:]):
valid_edge = v in ADJ[u]
solvable_target = solvable[v]
steps.append(
{
"u": u,
"v": v,
"valid_edge": int(valid_edge),
"solvable_target": int(solvable_target),
"good_step": int(valid_edge and solvable_target),
}
)
return {
"path": tuple(path),
"steps": steps,
"n_steps": len(steps),
"outcome": int(path[-1] == GOAL),
}We build three pools from a single seeded generator. The train and test pools mix careful and sloppy trajectories. The shift pool contains only guessers.
PythonIn [11]Expand
rng = np.random.default_rng(0)
def build_pool(policy, n):
rows = []
for _ in range(n):
rec = label_candidate(sample_candidate(rng, policy))
rec["policy"] = policy
rows.append(rec)
return rows
train_pool = build_pool("careful", 300) + build_pool("sloppy", 300)
test_pool = build_pool("careful", 300) + build_pool("sloppy", 300)
shift_pool = build_pool("guesser", 300)| pool | n | success_rate | mean_steps | |
|---|---|---|---|---|
| 0 | train | 600 | 0.577 | 3.537 |
| 1 | test | 600 | 0.548 | 3.633 |
| 2 | shift (guesser) | 300 | 1.000 | 1.933 |
The training and test pools contain fresh draws from the same policy mixture on the same graph. They do not share sampled records, but a complete path can recur in both pools.
Every guesser reaches node 9 through an illegal last edge. Earlier edges can be valid. The pool therefore has perfect terminal correctness with no fully legal chain. These are different endpoints, so the results depend on which endpoint you measure.
Two Learned Scorers
The outcome grader receives trajectory length, legal-edge fraction, fraction of steps landing on non-goal dead ends, and mean out-degree over step targets. It does not receive the final node as a feature.
The outcome grader does not receive the terminal node directly. Its inputs still summarize path length and graph-derived features. These can predict final-answer success on the held-out pool without estimating whether every step is valid.
PythonIn [13]Expand
def traj_features(rec):
steps = rec["steps"]
if not steps:
return np.zeros(4)
valid_frac = float(np.mean([s["valid_edge"] for s in steps]))
dead_frac = float(
np.mean([OUT_DEG[s["v"]] == 0 and s["v"] != GOAL for s in steps])
)
mean_deg = float(np.mean([OUT_DEG[s["v"]] for s in steps]))
return np.array([rec["n_steps"], valid_frac, dead_frac, mean_deg])
def step_features(s, i):
return np.array(
[s["valid_edge"], OUT_DEG[s["v"]], float(s["v"] == GOAL), i]
)The step grader sees the legality of the edge, the out-degree of the target, whether the target is the goal, and the index of the step. We fit both models with logistic regression on the training pool. The outcome model is fit on trajectory-level labels; the step model is fit on all individual steps.
Edge legality is an explicit input to the step grader. Out-degree and the goal indicator make the other part of its label directly inferable in this graph. The toy’s step-grader AUC measures performance on that deliberately simple task.
PythonIn [14]Expand
X_train = np.vstack([traj_features(r) for r in train_pool])
y_train = np.array([r["outcome"] for r in train_pool])
orm = LogisticRegression(max_iter=2000, C=0.05).fit(X_train, y_train)
step_X_train = np.vstack(
[step_features(s, i) for r in train_pool for i, s in enumerate(r["steps"])]
)
step_y_train = np.array(
[s["good_step"] for r in train_pool for s in r["steps"]]
)
prm = LogisticRegression(max_iter=2000, C=0.2).fit(step_X_train, step_y_train)PythonIn [15]Expand
def orm_scores(pool):
return orm.predict_proba(np.vstack([traj_features(r) for r in pool]))[:, 1]
def prm_step_scores(rec):
if not rec["steps"]:
return np.array([], dtype=float)
X = np.vstack([step_features(s, i) for i, s in enumerate(rec["steps"])])
return prm.predict_proba(X)[:, 1]
test_outcomes = np.array([r["outcome"] for r in test_pool])ConsoleOut [16]Expand
Outcome grader AUC on test: 0.96 Step grader AUC on test: 1.0
The cell reports AUC separately on held-out outcomes and step labels. The step grader receives edge validity directly and can identify dead ends from out-degree and a goal indicator. This deliberately simple target can be highly separable. Neither AUC estimates natural-language grading performance.
The outcome and step AUCs use different prediction targets. Their difference does not establish which aggregation will select the best completed path.
Reranking With Each Scorer
We now build five trajectory scorers and run best-of- on the test pool. Every sampled path has at least one transition. A path with zero transitions stays at the start, so the three PRM scorers return 0 for it.
PythonIn [17]Expand
def build_scores(pool):
scores = {"Verifier": np.array([r["outcome"] for r in pool], dtype=float)}
scores["ORM"] = orm_scores(pool)
prods, mins, lasts = [], [], []
for rec in pool:
p = prm_step_scores(rec)
if p.size:
product, minimum, last = (
float(np.prod(p)),
float(np.min(p)),
float(p[-1]),
)
else:
product, minimum, last = 0.0, 0.0, 0.0
prods.append(product)
mins.append(minimum)
lasts.append(last)
scores["PRM product"] = np.array(prods)
scores["PRM min"] = np.array(mins)
scores["PRM last"] = np.array(lasts)
return scores
test_scores = build_scores(test_pool)
shift_scores = build_scores(shift_pool)
def best_of_n(scores, outcomes, n_values, trials=400, seed=1):
rng_local = np.random.default_rng(seed)
curve = {}
M = len(outcomes)
for n in n_values:
hits = 0
for _ in range(trials):
idx = rng_local.choice(M, size=n, replace=False)
best = idx[int(np.argmax(scores[idx]))]
hits += int(outcomes[best])
curve[n] = hits / trials
return curve
n_values = [1, 2, 4, 8, 16, 32, 64]
curves = {
name: best_of_n(sc, test_outcomes, n_values)
for name, sc in test_scores.items()
}
# The ORM features omit the final node identity. The fit uses C=0.05.
# Report the measured curve for this feature and regularization choice.
# The fitted response at each budget is computed above.VisualizationOut [18]Expand

The answer checker’s rate depends on whether a sampled subset contains a goal-ending path. With these seeded draws, the product and minimum both reach 1.0 at budget 16, while the ORM reaches 1.0 at 64. Last-step ranking drops to 0.48 at 64. These rates summarize the synthetic trials. The next table uses a fresh set of sampled subsets to check how often the selected path also has a fully valid chain.
PythonIn [19]Expand
def selection_quality(scores, pool, n, trials=400, seed=2):
rng_local = np.random.default_rng(seed)
M = len(pool)
success, valid = 0, 0
for _ in range(trials):
idx = rng_local.choice(M, size=n, replace=False)
best = idx[int(np.argmax(scores[idx]))]
rec = pool[best]
success += rec["outcome"]
valid += int(
rec["outcome"] == 1 and all(s["good_step"] for s in rec["steps"])
)
return success / trials, valid / trials
N_FIX = 16
quality_rows = []
for name, sc in test_scores.items():
succ, valid = selection_quality(sc, test_pool, N_FIX)
quality_rows.append(
{"scorer": name, "success": succ, "correct_and_valid": valid}
)
quality = pd.DataFrame(quality_rows)| scorer | success | correct_and_valid | |
|---|---|---|---|
| 0 | Verifier | 1.000 | 0.608 |
| 1 | ORM | 0.955 | 0.238 |
| 2 | PRM product | 1.000 | 1.000 |
| 3 | PRM min | 1.000 | 1.000 |
| 4 | PRM last | 0.882 | 0.288 |
The table separates selected-answer success from selecting a correct answer on a valid chain. At a budget of 16, this table reuses the same 400 fresh subsets across scorers. In this run, product and minimum select correct, valid paths on every trial. Answer-only checking reaches the goal every time but selects a valid chain in about 0.61 of the trials. Both columns use all selections as their denominator.
Final-answer accuracy cannot distinguish selections that end at the same answer. If step validity matters, add a chain-level measure with a separate source of validity labels.
VisualizationOut [21]Expand

Reranking by Length Stratum
Length and terminal success are related in this pool. The table compares the same sampled subsets across scorers within three strata. It leaves out 9 of the 600 test paths. All nine are one-step paths that reach node 9 by an illegal jump. The 4+ band pools several lengths.
A length-stratified result answers a different question from overall performance. Inspect each stratum’s composition and sample size before attributing a difference to reasoning quality.
PythonIn [22]Expand
def selection_by_length(scores, pool, n=16, trials=300, seed=4):
rng_local = np.random.default_rng(seed)
bands = {
"2 steps": [i for i, r in enumerate(pool) if r["n_steps"] == 2],
"3 steps": [i for i, r in enumerate(pool) if r["n_steps"] == 3],
"4+ steps": [i for i, r in enumerate(pool) if r["n_steps"] >= 4],
}
rows = []
for band, idxs in bands.items():
if len(idxs) < 2:
continue
samples = [
rng_local.choice(idxs, size=min(n, len(idxs)), replace=False)
for _ in range(trials)
]
for name, sc in scores.items():
hits = 0
for take in samples:
best = take[int(np.argmax(sc[take]))]
hits += pool[best]["outcome"]
rows.append(
{"band": band, "scorer": name, "success": hits / trials}
)
return pd.DataFrame(rows)
length_table = selection_by_length(test_scores, test_pool)| scorer | ORM | PRM last | PRM min | PRM product | Verifier |
|---|---|---|---|---|---|
| band | |||||
| 2 steps | 0.917 | 0.83 | 0.0 | 0.0 | 0.917 |
| 3 steps | 1.000 | 1.00 | 1.0 | 1.0 | 1.000 |
| 4+ steps | 0.937 | 0.82 | 1.0 | 1.0 | 1.000 |
Any path with two or three steps that reaches the goal contains an illegal transition in this graph. A selector that prioritizes legal prefixes can therefore miss some terminally correct paths in these strata.
Calibration Under Policy Shift
The guesser pool comes from a policy excluded from training. Each path reaches the goal and contains an illegal jump.
In this run, the shifted pool has mean predicted success of about 0.602 against observed success of 1.000. The grader underpredicts success in the large. The shifted paths contain illegal edges, but the model uses several path features, so the mean gap does not establish that any one feature caused it.
PythonIn [24]Expand
calibration = pd.DataFrame(
[
{
"pool": "in-distribution",
"mean_predicted": float(np.mean(test_scores["ORM"])),
"observed": float(np.mean([r["outcome"] for r in test_pool])),
},
{
"pool": "shift (guesser)",
"mean_predicted": float(np.mean(shift_scores["ORM"])),
"observed": float(np.mean([r["outcome"] for r in shift_pool])),
},
]
)VisualizationOut [25]Expand

The difference between the mean prediction and the observed success rate measures calibration in the large. Close means do not establish calibration across the score range. Here the shifted pool always reaches the goal and has a higher observed success rate than its mean predicted probability.
Because every guesser trajectory ends at node 9, final-answer correctness gives these candidates identical labels. Measure legal transitions separately.
Gao et al. trained a proxy from a fixed gold reward model and measured gold score as optimization pressure increased. They found different empirical curves for RL and best-of- in that synthetic setup.
Reward Hacking and Overoptimization
For this stress test, draw 200 fresh subsets per budget from the same test pool. Rank candidates using the final step’s PRM score and record that score and the terminal success label for each selection. A high last-step score does not require a complete path to the goal: a valid transition into a solvable intermediate node can also score well.
A valid step can end on an intermediate node without providing a correct final answer. Optimizing the last step’s score can therefore select unfinished trajectories, even with a well-fit step model.
PythonIn [26]Expand
overopt = {"n": [], "proxy": [], "true": []}
rng_opt = np.random.default_rng(3)
for n in [1, 2, 4, 8, 16, 32, 64, 128, 256]:
proxies, truths = [], []
for _ in range(200):
idx = rng_opt.choice(len(test_pool), size=n, replace=False)
best = idx[int(np.argmax(test_scores["PRM last"][idx]))]
proxies.append(float(test_scores["PRM last"][best]))
truths.append(int(test_pool[best]["outcome"]))
overopt["n"].append(n)
overopt["proxy"].append(float(np.mean(proxies)))
overopt["true"].append(float(np.mean(truths)))VisualizationOut [27]Expand

At budget 64, last-step ranking returns a correct answer in 0.575 of the stress-test trials. The earlier 400-trial sweep gives 0.480 at the same budget on a different set of sampled subsets. At budget 256, last-step selection mostly returns paths ending at nodes 1 and 2. Those paths can end with a good step even though they never reach the goal. The expected maximum score increases weakly with subset size under uniform sampling without replacement. Finite estimates made with independent draws do not have to be monotone.
A scorer can be accurate on its own step label yet make a poor trajectory reward after reduction. Evaluate the aggregation against the selected-answer or chain-level behavior it should support across the budgets you plan to use.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!