Loading video player…

Sample Cases From Real Questions

In this lesson, you put questions a model wrote beside the messages hikers really sent, then built the start of an eval set from a sample of last season’s log.

Key Points

  • Generated questions don’t look like real ones. Asked for ten questions hikers might send, the model (five recorded runs on 1 December 2026) returned ten complete, polite English questions about huts this trail doesn’t have, and ten of ten ended with a question mark. Your run will word them differently.
  • Real messages are messier. Real hikers type fragments on a phone, switch languages, ask two things at once, and ask for things the assistant doesn’t do. A prompt for messier questions only gives you the mess you thought of: the log shows what hikers really send, and how often.
  • Start from the log. The starting project’s data/questions.jsonl holds three hundred of last season’s messages, each with its month, its language, and its safety: "emergency", "hazard" (a wrong answer could hurt someone), or "none". The log’s personal data was stripped before you got it, and the starting project’s README says how.
  • Sample across the season. The log is in date order, so keeping every sixth message spreads the sample over the whole season: fifty of three hundred.
  • Count every slice. Counting the sample by month, language, and safety, next to the whole log’s counts, shows the thin slices. A slice is thin when it has too few cases to tell you anything, whatever its share of the log: one Italian case of nine, one French of twelve, and one of thirteen emergencies.
  • Fill thin slices from the log first. Adding every emergency, French, or Italian message the sample didn’t include gives seventy-nine cases, written to evals/cases.jsonl, one case per line. The script writes over that file, so move your twelve invented cases to evals/invented-cases.jsonl first.
  • Read results per slice. The set over-represents the thin slices on purpose, so one overall pass rate doesn’t describe real traffic.
  • Generate only for a slice the log can’t fill. Nine Italian cases are still few, and the log has no more. That’s when you generate cases, each marked synthetic and read by a person before it goes in.
  • Scale: three hundred messages is a small log. Real traffic gives thousands, and the same counts work there.

Final Code

First, move the twelve invented cases out of the way, since the script writes over evals/cases.jsonl:

Language: Shell
$ mv evals/cases.jsonl evals/invented-cases.jsonl

Then evals/sample.js samples the log, counts every slice, and fills the thin ones:

Language: JavaScript Filename: evals/sample.js
import { readFileSync, writeFileSync } from "node:fs";

const log = readFileSync("data/questions.jsonl", "utf8")
  .trim().split("\n").map((line) => JSON.parse(line));

const sample = log.filter((q, i) => i % 6 === 5);

function countBy(questions, field) {
  const counts = {};
  for (const q of questions) {
    counts[q[field]] = (counts[q[field]] ?? 0) + 1;
  }
  return counts;
}

function report(cases) {
  console.log(cases.length, "of", log.length, "questions");
  for (const field of ["month", "lang", "safety"]) {
    const inLog = countBy(log, field);
    const inCases = countBy(cases, field);
    for (const value in inLog) {
      console.log(` ${field} ${value}: ${inCases[value] ?? 0} of ${inLog[value]}`);
    }
  }
}

const thin = (q) => q.safety === "emergency" || q.lang === "fr" || q.lang === "it";
const cases = [...sample, ...log.filter((q) => thin(q) && !sample.includes(q))];

report(cases);
writeFileSync("evals/cases.jsonl", cases.map((q) => JSON.stringify(q)).join("\n") + "\n");

Run node evals/sample.js on the starting project’s log, and it prints:

Language: Text
79 of 300 questions
 month june: 10 of 40
 month july: 28 of 100
 month august: 28 of 110
 month september: 13 of 50
 lang en: 47 of 231
 lang de: 11 of 48
 lang fr: 12 of 12
 lang it: 9 of 9
 safety emergency: 13 of 13
 safety hazard: 23 of 124
 safety none: 43 of 163

Your seventy-nine cases have nothing to check answers against yet, so npm run evals can’t grade them. In the next lesson, Label Cases and Hold Some Out, you’ll write down what a good answer to each must have, and set some aside.

00:00 In the last lesson, your assistant passed all twelve eval cases, thirty-six answers out of thirty-six. However, someone wrote those twelve questions while building the assistant.

00:13 To tell you how it does with real hikers, the set needs more cases. The quickest way to get more is to ask a model to write them.

00:24 This script sends one request through the project’s ask function: write ten questions hikers might send to a trail-conditions assistant. Then it logs the model that answered, each question, and how many end with a question mark.

00:40 Run it, and ten questions come back. They look like a fine start. Each one is a complete, polite question in English. And ten of ten end with a question mark.

00:52 Your run will differ, but in five runs, that shape held.

00:58 Now put them beside what hikers typed last season: three hundred messages in the starting project’s log. Each has its month, its language, and a safety tag, such as emergency.

01:11 Here are a few. Valbrune ford after the rain, with two question marks. The same question in German. Beds at hut 6, and do they take cards.

01:23 And this one is an emergency, so the assistant must give the rescue number and stop. With this prompt, the model wrote tidy, complete questions in English, about huts this trail doesn’t have.

01:37 Real hikers type fragments on a phone, switch languages, ask two things at once, and ask for things the assistant doesn’t do. Ask for messier questions, and you only get the mess you thought of.

01:50 The log shows what hikers really send, and how often.

01:55 So start from the log, and make real messages your cases.

02:00 This script reads the log into an array, one object per message. Then it keeps every sixth message. The log is in date order, so the sample spreads over the whole season.

02:14 Next, one function counts messages per value of a field. Another prints them for month, language, and safety, next to the whole log’s counts. Run it, and fifty of the three hundred messages are in the sample.

02:30 The months look fine, with about one message in six from each. But a slice is thin when it has too few cases to tell you anything, whatever its share of the log.

02:43 Italian has one of nine. French has one of twelve. And emergencies have one of thirteen. One case can’t tell you how the assistant handles them.

02:55 So top up the thin slices from the log itself. The first new line tests for a thin slice: an emergency, French, or Italian. The second adds each one that passes and isn’t in the sample yet.

03:09 The sample holds the log’s own objects, so the includes check finds them. The script writes over the file holding your twelve invented cases, so first move them to their own file.

03:23 Run it again, and you get seventy-nine cases. That’s all twelve French messages, all nine Italian, and all thirteen emergencies.

03:32 On purpose, the set now over-represents these slices. So read results per slice as well as overall. The log’s personal data was stripped before you got it, and the starting project’s README says how.

03:47 Three hundred messages is a small log. Real traffic gives thousands, and the same counts work there.

03:56 The rule is to build the eval set from a sample of real messages, count every slice, and fill the thin ones from the log. Nine Italian cases are still few, and the log has no more.

04:08 That’s when you generate cases, each marked synthetic and read by a person before it goes in. Your seventy-nine cases have nothing to check answers against yet, so npm run evals can’t grade them.

04:21 In Label Cases and Hold Some Out, you’ll write down what a good answer to each must have, and set some aside.

Become a Member to join the conversation.