Repository navigation
Conversation
has_answer treated a reference that normalizes to zero tokens (empty string, an article, punctuation only) as a match for any passage. Skip such references before the token search.
Contributor
[Low impact] The PR appears safe to merge. SummaryFixes false passage matches caused by answers that normalize to no tokens.
No actionable issues found. Review was based on source inspection; tests were not run. Reviews (2) · Last reviewed commit: "fix(dspy): ignore empty normalized answe..." · Reviewed by Greptile |
This branch has not been deployed
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.
answer_passage_matchreturnsTruefor any passage when one of the reference answers normalizes to nothing (empty string, "the", "A", punctuation only).has_answerindsp/utils/dpr.pycompares the empty token list with a zero-length slice of the passage, and that always matches. This PR skips references with zero tokens. If every reference is empty the result isFalse. A real reference after an empty one still matches.Added a parametrized test in
tests/evaluate/test_metrics.py(empty string, articles, punctuation, all empty, empty followed by a real match).tests/evaluatepasses locally with--extra, 61 passed.This is not covered by #10783 (empty answer list) or #10913 (non-string values). The example above still returns
Trueon the #10783 branch.One thing I ran into: on a fresh checkout the ty pre-commit hook fails before it starts, because
uv.lockhas dspy 3.4.1 andpyproject.tomlsays 3.5.0. Not related to this change.AI use: Claude and Codex did most of the work, the patch and the test, and drafted this text.