When do you use code-based graders versus model-based graders?
969 views
23 of 83
1
The problem
Question presented to candidate:
"You are setting up evals for an assistant that answers refund questions with a JSON record and a short customer message. Which checks would you write as code, which would you hand to an LLM grader, and how would you decide in general?"
What a strong answer should cover:
Code-based graders for anything with an objective answer: schema and parse checks, exact or normalised match, numeric tolerance, regex or forbidden-content rules, citations that must resolve, unit tests for generated code; they are cheap, fast, deterministic and debuggable
Model-based graders (LLM-as-judge) only for qualities code cannot decide: tone, faithfulness to sources, helpfulness, whether a free-text answer addresses the question; they need a rubric, cost a model call per case and carry biases
Decompose a vague quality into checkable parts first; often most of "is this answer good" turns into code checks, with one or two judged dimensions left
Validate any model grader against human labels before trusting it: confusion matrix, how many real failures it catches, kappa, and re-validation when the judge model or prompt changes
Layer them: code checks gate first (fail fast, no judge cost on broken output), judges on what survives, humans to calibrate both and to review disagreements
Clarifying questions expected:
Is there a single correct answer for parts of the output (IDs, amounts, policy windows), or is it all open-ended prose?
How often will the suite run, and what is the budget per run?
Do we have human-labelled examples to validate a judge against?
Code / implementation expected: Optional โ a few code graders plus a stub judge over the same outputs, or a confusion matrix comparing a judge with human labels.
graders
evals
code-graders
llm-as-judge
2
Try it yourself
Sketch your approach before you read the solution. That is what the interview tests.
Stuck? Get a hint.
A short nudge toward the approach. It will not give the answer away.
3
Solution
Target Audience: Engineers writing their first eval suite who need to decide, check by check, whether to write a function or ask a model, and candidates who should be able to defend that choice.
Difficulty: Medium
Verified with: Node 22 and Python 3.12 (five code graders and a stub judge over ten outputs, and a judge-versus-human validation with corrected pass rates). Judge verdicts are canned stand-ins for model calls; token prices in the cost line are assumptions. Vendor tooling is described from its docs with dates, checked October 2026.
How to read this doc: Every idea is explained in plain language first, then tagged with ๐ Interview term: so you also learn the words an interviewer expects. All program output shown was produced by actually running the examples; the Verified section quotes it in full.
1. Why This Even Matters โ A Story First
A school ex
The solution is hidden so you can try first
14 min read ยท 14 sections
4
Read the code
Five code graders and a stub judge on ten refund replies