Judge Calibration and Meta-Evaluation › Bias Diagnostics
Michael BrenndoerferDecember 1, 20262 min read
Language AI HandbookAll chapters We now compute the three bias statistics for each judge: position, verbosity, self-preference.
PythonIn [10]Expand
def position_bias(df, judge_col):
original = df[judge_col]
swapped = df[f"{judge_col}_swapped"]
both_decided = original.notna() & swapped.notna()
if not both_decided.any():
return float("nan")
first_wins = (original[both_decided] == 0).sum() + (
swapped[both_decided] == 1
).sum()
return float(first_wins / both_decided.sum() - 1)
def length_pref_correlation(df, judge_col):
from scipy.stats import spearmanr
choice = df[judge_col]
decided = choice.notna()
length_gap = df.loc[decided, "len_diff"]
side = choice[decided].map({0: 1, 1: -1})
if len(side) < 5 or min(side.nunique(), length_gap.nunique()) < 2:
return float("nan")
return float(spearmanr(length_gap, side).statistic)
def source_affinity(df, judge_col, source):
choice = df[judge_col]
own_first = df["src_1"] == source
own_second = df["src_2"] == source
one_own_and_decided = (own_first ^ own_second) & choice.notna()
if not one_own_and_decided.any():
return float("nan")
match_source = choice[one_own_and_decided] == np.where(
own_first[one_own_and_decided], 0, 1
)
return float(match_source.mean() - 0.5)
bias_rows = []
for name in ("A", "B", "C"):
col = f"judge_{name}"
bias_rows.append(
{
"judge": name,
"position_bias": position_bias(fixture, col),
"length_pref_rho": length_pref_correlation(fixture, col),
"source_affinity": source_affinity(fixture, col, "model_b"),
}
)
bias_df = pd.DataFrame(bias_rows)ConsoleOut [11]Expand
judge position_bias length_pref_rho source_affinity
A 0.000 0.031 0.009
B 0.137 0.045 -0.006
C 0.000 0.620 0.212B is the simulator with a position bonus. C has length and Model B bonuses. The Model B affinity diagnostic uses the same source criterion for every judge.
Check the denominator before interpreting an alert. The order statistic omits pairs with a nondecision in either presentation. Source affinity and length association omit nondecisions in the original order.
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!