Skip to content
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

Fix average sparse vector recommendation #4047

Merged
merged 5 commits into from
Apr 17, 2024

Conversation

agourlay
Copy link
Member

The recommendation API must sort the sparse vectors before computing the average because the combine_aggregate function requires sorted vectors.

Issue discovered while running the congruence tests locally with debug assertions enabled.

Copy link
Contributor

@IvanPleshkov IvanPleshkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great finding! Thanks for fixing, it was my fault (
I requested changes because PR affects dense vectors case

lib/sparse/src/common/sparse_vector.rs Outdated Show resolved Hide resolved
lib/collection/src/recommendations.rs Outdated Show resolved Hide resolved
@agourlay
Copy link
Member Author

The new approach is all green here but breaks the congruence test.

FAILED tests/congruence_tests/test_sparse_recommend.py::test_simple_recommend - AssertionError: point1[0].id = 151, point2[0].id = 394

I need to investigate 🔍

@agourlay
Copy link
Member Author

agourlay commented Apr 17, 2024

@IvanPleshkov I pushed a new version that does not break the congruence tests.

TBH I could not find the exact issue, so I went with a simpler implementation without in-place mutation for the result in the argument.

@IvanPleshkov
Copy link
Contributor

@IvanPleshkov I pushed a new version that does not break the congruence tests.

TBH I could not find the exact issue, so I went with a simpler implementation without in-place mutation for the result in the argument.

okay, approve. the easiest way to fix

@agourlay agourlay merged commit c6e7c6f into dev Apr 17, 2024
17 checks passed
@agourlay agourlay deleted the fix-sparse-vector-average-recommendation branch April 17, 2024 11:54
timvisee pushed a commit that referenced this pull request Apr 22, 2024
* Fix average sparse vector recommendation

* Revert "Fix average sparse vector recommendation"

This reverts commit 186c512.

* sort within combine (Ivan's approach)

* Revert "sort within combine (Ivan's approach)"

This reverts commit 28d560c.

* simpler approach without mutation
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.

None yet

2 participants