Skip to content

fix: compare dedup: against all kept rows, not just the last one - #202

Closed
SmilyOrg wants to merge 1 commit into
mainfrom
dedup-all-kept-rows
Closed

SmilyOrg wants to merge 1 commit into
mainfrom
dedup-all-kept-rows

Conversation

@SmilyOrg

Copy link
Copy Markdown
Owner

Summary

dedup: only suppressed a row when it was similar to the immediately previously kept row, so two near-duplicates separated by an unrelated photo both survived — contradicting the documented guarantee to keep only photos less than the threshold similar to each other. Track the embeddings of every kept row and suppress any row similar to any of them.

Split out of #201 (search date matching / limit-after-scoring), which this commit is cherry-picked from — that PR now reverts this change. Merge #201 first to keep the diff clean; the two are otherwise independent.

Cost

O(n²) cosine comparisons in Go over kept rows — acceptable at current collection sizes; noted for future optimization.

Test plan

  • New dedup_search_test.go: non-adjacent near-duplicates with synthetic CLIP embeddings — the duplicate after an unrelated photo is now suppressed.
  • Verified standalone on main (this branch): TestListDeduplicateSuppressesNonAdjacentNearDuplicates passes.

Related

dedup: only suppressed a row when it was similar to the immediately
previously kept row, so two near-duplicates separated by an unrelated
photo both survived — contradicting the documented guarantee to keep
only photos less than the threshold similar to each other. Track the
embeddings of every kept row and suppress any row similar to any of
them. Covered by dedup_search_test.go (non-adjacent near-duplicates,
synthetic CLIP embeddings).
@SmilyOrg

Copy link
Copy Markdown
Owner Author

I don't think this is the best way to go with O^2, so might reopen later

@SmilyOrg SmilyOrg closed this Oct 11, 2026
SmilyOrg added a commit that referenced this pull request Oct 11, 2026
Moved out of this PR for independent review; the fix lands via
dedup-all-kept-rows (cherry-pick of 2a6aa37). Merge #201 first to
keep that PR's diff clean.

embeddingBytes moves into similarity_search_test.go — a7068aa's
similarity tests use the helper that lived in dedup_search_test.go.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant