Fix estimate_pass_at_k returning 1.0 when there are no correct samples (#35)#68
Open
LeSingh1 wants to merge 1 commit into
Open
Fix estimate_pass_at_k returning 1.0 when there are no correct samples (#35)#68LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
The estimator's n - c < k shortcut returns 1.0 to represent the case where there are too few incorrect samples to avoid drawing a correct one. That reasoning only holds when at least one correct sample exists. When c == 0 and k > n (so n - c < k), the shortcut wrongly returned 1.0 even though pass@k is exactly 0 with no correct samples. Return 0.0 up front whenever c == 0. For c == 0 with k <= n the estimator formula already evaluated to 0.0, so behavior is unchanged there and for all c > 0 cases; only the previously incorrect k > n branch changes. Adds a unittest-based regression test for estimate_pass_at_k. Fixes openai#35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
estimate_pass_at_kreturns1.0for a problem that has no correct samples whenkexceeds the number of samples. That is wrong: with zero correct samples, pass@k is exactly0for anyk.The estimator uses a shortcut:
The
n - c < kbranch encodes "there are too few incorrect samples to avoid drawing a correct one, so a correct sample is guaranteed." That reasoning only holds when at least one correct sample exists (c > 0). Whenc == 0andk > n(son - c = n < k), the branch is taken and returns1.0, even though there is nothing correct to draw.This was reported in #35.
evaluate_functional_correctnessguards its own calls with(total >= k).all()(son >= k), which is why the main pipeline never hits this branch. Butestimate_pass_at_kis a public, widely-imported helper, and downstream callers that compute pass@k withk > nget an incorrect1.0for unsolved problems.Fix
Return
0.0up front wheneverc == 0:For
c == 0withk <= nthe estimator formula already evaluated to0.0(thenp.arange(n + 1, n + 1)product is empty →1.0, giving1 - 1 = 0), so behavior is unchanged there and for everyc > 0case. Only the previously incorrectc == 0, k > nbranch changes.Verification
Added
human_eval/test_evaluation.py(stdlibunittest, no new dependencies) covering the regression plus the all-correct, guaranteed-pass, known-value (pass@1 == 0.5for 3/6), and scalar-num_samplescases. All pass:Before the fix
estimate_pass_at_k([2], [0], 5)returned[1.0]; after, it returns[0.0].The README sanity check is unchanged:
evaluate_functional_correctnesson the bundled example samples still yieldspass@1: 0.4999999999999999.Fixes #35