Skip to content
mentoor

Topic 5 of 5 · 5 min read

What code graders cannot judge

Goal: Spot a code grader that passes a wrong answer or fails a right one and propose the better grader.

A code grader sees strings and structure, not meaning, so it can only judge what meaning leaves visible. Knowing where that stops keeps you from trusting a green dashboard.

Check yourself · 1 of 3

A grader passes any refund answer that contains "30 days". Which answer does it wrongly pass?

Choose one answer

Why it matters

Code graders are cheap and stable, which makes them tempting to use for everything. But a rule cannot tell whether an answer is polite, whether a summary is faithful to its source, or whether advice would actually help. When a grader quietly measures the wrong thing, the team optimizes toward it. The score rises and quality does not.

Two ways a code grader lies

  1. False pass. The check is satisfied, the answer is wrong. A contains: "30 days" check passes "Refunds are not available within 30 days."
  2. False fail. The answer is right, the check rejects it. An equality check fails "thirty days" when the key says "30 days".

Both come from the same gap: the rule matches surface form, the task is about meaning.

How to decide what to use

  • Is there one checkable answer? Use exact match, a schema or a test.
  • Is it a known, visible failure? Use an assertion.
  • Does it need reading and understanding? Tone, faithfulness to a source, helpfulness, reasoning quality. Use an LLM judge with a written rubric, and check the judge against human labels.
  • Is it high stakes or new? Use a human review, at least on a sample, and use those labels to check the cheaper graders.

Layer them. Run code graders first: they are cheap and filter out broken outputs. Then run judges on what is left.

Before and after

# Weak: grades a refund answer by keyword
def grade(output: str) -> bool:
    return "30 days" in output and "refund" in output.lower()
def grade(output: str, judge) -> dict:
    cheap = "30 days" in output          # surface check, kept as a filter
    verdict = judge(
        rubric="States that refunds ARE allowed within 30 days of purchase; "
                "does not add conditions that are not in the policy.",
        output=output,
    )
    return {"keyword": cheap, "meaning": verdict}

The keyword stays as a cheap filter, and meaning goes to a judge you have checked against human labels.

What goes wrong

  • Brittle regexes. A pattern tuned on ten examples fails on the eleventh phrasing.
  • Goodhart effects. Prompts get tuned to satisfy the rule, not the reader.
  • Unverified hand-off. A judge model also errs, so sample its verdicts against human ones.

Examples

A keyword that passes a wrong answer

Policy: refunds are allowed within 30 days. The check is contains "30 days". The model answers "We cannot refund purchases, even within 30 days." The check passes and the answer contradicts the policy. A rubric judge that asks "does the answer say refunds are allowed within 30 days?" catches it.

Handing off with a human sample

A team scores 500 summaries with a judge. A reviewer labels 50 of them by hand. The judge agrees on 41. The team then reads the 9 disagreements, finds that the judge rewards length, and edits the rubric before trusting the other 450 scores.

Key points

  • Code graders judge surface form and structure; they cannot read meaning, tone or faithfulness.
  • A grader fails in two ways: a false pass on a wrong answer and a false fail on a right one.
  • Match the grader to the question: tests and schemas for checkable answers, judges for meaning, humans for high stakes.
  • Layer graders so cheap code checks filter first and judges run on what remains.
  • Check every judge, and every new rule, against human-labeled examples before you rely on it.

Common mistakes

  • Using a keyword or regex as the grader for faithfulness, tone or helpfulness.
  • Treating a rising code-grader score as proof that quality improved.
  • Replacing code graders with a judge for tasks that tests or schemas could grade exactly.
  • Trusting an LLM judge without comparing its verdicts to human labels.

Check yourself · 2 of 3

Which question is a poor fit for a code grader and needs a judge or a human?

Choose one answer

Check yourself · 3 of 3

A team moves all grading from tests and schemas to an LLM judge because it is more flexible. What is the main cost of that change?

Choose one answer

Practice items, not counted towards your mastery.

Start here