Judge Calibration and Meta-Evaluation › Worked Example: Synthetic Fixture
Language AI HandbookAll chapters The example uses simulated votes and fixed paired presentations. It records which votes are missing, stratifies agreement by length, and evaluates fixed illustrative thresholds on held-out items. It does not produce confidence scores or run a live model.
The fixture draws two candidates per comparison from three possible source labels and records both lengths in characters. Judges A, B, and C add different position, length and source effects. Shared noise within each two-order presentation isolates the simulated position effect.
We use numpy for the simulation and pandas for the analysis. If any package is missing, install with uv pip install numpy pandas matplotlib scipy.
PythonIn [4]Expand
import numpy as np
import pandas as pd
rng = np.random.default_rng(7)
N = 600
item_ids = [f"item_{i:04d}" for i in range(N)]
# Candidate answers with lengths and source models.
# Candidate source labels affect length offsets. The latent preference is a
# separate random draw, independent of those source labels and lengths.
sources = np.array(["model_a", "model_b", "model_c"])
source_quality = {"model_a": 0.0, "model_b": 0.6, "model_c": -0.4}
lengths = rng.integers(40, 400, size=(N, 2))
# Add source-correlated length offset so length and source are entangled
source_pair = rng.choice(sources, size=(N, 2))
# Note: the draw is uniform per side in expectation, but the realized marginal
# counts under seed 7 are not exactly equal (side-0 counts are 167 model_a,
# 207 model_b, 226 model_c; pooling both sides gives 393/394/413).
for i in range(N):
for side in range(2):
lengths[i, side] += int(
30 * source_quality[source_pair[i, side]] + rng.normal(0, 60)
)
# Truncate the adjusted draws at one character.
lengths = np.maximum(lengths, 1)
# Reference labels from a simulated human panel: 3 annotators per item.
# Each annotator agrees with the latent "true preference" with probability 0.7
latent_pref = rng.choice(
[0, 1], size=N
) # 0 -> first listed is preferred, 1 -> second
panel = np.zeros((N, 3), dtype=int)
for a in range(3):
for i in range(N):
if rng.random() < 0.7:
panel[i, a] = latent_pref[i]
else:
panel[i, a] = 1 - latent_pref[i]
# Majority vote of panel as the reference label
ref_majority = (panel.mean(axis=1) > 0.5).astype(int)
fixture = pd.DataFrame(
{
"item_id": item_ids,
"len_1": lengths[:, 0],
"len_2": lengths[:, 1],
"src_1": source_pair[:, 0],
"src_2": source_pair[:, 1],
"ref_majority": ref_majority,
"panel_a1": panel[:, 0],
"panel_a2": panel[:, 1],
"panel_a3": panel[:, 2],
}
)
fixture["len_diff"] = fixture["len_1"] - fixture["len_2"]
fixture["position_of_ref"] = np.where(
fixture["ref_majority"] == 0, "first", "second"
)
fixture.head()The synthetic reference is the majority of three annotators. With independent errors at per-annotator accuracy 0.70, its expected latent-label accuracy is 0.784. Report measured panel-member reliability separately.
ConsoleOut [5]Expand
Items: 600 Reference label balance: 0.48 (fraction preferring 2nd) Mean length difference: 4.8, std: 168.8 Source-pair distribution: src_1 src_2 model_c model_a 91 model_b model_a 78 model_c model_b 78 model_b model_c 69 model_a model_c 61 Name: count, dtype: int64
Candidate lengths are at least one character. This draw gives a reference preference for the second canonical candidate on about 48% of items. Counterbalancing keeps each pair fixed and displays both orders. A position-neutral judge that makes the same decisive choice in both orientations contributes zero to the signed position statistic even when the reference or source labels are skewed.
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!