Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
51 small wins to finish your pathNext question →

Q25IntermediateConcept

How do you evaluate code generation? Explain pass@k.

30-second answerSay your answer out loud first, then reveal.

Metrics

MetricMeaning
pass@1Chance a single sample is correct (most relevant for users)
pass@kChance any of k samples is correct (relevant when you can test and pick)
Compile / lint rateSyntactic and style validity
Test pass rateFraction of tests passed (partial credit)
Security findingsStatic analysis (e.g. injection, hard-coded secrets)
Edit acceptanceReal-world: suggestions accepted and retained
Worked example. n = 10 samples, c = 3 correct.
text
pass@1 = 1 − C(7,1)/C(10,1) = 1 − 7/10 = 0.3
pass@5 = 1 − C(7,5)/C(10,5) = 1 − 21/252 ≈ 0.92

Practical considerations

  • Sandboxing: generated code is untrusted. Isolate execution with no network, resource limits and timeouts.
  • Test quality: weak tests inflate scores; use hidden tests and property-based tests.
  • Contamination: public benchmarks may be in training data, so build internal tasks from your codebase.

Every expert started right here.