Standard library only · runs in your browser
The team wants to compare two prompts by asking an LLM which answer is better. The judge agrees with humans 60% of the time. Before anyone trusts that number, find out how much of it is the judge reading the answers and how much is the judge picking whichever answer came first.
judge(question, first, second) (provided) is the LLM judge. It returns "first" or "second". It's scripted so the tests are exact, and it has the two biases real judges have.
Each pair has two answers a and b, and the answer a person preferred ("human": "a" or "b").
Write evaluate_judge(pairs), returning three numbers rounded to 3 decimals:
raw_agreement: ask the judge once, a first and b second, and count how often its pick matches the human.swap_checked_agreement: ask twice, a-then-b and b-then-a. If both runs pick the same answer, that's the verdict. If they disagree, the verdict is a tie, and a tie never matches the human.position_flip_rate: how often the two runs disagree.evaluate_judge(pairs: list[dict]) -> dict (judge is provided)