TL;DR
Pass@k is the probability that at least one of answers drawn from a language model solves the problem. It is measured by letting the model answer the same problem several times, checking each answer, and asking whether any of the first passed. Two models with the same single-try score can differ a lot once several tries are allowed, so pass@k shows how much a model's answers improve by trying more often.
Builds on: Bernoulli Distribution, Counting Principles, Autoregressive Model · Leads to: Best-of-N Sampling, verifier-based selection
Where it's used
Code generation benchmarks. A model is given a function description and a set of unit tests. It writes a program, the tests run, and the program either passes or fails. Reports on code models give pass@1, pass@10 and pass@100, because a model that writes many different programs may solve a problem on the tenth try even when its first try fails. The benchmark turns each problem into a yes-or-no trial, which is exactly the setting of a Bernoulli trial.
Maths with an answer checker. A problem with a unique numerical answer can be graded automatically. Sampling the model many times and checking whether any answer matches shows how often the right answer is reachable at all, even if the model's first guess is usually wrong. This is useful evidence when deciding whether a verifier could pick the good answer out of a pool.
Sampling budgets in products. A team deciding how many candidate answers to generate per user request needs to know how quickly the chance of a good answer grows with the number of samples. Pass@k gives that curve for a fixed task, so the team can weigh the extra compute against the extra successes.
How it works
Suppose a model answers a single problem, and each answer is correct with the same chance , independently of the others. Take the simplest case, a single answer.
- Ask for one answer. It is correct with probability . So pass@1 is .
- Ask for two answers, independently. The first is wrong with probability , and the second is wrong with probability . Both are wrong with probability .
- The check is the complement: at least one is correct with probability . So pass@2 is .
- Ask for three answers. All three are wrong with probability . So pass@3 is .
- Read the pattern. Each extra sample halves the chance that every answer so far has failed, and the gain shrinks each time: from to is a gain of , and from to is a gain of .
The same rule applies to any single-answer chance . The chance that all answers fail is , so pass@k is .
The graph below shows the curve for two values of .
- p = 0.5
- p = 0.1
In practice is not known. It is estimated from samples on the same problem, and the counting argument in the math section turns those samples into an estimate of pass@k for every up to . The whole pipeline runs like this:
flowchart LR P[problem] --> S[draw n samples] S --> G[check each sample] G --> C[count the c correct ones] C --> E[estimate pass@k for every k up to n]
The math
A problem has a true per-sample success chance . We draw samples. The event "pass@k" is that at least one sample is correct. Its probability is
under the assumption that the samples are independent and identically distributed. The on the right is the chance of everything, and is the chance that every sample fails.
For a problem with per-sample success chance , pass@k is the probability that at least one of independent samples passes the check. Under independent sampling, it equals .
Step 1 in symbols
For and : .
Step 2 in symbols
For : . The term is the chance that both answers fail, using the independence to multiply the two chances.
Step 4 in symbols
For : .
Estimating from n samples
The formula needs , which we do not know. Suppose we draw samples on the problem and find that of them pass. The simplest estimate of is , and plugging it in gives . That estimate is biased, because it treats the sample fraction as if it were exactly.
There is a cleaner estimator that does not need at all. Think of drawing of the samples without replacement, where each set of samples is equally likely. The sets with no correct sample are the sets drawn entirely from the failures. The number of such sets is , and the total number of sets is . So the chance that none of the is correct is , and the estimator is
where is the number of ways to choose items from , read "m choose k". This needs . When it reduces to , the fraction of correct samples, which is what you would expect.
Worked examples
A model answers a problem correctly with chance on each independent try. Find pass@2.
- Chance that the first answer fails: .
- Chance that the second answer also fails: .
- Chance that both fail, using independence: .
- Chance that at least one passes: .
Interpretation: a model that gets a problem right half the time has a three-in-four chance of getting it right in one of two tries.
A model is asked the same problem times, and of the answers pass. Estimate pass@1, pass@2 and pass@5.
- For : and . So the estimate is , which is the fraction .
- For : and . So the estimate is .
- For : and . So the estimate is .
- The estimates rise with , as they must, since a larger set of tries can only do as well as a smaller one.
Interpretation: three correct answers out of ten gives a 30 percent single-try rate, but five tries reach about 92 percent under this estimate. The jump is large because five tries from ten samples almost always include one of the three correct answers. Only 1 in 12 of the five-sample sets misses all three.
On a code benchmark, a model writes solutions to one problem. Two of them pass the tests, so . Estimate pass@1 and pass@5.
- For , the estimate is .
- For , the estimate is .
- Simplify the ratio without computing the large binomial coefficients. With , the ratio equals . For and , this is .
- So the estimate is .
- Compare: a single try gives about 10 percent, and five tries give about 45 percent.
Interpretation: the benchmark result is only as good as the samples behind it. With twenty samples the estimate has real variance, so a careful report gives the number of samples as well as the value.
Try it: the same problem with and , but now with tries. Find the estimate. Answer: the ratio is , so the estimate is .
Common mistakes and tradeoffs
Pass@k is not the fraction of samples that pass. It is tempting to read pass@10 as "the model gets it right 10 percent of the time". In fact pass@k is a probability about at least one success among tries, and only pass@1 equals the sample fraction. A model with pass@1 of can have pass@10 near , as the Try it after the realistic example shows.
Pass@k assumes you can pick the right answer. It is tempting to think pass@100 is what a user gets. In fact pass@k counts a problem as solved if any of the samples passes, which assumes an oracle picks it. A deployed system does not have that oracle. It has to choose one answer, and that choice is the job of a best-of-N scorer or a verifier. If the scorer is weak, the real result sits well below pass@k.
The independence assumption can fail. It is tempting to plug into and trust the curve. In fact samples from one model on one prompt are often correlated: if the model has a systematic blind spot, every sample shares it. Then the true chance of at least one success rises more slowly than the formula says. The counting estimator avoids assuming a value for , but it still assumes that the samples are drawn the same way as the samples in use.
Small means noisy estimates. It is tempting to compare two models on pass@10 from a run of twelve samples per problem. The estimate is noisy, and a difference of a few points may be chance. Use enough samples per problem, and report the number of samples.
When to use it. Use pass@k to measure how much coverage a model has across tries, especially when a checker can grade answers automatically. Do not use it as the single number for a product that serves one answer per user. Alternatives are pass@1 for a single-answer setting and the score of the selected answer for a deployed system.
History
Repeated sampling for code had been used informally for years, but the modern standard form of the measure became common after a 2021 paper on code models by Chen and colleagues, which defined pass@k on a benchmark of programming problems and gave the unbiased counting estimator used above. The paper showed that a model's score depended strongly on how many samples were allowed, and that single-sample scores could understate what a model could do.
The idea caught on because it turns a generative model into a yes-or-no trial on each problem, where the tools of probability already apply. It also made clear a tension that stayed open: more samples raise coverage, but a real system must still pick one answer, so the value of pass@k depends on the quality of the selection step.
Recap
- A single sample is a Bernoulli trial with success chance , if we treat the samples as independent.
- Pass@k is the chance that at least one of samples passes, which equals under independence.
- Each extra sample halves the chance of total failure in the example and gives a smaller gain than the one before it.
- From samples with correct, the unbiased estimator is , built from counting.
- Pass@k assumes an oracle picks the best answer, so it is an upper bound on what a deployed system achieves unless a selection step is good.
Next, read about Best-of-N Sampling to see how a scorer tries to pick the good answer from a pool, and about Solution Verifier for checkers that grade answers. For the counting that underlies the estimator, see Binomial Distribution.
Check yourself
QuestionA model's single-sample chance of success on a task is , and samples are independent. What is pass@3?Show answer
Pass@3 . The chance that all three fail is , so the chance of at least one success is .
QuestionFrom samples with correct, compute the estimator for .Show answer
Compute and . The estimate is .
QuestionWhy does the counting estimator for pass@k use combinations rather than the simpler expression ?Show answer
The simpler expression treats the sample fraction as if it were the true per-sample chance, which introduces bias. The combination form counts the sets of samples drawn without replacement from the actually observed. Among these, the sets with no correct sample are the sets drawn entirely from the failures, so the ratio of counts gives the chance of failure directly, with no need to estimate first.
QuestionA team reports that its model reaches pass@100 of 0.9 on a benchmark, and it ships a product that returns one answer per request. Explain why this report could mislead a customer.Show answer
Pass@100 says a correct answer exists among 100 samples in 90 percent of problems, but it assumes the best of the 100 is picked for free. The product returns one answer, so its real success rate depends on how well the system chooses or whether the first sample is right. The number that describes the shipped product is pass@1, or the score of the answer the selection step returns.