fix(search): separate channel candidate retrieval limit before fusion… - #146
fix(search): separate channel candidate retrieval limit before fusion…#146ayan-waqas wants to merge 1 commit into
Conversation
|
Hey @ayan-waqas, |
|
@SaadBazaz I have starred the repo , kindly review the PR now. |
tulayha
left a comment
There was a problem hiding this comment.
A couple of small cleanup items for the next revision:
- Please run the formatter across all four changed files; a few stray blank lines were introduced.
- The public commands already reject zero and negative
top_k, so returning those invalid values unchanged givesresolve_candidate_limit()a confusing contract. Please either reject them here or rely on the existing command validation and remove that branch and its tests.
Could you also leave a quick comment on #88 confirming that you’re continuing with this work? That will let me assign the issue to you and keep the issue and PR ownership clear.
| """Determine the internal per-channel retrieval limit for candidate pool before fusion.""" | ||
| if top_k <= 0: | ||
| return top_k | ||
| return min(max(top_k * multiplier, min_candidates), max_candidates) |
There was a problem hiding this comment.
The candidate limit should not be derived from the public top_k. These represent different concerns: top_k is the final result count, while candidate depth is an internal recall and cost budget. A multiplier assumes ranking depth scales consistently across modalities and models, which we have not established and which #76 is intended to measure. Please use an independent, bounded candidate-depth setting for now, ensure it cannot fall below top_k, and treat its value as provisional until the evaluation work gives us evidence for the final default.
| query=step.query, | ||
| media_id=command.media_id, | ||
| top_k=command.top_k, | ||
| top_k=candidate_limit, |
There was a problem hiding this comment.
Could you add a test for this path as well? The issue covers both regular search and video queries, but the new application test only exercises search(). Please confirm that video moment searches receive the expanded candidate limit while the final fused result still respects the requested top_k.
| self.assertEqual(resolve_candidate_limit(0), 0) | ||
| self.assertEqual(resolve_candidate_limit(-1), -1) | ||
|
|
||
| def test_fusion_recovers_top_result_when_candidates_extend_beyond_final_top_k(self): |
There was a problem hiding this comment.
This verifies fusion after the additional candidate has already been supplied, but it does not reproduce the original retrieval problem—the previous fusion code would also pass with these inputs. Could the regression go through application.search() with two modalities so it proves that candidates beyond the public top_k are retrieved, fused, and then trimmed back to the requested result count?
|
Yes , sure! |
98f7a56 to
9dfa734
Compare
…grayhatdevelopers#88) - Introduce resolve_candidate_limit() with independent candidate_depth budget (default 50, max 500) - Add search_candidate_depth setting to VidXPSettings - Update Application.search() and Application.query_video() to use candidate limits for channel queries while returning top_k final fused moments - Add unit tests for candidate depth resolution and non-positive input validation - Add query_video candidate depth verification and application.search regression test for candidates retrieved past public top_k
9dfa734 to
d82bd88
Compare
Related issue
Closes #88
Summary
resolve_candidate_limit(top_k)insrc/vidxp/search_fusion.pyto calculate internal retrieval limits for candidate pools per search channel (bounded between 50 and 500 candidates).VidXPApplication.search()andVidXPApplication.query_video()insrc/vidxp/application.pyto usecandidate_limitwhen fetching channel candidates, while returningcommand.top_kfinal fused moments to callers.top_k) and response schemas without breaking compatibility.Validation
resolve_candidate_limitbounds and candidate expansion intests/test_search_fusion.py:resolve_candidate_limit(3)returns50,resolve_candidate_limit(200)returns500, and0/negative inputs remain un-expanded.top_k=2) is retrieved in candidate pools and wins docs/open source v1 #1 in fused results.Application.searchcandidate limit verification intests/test_application.py:50) for channel search whentop_k=3is requested..venv/bin/pytest tests/test_search_fusion.py tests/test_application.py tests/test_query_service.py: