-
Notifications
You must be signed in to change notification settings - Fork 2
Add option to repeat queries in ground truth #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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. |
Copilot uses AI. Check for mistakes.
No description provided.