技术指南

Pass@k Metric Explained

Pass@k is the probability that at least one of k sampled attempts from a model solves a problem, usually checked by running hidden unit tests on generated code.

  • 4 分钟阅读
  • 最后更新
在本页4 分钟阅读
  1. 概述
  2. 深入探讨
  3. 战略影响
  4. The Future of Pass@k Metric Explained
  5. 现实世界的实施
  6. 风险与防护栏
  7. 实施路线图
  8. 不断探索
  9. 常见问题

概述

It matters because code and agent benchmarks report it constantly, and a pass@10 or pass@100 score can look far better than what a user gets from a single try.

深入探讨

Pass@k grew out of program synthesis research, where Kulal and colleagues used it in 2019 for pseudocode-to-code tasks, and it became standard with OpenAI's 2021 Codex paper, which introduced HumanEval, a set of 164 hand-written Python programming problems. For each problem the model writes a function, and the function counts as correct only if it passes hidden unit tests. Pass@k asks: if you drew k samples, what is the chance that at least one passes? The benchmark score is that probability averaged over all problems. The naive method is to generate exactly k samples per problem and check whether any pass, but that estimate is very noisy. The Codex paper instead generates n samples, where n is larger than k (for example 200), counts the c correct ones, and computes the probability that a random subset of k samples contains at least one correct sample: 1 minus C(n minus c, k) divided by C(n, k). This estimator is unbiased and far less variable. The shortcut of plugging c/n into 1 minus (1 minus p) to the power k is biased. Sampling temperature matters. Pass@1 is usually best at low temperature, while pass@100 benefits from higher temperature because more diverse samples raise the chance that one works. Papers often pick a different temperature for each k. Agent benchmarks added a complementary metric. The tau-bench paper from Sierra (2024) defined pass^k, the probability that all k independent trials succeed. It measures reliability rather than capability. Common misreadings include comparing one model's pass@10 with another's pass@1, forgetting that pass@k assumes something already knows which sample is correct, and treating greedy-decoding pass@1 as identical to sampled pass@1. Weak unit tests inflate every pass@k number, which is why EvalPlus added many more tests to HumanEval and saw scores drop.

战略影响

成本与预算

多年来,架构决策决定着性能和运营成本。

更清晰的判决

技术教育帮助团队选择正确的堆栈,而不仅仅是最新的堆栈。

质量控制

更好的工程选择可以减少生产中的可靠性事故。

The Future of Pass@k Metric Explained

As models move from single completions to multi-step agents, reliability measures such as pass^k and run-to-run consistency are getting more attention alongside pass@k, because users experience one attempt, not the best of many. Benchmark authors are also investing in stronger test suites, since weak tests let incorrect code pass and inflate every metric. Careful reports should state k, sample count, temperature and whether any selection step was used, but practice varies, so readers should keep checking those details rather than assuming them.

现实世界的实施

A team evaluating a code model on HumanEval samples 200 completions per problem, counts how many pass the tests, and reports pass@1, pass@10 and pass@100 from that one set of samples using the unbiased estimator.

An editor autocomplete that shows one suggestion should be judged by pass@1, while a tool that generates five candidates and runs your test suite to pick a working one is closer to a pass@5 situation.

A customer-support agent that succeeds on 75 percent of trials looks strong on pass@k, but if trials are independent its pass^4 score (all four trials succeed) is only about 0.32, which shows how unreliable it would feel across repeated use.

A competitive programming system generates many candidate programs, filters them against the example tests, and submits a small number; its reported solve rate depends on how many submissions were allowed, which is a pass@k-style budget.

风险与防护栏

  • 优化一项基准测试可以隐藏更广泛的系统弱点。

  • 基础设施和维护成本常常被低估。

  • 随着系统变得更加复杂,安全性和可观察性差距可能会扩大。

实施路线图

  1. 在实施之前定义延迟、质量和成本目标。

  2. 在实际负载和数据条件下进行基准测试。

  3. 仪器监控错误、漂移和用户影响。

  4. 在扩展之前准备回滚和事件响应路径。

不断探索

Free newsletter

Get the daily AI briefing

Three verified AI stories every weekday morning, written in plain English. Free forever, no ads.

One email each weekday. Unsubscribe in one click. We never sell or share your address.

Test yourself

Take the Pass@k Metric Explained quiz

Instant feedback on every answer, and a shareable certificate with a verifiable ID once you pass a course.

开始测验

Support free AI education. AI Understanding is a 501(c)(3) nonprofit — no ads, no paywall, ever. Make a donation

常见问题

What is Pass@k Metric Explained?

Pass@k is the probability that at least one of k sampled attempts from a model solves a problem, usually checked by running hidden unit tests on generated code. It matters because code and agent benchmarks report it constantly, and a pass@10 or pass@100 score can look far better than what a user gets from a single try.

What does pass@k measure for a single problem?

Pass@k is the chance that at least one of k attempts succeeds. The benchmark score averages that probability over all problems.

HumanEval, the benchmark introduced with the Codex paper, contains what?

HumanEval has 164 hand-written Python problems, each checked by hidden unit tests.

Why does the Codex paper generate n samples with n larger than k?

Generating exactly k samples gives a noisy estimate. Using n samples and counting c correct ones allows an unbiased estimate with much less variance.

With n samples and c correct, which expression is the unbiased pass@k estimator?

It is one minus the probability that a random k-subset contains only incorrect samples. C(c, k)/C(n, k) is the pass^k estimator, and the power-k shortcut is biased.

What does pass^k, defined in the tau-bench paper, measure?

Pass^k requires every trial to succeed, so it measures reliability, which matters for agents serving many users.