Repository navigation
Conversation
Sibling of mem0ai#6546/mem0ai#6547. Hardcoded 1-distance collapses L2 hits. Closes mem0ai#7229.
|
Thanks for taking the time to open this. We only review pull requests that fix an issue we have already agreed to take on, so this one is closed for now. To get it reviewed:
Issue already labeled Documentation-only changes skip this gate entirely. See CONTRIBUTING.md for the full policy. |
|
Hi @ktz03, thanks for opening this pull request. This is just a soft check: you are not yet in this repo's vouched contributor list ( A maintainer can vouch for you by commenting |
|
An |
Linked Issue
Closes #7229
Description
Sibling of #6546 / #6547 for the Valkey store.
Search scoring hardcoded
max(0.0, 1.0 - raw_distance), which is only correct for cosine. With L2 (already accepted bycreate_col(distance=...)), unbounded distances collapse almost every hit withd > 1to0.0.This PR:
distancetoValkeyConfig/ValkeyDB(defaultCOSINE)self.distancein_create_index(was hardcodedCOSINE)create_col(..., distance=...)ontoself.distancefor scoring_distance_to_scoremirroring fix(vector_stores/s3_vectors): make search score metric-aware #6547:max(0, 1 - d)1 / (1 + d)Type of Change
Breaking Changes
N/A. Cosine (the default) is unchanged; only L2 scoring is corrected, and index init now respects the configured metric.
Test Coverage
Added regression tests in
tests/vector_stores/test_valkey.py:1 - dd=4.0to0create_col(distance="L2")updates scoring, not onlyFT.CREATEChecklist