Repository navigation
Conversation
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.
Problem
CiderSampleEvaluator(df_mode="corpus")constructs a separate one-document scorer for every row. Each scorer therefore useslog(1)=0for the corpus size, making every TF-IDF weight zero. Two distinct five-word references, each matched exactly by its generated text, receive[0, 0]instead of[10, 10].This makes the corpus mode unable to distinguish matching text from unrelated text.
Change
Build one local CIDEr scorer for all rows of each
eval()call, estimate document frequencies from that input corpus, then return its per-row scores in the original order. The scorer is recreated for each call.The precomputed-IDF path and empty-input behavior remain unchanged. A genuine singleton corpus still has zero IDF; the fix supplies the intended multi-document corpus instead of treating each row as one.
Validation
Added ten CPU cases using the real evaluator and scorer, including:
Original source with the new tests: 7 failed, 3 passed. Fixed source plus related evaluation/deduplication regressions: 28 passed. Independent code review and test reruns passed, as did Ruff lint/format on the new tests and
git diff --check.python -m pytest test/cpu_only/test_cider_sample_evaluator.py test/cpu_only/test_ngram_sample_evaluator.py test/cpu_only/test_dedup_single_input_keys.py test/cpu_only/test_minhash_short_texts.py -qValidated on Windows, Python 3.12.14, NumPy 1.26.4 and pandas 2.2.3. The full model/API test suite was not run.