4.4.16 · D2Alignment, Prompting & RAG

Visual walkthrough — Evaluation of LLMs (benchmarks, LLM-as-judge)

2,022 words9 min readBack to topic

Everything below rests on one idea from the parent note: a benchmark runs the code and checks if it passes hidden tests. So each attempt is either a ✅ (passes all tests) or a ❌ (fails at least one). Nothing in between. Hold onto that.


Step 1 — One attempt is a biased coin

WHAT. Picture the model making a single attempt at one problem. The outcome is binary: ✅ pass or ❌ fail. We invent a number for "how often the ✅ side comes up."

WHY a probability at all? Because the model is random — same prompt, different sampled words each time (temperature > 0). We cannot predict one attempt, but we can talk about how often ✅ shows up. That "how often" is exactly what names.

PICTURE. A coin painted green on one face (✅, area ) and red on the other (❌, area ). The green fraction is .

Figure — Evaluation of LLMs (benchmarks, LLM-as-judge)

Step 2 — Failing all tries is the easy thing to count

WHAT. We want . Counting "at least one" is annoying — it could be 1, or 2, ... up to successes, and we'd have to add all those cases. So we flip the question and count the one way things go completely wrong: every attempt is ❌.

WHY subtraction is legal. For any event , Here = " success", so "not " = "all failed". Term by term:

  • — total probability of all outcomes (something must happen).
  • — the single slice we subtract off.

PICTURE. The whole probability bar is length . We shade the small "all-fail" chunk in red; whatever's left (blue) is our answer.

Figure — Evaluation of LLMs (benchmarks, LLM-as-judge)

Step 3 — Independent tries multiply

WHAT. Each attempt fails with probability (the red face). If the tries don't influence each other, the chance that attempt 1 fails and 2 fails and ... and fails is the product of copies of .

WHY multiply and not add? "AND across independent events" is multiplication — think of a tree. Each try branches into ✅ or ❌; walking the all-red path means multiplying the red probability at every branch:

  • — probability one attempt lands ❌.
  • exponent — how many attempts, each an independent ❌.

PICTURE. A branching tree, levels deep. The single all-red path down the left is highlighted; its length shrinks as grows.

Figure — Evaluation of LLMs (benchmarks, LLM-as-judge)

Plugging Step 3 into Step 2:

  • — everything went wrong.
  • — so something went right.

Step 4 — We don't know , so we estimate it

WHAT. The formula needs , but is the true pass rate we can never see. All we have is data: over real problems, we watched how often the model succeeded. We replace by the observed success fraction .

WHY the raw fraction? It is the maximum-likelihood estimate: among all values of , the observed count was most probable precisely when . In plain words — the guess that makes what you actually saw the least surprising. If 30 of 100 tries passed, betting is the least-surprised bet.

PICTURE. A jar of 100 marbles, 30 green; you scoop them and estimate "green-ness" .

Figure — Evaluation of LLMs (benchmarks, LLM-as-judge)

Now the usable formula from the parent note appears:


Step 5 — Every case: what Pass@k does at the extremes

WHAT. A formula you trust is one you've watched at its boundaries. Read across all inputs.

Input Meaning Pass@k
model never solves it
model always solves it
one attempt only
infinite retries, any

WHY each makes sense.

  • : no green face exists → all tries fail no matter how many → . ✅
  • : first try already wins → . ✅
  • : Pass@k is just ; the whole machinery reduces to one coin flip. ✅
  • : as long as some green exists (), keep flipping and you're guaranteed to hit it eventually → . This is why bigger always flatters a model. ✅

PICTURE. Curves of Pass@k versus , one curve per . All pass through and ; higher bows harder toward the top-left.

Figure — Evaluation of LLMs (benchmarks, LLM-as-judge)

Step 6 — The honest estimator (sampling without replacement)

WHAT. In real HumanEval you don't flip infinitely. You draw a fixed pool of samples per problem, count how many pass (), then ask: if I'd picked of these , what's the chance all were failures? Since you're picking from a finite pool without putting them back, the naive is slightly biased. The parent note's boxed formula fixes this with counting, not multiplication.

WHY combinations here instead of a power? When you remove a failed sample and can't draw it again, the odds shift each pick — so you can't just multiply one fixed . Counting arrangements handles the shifting odds exactly. (If the pool were infinite, and Step 3's formula returns.)

PICTURE. A row of cards, green and red. We fan out one hand of cards drawn without replacement; the "all-red hand" is the failure event we're counting.

Figure — Evaluation of LLMs (benchmarks, LLM-as-judge)

The one-picture summary

Figure — Evaluation of LLMs (benchmarks, LLM-as-judge)

The whole story on one canvas: a coin () → the all-fail red slice () → subtract from → estimate from data → the rising family of curves → the finite-pool correction.

Recall Feynman retelling — say it like you'd explain to a friend

The model is a slightly unreliable machine. On any single try it succeeds a fraction of the time — that's our green coin. We give it shots and only care whether any shot lands. Counting "any" is hard, so we count the opposite: the one way it's a total flop is every shot missing, which (if shots don't affect each other) is multiplied by itself times, i.e. . Whatever's left over, , is the chance of at least one win — that's Pass@k. We never actually know , so we just use the fraction of problems it solved, . Sanity checks: a hopeless model () scores no matter how many tries; a perfect one scores ; one try makes the whole thing collapse to plain ; and infinite tries push any nonzero model to — which is exactly why you must compare models at the same . Finally, since a real benchmark draws from a finite bag of samples you can't redraw, we swap the "multiply" for a "count the hands" formula with combinations, and that removes the small bias.

Recall

What does mean in one sentence? ::: The true fraction of single attempts that pass all tests for a problem. Why do we compute instead of adding up success cases? ::: "At least one success" and "all fail" are complementary, so it's easier to compute the single all-fail case and subtract from 1. Why is raised to the power ? ::: The attempts are independent, and "all fail" means every one fails — independent ANDs multiply. What is and why that value? ::: The maximum-likelihood estimate of the pass rate — the guess that makes the observed data least surprising. What happens to Pass@k as for any ? ::: It approaches 1 — with enough retries any nonzero-chance model eventually succeeds. Why does HumanEval use the combinatorial form? ::: Samples are drawn from a finite pool without replacement, so a fixed- power is biased; counting arrangements is exact.

See also: Prompt Engineering Best Practices · Few-Shot Learning · RAG (Retrieval-Augmented Generation) · RLHF (Reinforcement Learning from Human Feedback)