Fix: scorers crash on empty input (UnboundLocalError / ZeroDivisionError) - #52
Open
jimdawdy-hub wants to merge 1 commit into
Open
Fix: scorers crash on empty input (UnboundLocalError / ZeroDivisionError)#52jimdawdy-hub wants to merge 1 commit into
jimdawdy-hub wants to merge 1 commit into
Conversation
Two scorers raise on an empty `generations` list: - `evaluate_successor_liability` binds `f1` only inside the per-sample loop, so it raises `UnboundLocalError` when there are no generations. - `evaluate_definition_extraction` ends in `correct / total`, raising `ZeroDivisionError` when `total == 0`. An empty list is a normal degenerate case (e.g. a task whose generations all failed to produce, or a zero-length eval slice). Return 0.0 in both instead of throwing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author
Reproduction (captured output)# repro.py
from evaluation import evaluate_successor_liability, evaluate_definition_extraction
for name, fn in [("evaluate_successor_liability", evaluate_successor_liability),
("evaluate_definition_extraction", evaluate_definition_extraction)]:
try:
print(f"{name}([], []) -> {fn([], [])}")
except Exception as e:
print(f"{name}([], []) -> {type(e).__name__}: {e}")BEFORE (upstream AFTER (this branch): |
Author
|
@neelguha Friendly ping on this one as well — another small scorer hardening fix. What it fixes: Two scorers crash on empty
Scope: One commit; returns Relation to #50 / #51: Independent. Useful on its own for robust eval pipelines (failed parses, empty slices, etc.). Let me know if you’d prefer these three successor_liability-related PRs squashed — happy to do that. Thanks! |
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
Two scorers raise on an empty
generationslist instead of returning a score:evaluate_successor_liabilitybindsf1only inside the per-sample loop →UnboundLocalErrorwhengenerations == [].evaluate_definition_extractionends incorrect / total→ZeroDivisionErrorwhentotal == 0.An empty list is a normal degenerate case (a task whose generations all failed to parse, a zero-length slice, etc.).
Fix
Return
0.0in both when there are no generations.