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

Recommendation api update + local mode #314

Merged
merged 16 commits into from
Oct 5, 2023
Merged

Recommendation api update + local mode #314

merged 16 commits into from
Oct 5, 2023

Conversation

generall
Copy link
Member

@generall generall commented Sep 25, 2023

  • Implement support for vectors and strategy in reco API
  • local mode

@coszio
Copy link
Contributor

coszio commented Sep 26, 2023

New tests are failing at the moment, there is difference in the score precision being generated in local mode, apparently. Will continue tomorrow

@coszio coszio marked this pull request as draft September 26, 2023 21:58
@coszio coszio self-assigned this Sep 27, 2023
@coszio coszio marked this pull request as ready for review September 27, 2023 20:21
@coszio coszio changed the title WIP: recommendation api update Recommendation api update + local mode Sep 27, 2023
@coszio coszio requested a review from joein September 27, 2023 20:25
qdrant_client/http/models/models.py Outdated Show resolved Hide resolved
qdrant_client/http/models/models.py Outdated Show resolved Hide resolved
qdrant_client/http/models/models.py Outdated Show resolved Hide resolved
qdrant_client/http/models/models.py Outdated Show resolved Hide resolved
qdrant_client/local/distances.py Outdated Show resolved Hide resolved
qdrant_client/qdrant_remote.py Outdated Show resolved Hide resolved
Comment on lines 811 to 816
RestToGrpc.convert_extended_point_id(example)
if isinstance(example, get_args_subscribed(models.ExtendedPointId))
else example
for example in positive
if isinstance(example, get_args_subscribed(models.ExtendedPointId))
or isinstance(example, grpc.PointId)
Copy link
Member

Choose a reason for hiding this comment

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

same

qdrant_client/qdrant_remote.py Outdated Show resolved Hide resolved
@@ -118,7 +118,7 @@ def compare_scored_record(
point1.id == point2.id
), f"point1[{idx}].id = {point1.id}, point2[{idx}].id = {point2.id}"
assert (
point1.score - point2.score < 1e-4
abs(point1.score / point2.score - 1) < 1e-4
Copy link
Member

Choose a reason for hiding this comment

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

Is it actually better?
I can see the concern about abs, but with the division it is not clear for me
I don't mind, but it should be checked for a division by zero

Copy link
Contributor

Choose a reason for hiding this comment

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

new reco was failing because for only negatives recommendation, scores can be in the magnitude of hundreds, which needed to either

  1. Decrease precision check
    or
  2. "Normalize" the scores

But then it is true that we get into division by zero errors

Copy link
Contributor

Choose a reason for hiding this comment

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

Resorted to another solution: adjust the precision based on the magnitude of the score

tests/congruence_tests/test_recommendation.py Outdated Show resolved Hide resolved
@coszio coszio requested a review from joein October 2, 2023 12:26
@generall generall merged commit bb8c442 into dev Oct 5, 2023
generall added a commit that referenced this pull request Oct 6, 2023
* WIP: recommendation api update

* implement local new reco + add new tests

* refactor calculate_best_scores, normalize score assertion

* fix raw vectors in new recommend

* fix mypy errors, add new reco on group recommend

* fix more lints from ci

* fix pyright lint

* formattng

* Add descriptions to enums

* no mutable default argument

* edit score comparison precision based on magnitude

* Address review comments

* remove custom message for type ignore

* add coverage test

* improve coverage test a little

* add more fixtures for conversion test

---------

Co-authored-by: Luis Cossío <[email protected]>
@generall generall deleted the update-reco-api branch May 3, 2024 10:49
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.

3 participants