Code-based graders
For engineers
Deterministic checks (exact match, schemas, assertions and executable tests) that grade fast and cheap, and where they stop working
110 questions across four stages: Understand, Apply, Solve and Judge.
Try 5 questions
Practice items, not counted towards your mastery. No account needed.
Check yourself · 1 of 5
A ticket classifier returns "Billing." and the key is "billing". Plain string equality marks it wrong. What is the right fix in the grader?
Check yourself · 2 of 5
An output is valid JSON and matches the schema, but the category is wrong. What does the schema check report?
Check yourself · 3 of 5
Why is running generated code against tests a stronger grader than reading it?
Check yourself · 4 of 5
After a prompt change, answers start with "I cannot browse the internet". Which assertion catches this cheaply on every run?
Check yourself · 5 of 5
A grader passes any refund answer that contains "30 days". Which answer does it wrongly pass?
Topics
- Exact and normalized answer matching4 min read · Comparing labels, extracted fields and numbers after normalizing case, whitespace and units, and knowing where exact match fails
- Validating output structure with schemas5 min read · JSON Schema, Pydantic or Zod checks for required fields, types and enums, grading format separately from content
- Executable tests as graders5 min read · Running generated code against tests, executing generated SQL on a fixture database and pass@k for code tasks
- Cheap assertions that catch regressions4 min read · Contains and not-contains checks, length limits, banned phrases, citation presence, language detection and PII patterns
- What code graders cannot judge5 min read · Tone, faithfulness and helpfulness, brittle regexes that pass wrong answers, and when to hand off to a judge or a human
Start here
- promptfoo: Assertions and metrics (opens in a new tab)DocsFree
Lists the deterministic assertion types (equals, contains, is-json, regex, javascript, python) with config examples.
- JSON Schema (opens in a new tab)StandardFree
The specification and learning material for required fields, types, enums and additionalProperties.
- Evaluating Large Language Models Trained on Code (Chen et al.) (opens in a new tab)PaperFree
Introduces HumanEval, functional-correctness grading by unit tests, and the unbiased pass@k estimator.
Scenarios
Helps to know first
110 questions · last verified 2026-12