Your dev cases now carry labels such as “that hut 6 is closed, from the August 28 report,” but string checks can’t grade them because the assistant can say “closed” in a dozen ways, including in Italian. Grading meaning takes a model judge: a second model call that grades the assistant’s answer.
In this lesson, you’ll write a judge for one criterion and get a pass rate from it. Start with the judge most people write first, which asks for a score.
Ask for a Score
A score from 1 to 10 looks more precise than a pass or a fail. To test one, take two answers to your hut 6 failure case, from before and after the closure report. Save them in evals/answers.js:
evals/answers.js
export const question =
"hut 6 open this weekend? need a bed sat night";
export const answers = {
open: "Hut 6 is open and staffed (warden, July 10). "
+ "It's full on Saturday nights, so book ahead.",
closed: "Hut 6 closed for the season on August 28 "
+ "(warden): the spring is dry. Try hut 5 or hut 7.",
};
This script asks the model to rate each answer six times, stops with a grading error on any reply that isn’t a whole number from 1 to 10, and then prints the scores and their average. Save it as evals/score.js:
evals/score.js
import { ask } from "../model/index.js";
import { question, answers } from "./answers.js";
for (const [name, answer] of Object.entries(answers)) {
const scores = [];
for (let i = 0; i < 6; i++) {
const { text } = await ask({
instructions: "Rate the quality of the answer from 1 "
+ "to 10. Reply with the number only.",
messages: [{
role: "user",
content: `Question: ${question}\nAnswer: ${answer}`,
}],
});
const score = Number(text.trim());
if (!Number.isInteger(score) || score < 1 || score > 10) {
throw new Error(`Grading error: not a 1-10 score: "${text}"`);
}
scores.push(score);
}
const average = scores.reduce((a, b) => a + b) / 6;
console.log(name, scores.join(" "), average.toFixed(1));
}
Add "score": "node --env-file=.env evals/score.js" to the scripts in package.json. Before you run npm run score, predict the answers to these questions: Does each answer get the same score six times? If the stale answer scores low, what should the assistant change?
This is one run with OpenAI on December 1, 2026:
$ npm run score
> [email protected] score
> node --env-file=.env evals/score.js
open 3 3 3 2 3 4 3.0
closed 9 9 8 3 8 8 7.5
The same correct answer scored 3 and 9, and across five runs its average ranged from 5.3 to 8.3, so a three-point gap between prompt versions could be chance. A 3 doesn’t say whether the status, the tone, or the length is wrong. And the judge never saw the August 28 report, so it can’t know which answer is right. An average mixes all of that into a number no one agreed on.
The button below opens a chat with your AI mentor so you can talk through where the spread comes from. The chat has this question filled in: