Knowing If It WorksLesson 32 of 76

Module 4 · The systems you will actually be handed

Code: run it, in a box, against tests it has not seen

In this lesson

  • 9 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 3 of 10 in this chapter

This chapter’s goalDesign a defensible evaluation for a summariser, a translator, a code generator, a structured extractor, a multi-turn assistant, a ranking system, a vision or speech model, a document pipeline or a tabular model, and name the specific failure mode each design exists to catch.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
Grading generated code by running itSample ncompletionsTen per problemis typical.Run each in aboxNo network,memory cap,process cap,read-only mount,hard timeout. Atimeout is afailure, countedseparately.HiddenadversarialtestsEmpty, boundary,large andwrong-typeinputs. A naivestub must failthem.pass@kpass@1 if aperson sees onesuggestion;pass@k if thetool shows k orretries.Free staticchecksLint, importsagainst thelockfile, ascanner, thesize of thediff.With n = 10 samples and 3 passing, pass@1 is 0.30 and pass@5 is 0.92. Both are true; the interfacedecides which one is yours.
With n = 10 samples and 3 passing, pass@1 is 0.30 and pass@5 is 0.92. Both are true; the interface decides which one is yours.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

The rare task with a real oracle

Almost everything else in this course needs a judgement. Code has an oracle: run it and see. Any evaluation of code generation that reads the code instead of executing it is throwing away its main advantage: plausible-looking code that does not run is exactly the failure mode.

pass@k, and which k your product needs

Sample n completions for a problem, count how many pass the tests, and estimate the probability that at least one of k samples works:

Text
pass@k = 1 - C(n - c, k) / C(n, k)

With n = 10 samples of which c = 3 pass:

  • pass@1 = 3/10 = 0.30
  • pass@5 = 1 - C(7,5)/C(10,5) = 1 - 21/252 = 0.92

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Shipping It exam.

Stuck on something?Ask Sayali, your AI tutor

How to cite: Addaly (2026) ‘Code: run it, in a box, against tests it has not seen’, in Knowing If It Works. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/evaluating-ai/evaluating-code-generation (Accessed: 27 November 2026).