Fix duplicate-cluster trigger to require >=2 kept candidates#327
Merged
Conversation
…llow-up) PR #282 added a post-prune diversity step that fires when "all kept neighbors share the same distance". The original guard `!result.empty()` is also satisfied by `result.size() == 1`, because `all_duplicates` stays trivially true when only one candidate has been pushed into `result`. This causes the branch to fire on nodes whose alpha-pruning has collapsed `result` to a single retained neighbor, replacing that sole nearest-neighbor edge with a longer "diversity" edge -- which is unrelated to duplicate clusters. Restrict the trigger to `result.size() >= 2` so it only activates when two or more retained candidates actually share the same distance, matching the intent described in PR #282 / issue #80. Empirical impact (sift-scaled, ws=64, deg=64, pool=32, alpha=1.2, L2): - Pre-#282 baseline: recall = 0.925 - Post-#282 (current behavior): recall = 0.945 (434 triggers, 184 replacements -- all from result.size()==1) - Post-#282 + this fix (result.size() >= 2): recall = 0.925 (0 triggers, 0 replacements -- no real duplicate clusters present) This restores the documented baseline for sift-scaled CI while keeping the genuine duplicate-cluster handling for datasets that actually contain co-located vectors (e.g. issue #80 reproducer).
ethanglaser
approved these changes
May 5, 2026
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.
PR #282 added a post-prune diversity step that fires when "all kept neighbors share the same distance". The original guard
!result.empty()is also satisfied byresult.size() == 1, becauseall_duplicatesstays trivially true when only one candidate has been pushed intoresult. This causes the branch to fire on nodes whose alpha-pruning has collapsedresultto a single retained neighbor, replacing that sole nearest-neighbor edge with a longer "diversity" edge -- which is unrelated to duplicate clusters.Restrict the trigger to
result.size() >= 2so it only activates when two or more retained candidates actually share the same distance, matching the intent described in PR #282 / issue #80.