Skip to content

< all problems111 · Level 07, Evals

Measure the Judge Against People

medium · implement · Evals

Before you trust an LLM judge, measure how often it agrees with people, and how often people agree with each other. Implement three functions over parallel lists of pairwise verdicts, each "a", "b" or "tie".

  1. agreement(x, y, ties=True) is the share of positions where x[i] == y[i], rounded to 3 places. Lists of different lengths raise ValueError, here and in kappa.
  2. Without ties. With ties=False, first drop every position where either side said "tie", then take the share over what is left.
  3. Nothing to measure. When no positions are left (empty lists, or every position dropped), return None: not 0.0, and not a ZeroDivisionError.
  4. kappa(x, y) is Cohen's kappa over all positions, ties included: (p_o - p_e) / (1 - p_e). p_o is the share of positions that agree, unrounded. p_e sums, over the labels, the share of x with that label times the share of y with it. Round only the result to 3 places. Return None for empty lists, and when p_e is 1 (both sides gave the same one label every time).
  5. judge_report(votes) takes votes as (judge, human, second_human), where second_human is None when only one person voted. It returns {"judge": block, "humans": block}, each block {"n": count, "with_ties": ..., "without_ties": ..., "kappa": ...} with n the number of votes compared. "judge" compares the judge with the first human over every vote. "humans" compares the two humans over the votes that have a second human.

The catch. p_e uses each side's own label shares. A judge that always says "a", against people who said "a" 70% of the time, agrees 0.7 and has a kappa of 0.0. Pooling both lists into one share per label gives a different, wrong number.