Add option to repeat queries in ground truth#14
Open
mihaic wants to merge 1 commit intoIntelLabs:mainfrom
Open
Add option to repeat queries in ground truth#14mihaic wants to merge 1 commit intoIntelLabs:mainfrom
mihaic wants to merge 1 commit intoIntelLabs:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces an option to repeat query vectors when generating ground truth, updating both the CLI and associated test suites to support this new functionality.
- Added new tests in test_generate_ground_truth.py for scenarios with shuffling and repeated queries.
- Updated conftest.py with new constants and modified query file generation.
- Enhanced generate_ground_truth in src/svsbench/generate_ground_truth.py to handle repeated queries via the new num_query_vectors parameter.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/test_generate_ground_truth.py | New tests covering no-shuffle, shuffle, and repeated query scenarios. |
| tests/conftest.py | Added constants and updated query path generation. |
| src/svsbench/generate_ground_truth.py | Added new parameters and logic to optionally repeat queries. |
Comment on lines
+117
to
+126
| cursor = 0 | ||
| while cursor < num_query_vectors: | ||
| permutation = rng.permutation(len(queries)) | ||
| batch_size = min(num_query_vectors - cursor, len(queries)) | ||
| queries_all[cursor : cursor + batch_size] = queries[ | ||
| permutation[:batch_size] | ||
| ] | ||
| ground_truth_all[cursor : cursor + batch_size] = idxs[ | ||
| permutation[:batch_size] | ||
| ] |
There was a problem hiding this comment.
Consider adding inline comments within the while-loop block that repeats queries to clarify its logic and purpose, which can help future readers understand the batch-based repetition process.
Suggested change
| cursor = 0 | |
| while cursor < num_query_vectors: | |
| permutation = rng.permutation(len(queries)) | |
| batch_size = min(num_query_vectors - cursor, len(queries)) | |
| queries_all[cursor : cursor + batch_size] = queries[ | |
| permutation[:batch_size] | |
| ] | |
| ground_truth_all[cursor : cursor + batch_size] = idxs[ | |
| permutation[:batch_size] | |
| ] | |
| cursor = 0 | |
| # Repeat the process until we have generated the required number of query vectors. | |
| while cursor < num_query_vectors: | |
| # Generate a random permutation of the query indices to shuffle the queries. | |
| permutation = rng.permutation(len(queries)) | |
| # Determine the size of the current batch, ensuring we don't exceed the total required. | |
| batch_size = min(num_query_vectors - cursor, len(queries)) | |
| # Select a batch of queries based on the permutation and add them to the output array. | |
| queries_all[cursor : cursor + batch_size] = queries[ | |
| permutation[:batch_size] | |
| ] | |
| # Select the corresponding ground truth indices for the batch and add them to the output array. | |
| ground_truth_all[cursor : cursor + batch_size] = idxs[ | |
| permutation[:batch_size] | |
| ] | |
| # Update the cursor to reflect the number of queries processed so far. |
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.
No description provided.