Judge Calibration and Meta-Evaluation › Judge Ensembles
Michael BrenndoerferDecember 1, 20262 min read
Language AI HandbookAll chapters Now let's build a three-judge ensemble and evaluate it against the reference and against each judge's biases.
PythonIn [18]Expand
def aggregate_votes(df, columns, weights=None):
votes = df[columns].to_numpy(dtype=float)
weight_vector = (
np.ones(len(columns)) if weights is None else np.asarray(weights)
)
zero_votes = (votes == 0) @ weight_vector
one_votes = (votes == 1) @ weight_vector
close = np.isclose(zero_votes, one_votes, rtol=1e-12, atol=1e-12)
chosen = np.where(close, np.nan, np.where(zero_votes > one_votes, 0.0, 1.0))
return pd.Series(chosen, index=df.index)
judge_cols = ["judge_A", "judge_B", "judge_C"]
calibration = fixture.index % 2 == 0
test_mask = ~calibration
weights = {}
for col in judge_cols:
kappa = cohen_kappa(
fixture.loc[calibration, "ref_majority"], fixture.loc[calibration, col]
)
weights[col] = max(0.0, kappa) if np.isfinite(kappa) else 0.0
for suffix in ("", "_swapped"):
columns = [col + suffix for col in judge_cols]
fixture["ensemble_vote" + suffix] = aggregate_votes(fixture, columns)
fixture["weighted_vote" + suffix] = aggregate_votes(
fixture, columns, list(weights.values())
)ConsoleOut [19]Expand
Agreement weights fitted on the calibration half:
judge_A: 0.585
judge_B: 0.549
judge_C: 0.339
judge_A | held-out kappa 0.596 | coverage 0.957
judge_B | held-out kappa 0.520 | coverage 0.947
judge_C | held-out kappa 0.378 | coverage 0.977
ensemble_vote | held-out kappa 0.571 | coverage 0.980
weighted_vote | held-out kappa 0.573 | coverage 1.000Evaluate majority and weighted votes on the held-out half. Compare coverage and kappa together, since a method can change which items contribute.
PythonIn [20]Expand
ensemble_pos = position_bias(fixture, "ensemble_vote")
ensemble_len_rho = length_pref_correlation(fixture, "ensemble_vote")
ensemble_source = source_affinity(fixture, "ensemble_vote", "model_b")
print(
f"Majority: position {ensemble_pos:.3f}, length {ensemble_len_rho:.3f}, "
f"model_b affinity {ensemble_source:.3f}"
)ConsoleOut [21]Expand
Judge A: pos=0.000, len_rho=0.031 Judge B: pos=0.137, len_rho=0.045 Judge C: pos=0.000, len_rho=0.620
The majority vote has its own position and length statistics. The results describe fixed synthetic draws and do not establish a general reduction.
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!