Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Run Each Case More Than Once

In this video, you ran each case of the booking assistant’s eval set five times instead of once, and turned each case’s single verdict into a pass rate, with what a run costs and how long it takes beside it.

Key Points

  • One run is one sample. The model can take a different path through the same case. Asked to cancel LF-2414, it asked for the cancellation straight away in some runs and looked up the booking first in others. Both paths passed, but a run that passed once can fail the next time. In a chat run of the same request, the model asked for the cancellation again after Amara’s no, and the fifth case’s asks() check fails a run like that.
  • A pass rate is passes out of runs. Five passes out of five runs is a rate of 5/5 for that case. The whole set’s rate is the passes out of all its runs.
  • Runs differ in cost and time, too. A run of the cancel case with the lookup sent one more request and cost about 0.37 cents. A run without it cost about 0.24 cents.
  • runOnce() runs one case once. Last lesson’s body for one case moves into a function that returns whether the run passed, the checks that failed, the answer, the run’s cost in cents worked out from its token usage, and the seconds it took.
  • The loop runs each case RUNS times. Each run writes a ✓ or ✗ with process.stdout.write(), which doesn’t end the line, so one case’s marks share a row.
  • Each row ends with the passes out of five, the average cost and time of one run, and the case’s name. Below the table come the rate for the whole set and the total cost, then each failed run’s failed checks and answer. Every run, passing or not, goes to evals/runs.json.
  • Report cost and time beside each rate. In the recorded run, every case passed five times out of five, for 30 runs out of 30. Three more full runs of the set passed every time too.
  • An average run cost from 0.21 cents for the people on her own booking up to 0.36 cents for the Gull Island times, and the whole eval came to under 9 cents. Your numbers will differ, from run to run and with a different model. When you change the prompt or the model, you’ll weigh these numbers against the rates.
  • Five out of five doesn’t mean a case never fails. If a case failed one run in twenty, five runs would all pass about three times in four, because 0.95 to the power of five is about 0.77. Twenty runs would all pass only about one time in three (0.95 to the power of 20 is about 0.36). Give the cases where a failure would hurt most more runs.

Run each case several times. Report passes out of runs, per case and for the whole set, with cost and time beside each rate.

The Code

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

00:00 Last lesson, you ran your eval set five times and compared the runs by eye. Every case passed each time. Yet in a chat run of a similar request, the model asked for the cancellation again after Amara’s no, so your code asked her a second time.

00:15 The fifth case’s check fails a run like that, and none of those eval runs showed it. The same request can take different paths. In one run of the fifth case, the model asks to cancel straight away.

00:28 In another, it looks up the booking first, and then asks. Both runs passed. Your confirmation step ran once, Amara said no, and nothing changed. One run is one sample.

00:41 Now you’ll build a runner that counts passes over many runs, with cost and time.

00:48 So run the case five times, and keep each verdict. Three runs go straight to the change, and two look up the booking first. Every run gets a tick. Five passes out of five runs is the case’s pass rate.

01:03 The runs differ in cost, too. A run with the lookup sends one more request and costs about 0.37 cents. A run without it costs about 0.24.

01:15 Open the runner, evals/run.js. Last lesson’s body for one case moves into a function, runOnce(), so the loop can call it again. It returns whether the run passed, the checks that failed, and the answer.

01:30 It also returns what the run cost, worked out from its token usage, and the seconds it took. answer() needs a small change for that, in the text below. Then comes the loop.

01:41 For each case, it calls runOnce() RUNS times, here five. Each run writes a tick or a cross with process.stdout.write(). That doesn’t end the line, so one case’s marks share a row.

01:56 It counts the passes and adds up cost and seconds.

02:00 Each row ends with the passes, the average cost and time of one run, and the case’s name. Then come the whole set’s rate and total cost, and each failed run’s checks and answer, so you can tell a wrong answer from a strict check, or from a model request that failed.

02:18 Run the eval from your project’s folder. The marks fill in, row by row, at two to four seconds a run.

02:25 Every case passed five times out of five, so the set passed thirty runs out of thirty. Three more full runs of the set passed every time, too. This time, nothing failed, but that chat run shows it can.

02:39 Beside each rate, an average run cost 0.21 cents for the people on her own booking, up to 0.36 for the Gull Island times. The whole eval came to under 9 cents.

02:51 Your numbers will differ, from run to run and with a different model. When you change the prompt or the model, you’ll weigh these numbers against the rates.

03:00 Five out of five doesn’t mean a case never fails. Say a case failed one run in twenty. Five runs would all pass about three times in four. Twenty runs would all pass only about one time in three.

03:13 Therefore, a pass rate is a measurement. The cases where a failure would hurt most deserve more runs.

03:22 So run each case several times, and report passes out of runs for each case and for the whole set, with cost and time beside them.

03:31 Some must-haves don’t fit a rule, such as whether a refusal is helpful. In the next lesson, Grade Open Answers With a Rubric, you’ll grade answers like those.

Become a Member to join the conversation.