Measure the Judge Against People
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".
agreement(x, y, ties=True)is the share of positions wherex[i] == y[i], rounded to 3 places. Lists of different lengths raiseValueError, here and inkappa.- Without ties. With
ties=False, first drop every position where either side said"tie", then take the share over what is left. - Nothing to measure. When no positions are left (empty lists, or every position dropped), return
None: not0.0, and not aZeroDivisionError. kappa(x, y)is Cohen's kappa over all positions, ties included:(p_o - p_e) / (1 - p_e).p_ois the share of positions that agree, unrounded.p_esums, over the labels, the share ofxwith that label times the share ofywith it. Round only the result to 3 places. ReturnNonefor empty lists, and whenp_eis 1 (both sides gave the same one label every time).judge_report(votes)takes votes as(judge, human, second_human), wheresecond_humanisNonewhen only one person voted. It returns{"judge": block, "humans": block}, each block{"n": count, "with_ties": ..., "without_ties": ..., "kappa": ...}withnthe 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.