Search

Search papers and lessons

Pass@k

Level 3 · 12 min read

Pass@k is the chance that at least one of k sampled answers from a model is correct, and it can be estimated from n samples with a counting formula.

On this page

  • Colour = topic mix
  • Probability
  • Discrete math
  • Calculus
  • Losses & regularization
  • Neural network basics
  • Post-training
  • ReadReady to readNot yet

TL;DR

Pass@k is the probability that at least one of kk 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 kk 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 p=0.5p = 0.5, independently of the others. Take the simplest case, a single answer.

  1. Ask for one answer. It is correct with probability 0.50.5. So pass@1 is 0.50.5.
  2. Ask for two answers, independently. The first is wrong with probability 0.50.5, and the second is wrong with probability 0.50.5. Both are wrong with probability 0.5×0.5=0.250.5 \times 0.5 = 0.25.
  3. The check is the complement: at least one is correct with probability 1−0.25=0.751 - 0.25 = 0.75. So pass@2 is 0.750.75.
  4. Ask for three answers. All three are wrong with probability 0.5×0.5×0.5=0.1250.5 \times 0.5 \times 0.5 = 0.125. So pass@3 is 1−0.125=0.8751 - 0.125 = 0.875.
  5. Read the pattern. Each extra sample halves the chance that every answer so far has failed, and the gain shrinks each time: from 0.50.5 to 0.750.75 is a gain of 0.250.25, and from 0.750.75 to 0.8750.875 is a gain of 0.1250.125.

The same rule applies to any single-answer chance pp. The chance that all kk answers fail is (1−p)k(1 - p)^k, so pass@k is 1−(1−p)k1 - (1 - p)^k.

The graph below shows the curve for two values of pp.

24681000.20.40.60.81k (number of samples)pass@k
  • p = 0.5
  • p = 0.1
The curve rises fast at first and then flattens. A model that is right 10 percent of the time gets to about 41 percent at k = 5 under the independence assumption.

In practice pp is not known. It is estimated from nn samples on the same problem, and the counting argument in the math section turns those nn samples into an estimate of pass@k for every kk up to nn. 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 pp. We draw kk samples. The event "pass@k" is that at least one sample is correct. Its probability is

pass@k=1−(1−p)k,\text{pass@}k = 1 - (1 - p)^k,

under the assumption that the kk samples are independent and identically distributed. The 11 on the right is the chance of everything, and (1−p)k(1 - p)^k is the chance that every sample fails.

Definition: Pass@k

For a problem with per-sample success chance pp, pass@k is the probability that at least one of kk independent samples passes the check. Under independent sampling, it equals 1−(1−p)k1 - (1 - p)^k.

Step 1 in symbols

For p=0.5p = 0.5 and k=1k = 1: 1−(1−0.5)1=1−0.5=0.51 - (1 - 0.5)^1 = 1 - 0.5 = 0.5.

Step 2 in symbols

For k=2k = 2: 1−(0.5)2=1−0.25=0.751 - (0.5)^2 = 1 - 0.25 = 0.75. The term (0.5)2(0.5)^2 is the chance that both answers fail, using the independence to multiply the two chances.

Step 4 in symbols

For k=3k = 3: 1−(0.5)3=1−0.125=0.8751 - (0.5)^3 = 1 - 0.125 = 0.875.

Estimating from n samples

The formula needs pp, which we do not know. Suppose we draw nn samples on the problem and find that cc of them pass. The simplest estimate of pp is c/nc / n, and plugging it in gives 1−(1−c/n)k1 - (1 - c/n)^k. That estimate is biased, because it treats the sample fraction as if it were pp exactly.

There is a cleaner estimator that does not need pp at all. Think of drawing kk of the nn samples without replacement, where each set of kk samples is equally likely. The sets with no correct sample are the sets drawn entirely from the n−cn - c failures. The number of such sets is (n−ck)\binom{n-c}{k}, and the total number of sets is (nk)\binom{n}{k}. So the chance that none of the kk is correct is (n−ck)/(nk)\binom{n-c}{k} / \binom{n}{k}, and the estimator is

pass@k^=1−(n−ck)(nk),\widehat{\text{pass@}k} = 1 - \frac{\binom{n-c}{k}}{\binom{n}{k}},

where (mk)\binom{m}{k} is the number of ways to choose kk items from mm, read "m choose k". This needs n≥kn \geq k. When k=1k = 1 it reduces to 1−(n−c)/n=c/n1 - (n-c)/n = c/n, the fraction of correct samples, which is what you would expect.

Worked examples

Example
1. Two answers from a coin-like model

A model answers a problem correctly with chance p=0.5p = 0.5 on each independent try. Find pass@2.

  1. Chance that the first answer fails: 1−0.5=0.51 - 0.5 = 0.5.
  2. Chance that the second answer also fails: 0.50.5.
  3. Chance that both fail, using independence: 0.5×0.5=0.250.5 \times 0.5 = 0.25.
  4. Chance that at least one passes: 1−0.25=0.751 - 0.25 = 0.75.

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.

Example
2. The estimator on ten samples

A model is asked the same problem n=10n = 10 times, and c=3c = 3 of the answers pass. Estimate pass@1, pass@2 and pass@5.

  1. For k=1k = 1: (n−c1)=(71)=7\binom{n-c}{1} = \binom{7}{1} = 7 and (101)=10\binom{10}{1} = 10. So the estimate is 1−7/10=0.31 - 7/10 = 0.3, which is the fraction c/nc/n.
  2. For k=2k = 2: (72)=21\binom{7}{2} = 21 and (102)=45\binom{10}{2} = 45. So the estimate is 1−21/45=24/45=8/15≈0.5331 - 21/45 = 24/45 = 8/15 \approx 0.533.
  3. For k=5k = 5: (75)=21\binom{7}{5} = 21 and (105)=252\binom{10}{5} = 252. So the estimate is 1−21/252=1−1/12=11/12≈0.9171 - 21/252 = 1 - 1/12 = 11/12 \approx 0.917.
  4. The estimates rise with kk, 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.

Example
3. A realistic benchmark with twenty samples

On a code benchmark, a model writes n=20n = 20 solutions to one problem. Two of them pass the tests, so c=2c = 2. Estimate pass@1 and pass@5.

  1. For k=1k = 1, the estimate is c/n=2/20=0.1c/n = 2/20 = 0.1.
  2. For k=5k = 5, the estimate is 1−(185)/(205)1 - \binom{18}{5}/\binom{20}{5}.
  3. Simplify the ratio without computing the large binomial coefficients. With c=2c = 2, the ratio equals (n−k)(n−k−1)n(n−1)\frac{(n-k)(n-k-1)}{n(n-1)}. For n=20n = 20 and k=5k = 5, this is 15×1420×19=210380=2138\frac{15 \times 14}{20 \times 19} = \frac{210}{380} = \frac{21}{38}.
  4. So the estimate is 1−2138=1738≈0.4471 - \frac{21}{38} = \frac{17}{38} \approx 0.447.
  5. 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 n=20n = 20 and c=2c = 2, but now with k=10k = 10 tries. Find the estimate. Answer: the ratio is (n−k)(n−k−1)n(n−1)=10×920×19=90380=938\frac{(n-k)(n-k-1)}{n(n-1)} = \frac{10 \times 9}{20 \times 19} = \frac{90}{380} = \frac{9}{38}, so the estimate is 1−938=2938≈0.7631 - \frac{9}{38} = \frac{29}{38} \approx 0.763.

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 kk tries, and only pass@1 equals the sample fraction. A model with pass@1 of 0.10.1 can have pass@10 near 0.760.76, 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 kk 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 pp into 1−(1−p)k1 - (1-p)^k 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 pp, but it still assumes that the nn samples are drawn the same way as the kk samples in use.

Small nn 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 pp, if we treat the samples as independent.
  • Pass@k is the chance that at least one of kk samples passes, which equals 1−(1−p)k1 - (1 - p)^k 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 nn samples with cc correct, the unbiased estimator is 1−(n−ck)/(nk)1 - \binom{n-c}{k} / \binom{n}{k}, 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 p=0.2p = 0.2, and samples are independent. What is pass@3?Show answer

Pass@3 =1−(1−0.2)3=1−0.83=1−0.512=0.488= 1 - (1 - 0.2)^3 = 1 - 0.8^3 = 1 - 0.512 = 0.488. The chance that all three fail is 0.5120.512, so the chance of at least one success is 0.4880.488.

QuestionFrom n=10n = 10 samples with c=4c = 4 correct, compute the estimator for k=2k = 2.Show answer

Compute (n−ck)=(62)=15\binom{n-c}{k} = \binom{6}{2} = 15 and (102)=45\binom{10}{2} = 45. The estimate is 1−15/45=1−1/3=2/3≈0.6671 - 15/45 = 1 - 1/3 = 2/3 \approx 0.667.

QuestionWhy does the counting estimator for pass@k use combinations rather than the simpler expression 1−(1−c/n)k1 - (1 - c/n)^k?Show answer

The simpler expression treats the sample fraction c/nc/n as if it were the true per-sample chance, which introduces bias. The combination form counts the sets of kk samples drawn without replacement from the nn actually observed. Among these, the sets with no correct sample are the sets drawn entirely from the n−cn - c failures, so the ratio of counts gives the chance of failure directly, with no need to estimate pp 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.

Sources