Answers.Body: <p>Very late to this question, but pass@k doesn't behave like you're describing because each single pass@k sample is itself a union of k independent events, so averaging them doesn't behave like a union of (num samples) independent events.</p>
  <p>Here's an illustration. Say our dataset is two samples, such that on sample 1 our model always gets it right, and on sample 2 our model never gets it right. Then pass@1 = 50%. But doing 100 passes on each sample, we get 100 correct answers on sample 1 (counts as correct) and 0 correct answers on sample 2 (counts as incorrect). Then pass@100 = 50%. In fact pass@k = 50% for any k in this toy setting.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-10T19:01:48.987Z
Answers.LastActivityDate: 2023-05-10T19:01:48.987Z
Answers.UserDisplayName: Brian Huang
Body: <p><strong>pass@k</strong> is a metric used to evaluate models that generate code, used for example to evaluate <a href="https://arxiv.org/abs/2107.03374" rel="nofollow noreferrer">Codex</a>. To evaluate pass@k, you have a dataset of natural language/code pairs, and you pass each NL prompt to the model. For each prompt, it generates <em>k</em> code snippets. If at least one of the code snippets is correct, then the model succeeded at that prompt in <em>k</em> samples. The pass@k is the fraction of prompts for which the model succeeded in this sense.</p>
  <p>The samples generated for each prompt are obtained via some stochastic procedure based on the model's output probability distributions on the vocabulary, like randomly choosing the next token based on that distribution or something like that.</p>
  <p>So in the Codex paper for example, we see these figures for the largest Codex model:</p>
  <ul>
  <li>pass@1: 28%</li>
  <li>pass@100: 72%</li>
  </ul>
  <p><strong>These numbers make no sense to me.</strong> Every time we sample the model's prediction for a given prompt, we get back a random code snippet. That output is either correct or incorrect. Each trial is independent. So if the probability of one output being correct is <em>p</em>, the probability of at least one of 100 being correct should be <em>1 - (1 - p)^100</em>. Here <em>p=0.28</em>, so the pass@100 should be like 99.999999%.</p>
  <p>Are the trials not independent? What's going on?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-11T09:02:47.680Z
Comments.Text: You can use mathjax on this site.
Comments.UserDisplayName: nbro
Tags: <transformer><metric>
Title: Why does the pass@k metric not "behave like" probability?
UserDisplayName: Jack M
ThreadText: # Why does the pass@k metric not "behave like" probability?
  
  (Asked by: username_0 on 2023-03-07)
  
  **pass@k** is a metric used to evaluate models that generate code, used for example to evaluate [Codex](https://arxiv.org/abs/2107.03374). To evaluate pass@k, you have a dataset of natural language/code pairs, and you pass each NL prompt to the model. For each prompt, it generates *k* code snippets. If at least one of the code snippets is correct, then the model succeeded at that prompt in *k* samples. The pass@k is the fraction of prompts for which the model succeeded in this sense.
  
  The samples generated for each prompt are obtained via some stochastic procedure based on the model's output probability distributions on the vocabulary, like randomly choosing the next token based on that distribution or something like that.
  
  So in the Codex paper for example, we see these figures for the largest Codex model:
  
  * pass@1: 28%
  * pass@100: 72%
  
  **These numbers make no sense to me.** Every time we sample the model's prediction for a given prompt, we get back a random code snippet. That output is either correct or incorrect. Each trial is independent. So if the probability of one output being correct is *p*, the probability of at least one of 100 being correct should be *1 - (1 - p)^100*. Here *p=0.28*, so the pass@100 should be like 99.999999%.
  
  Are the trials not independent? What's going on?
  
  **Tags:** transformer, metric
  > **Comments:**
  > **username_1**: You can use mathjax on this site.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2023-05-10. Score: 1 | Accepted answer
  
  Very late to this question, but pass@k doesn't behave like you're describing because each single pass@k sample is itself a union of k independent events, so averaging them doesn't behave like a union of (num samples) independent events.
  
  Here's an illustration. Say our dataset is two samples, such that on sample 1 our model always gets it right, and on sample 2 our model never gets it right. Then pass@1 = 50%. But doing 100 passes on each sample, we get 100 correct answers on sample 1 (counts as correct) and 0 correct answers on sample 2 (counts as incorrect). Then pass@100 = 50%. In fact pass@k = 50% for any k in this toy setting.
  
  
  ---
  
  