oasysai / oasysdb

Hybrid vector database with flexible SQL storage engine & multi-index support.
https://docs.oasysdb.com/
Apache License 2.0
357 stars 12 forks source link

fix: search distance calculation #78

Closed edwinkys closed 6 months ago

edwinkys commented 6 months ago

Purpose

This PR is to fix the bug in this Google Colab notebook: https://colab.research.google.com/drive/1zQtpXkkWASt_37aiA7m5ZZcMqBnUGxOZ?usp=sharing

In short, the search result distance returned is that of Euclidean instead of the configured Cosine.

Cause

https://github.com/oasysai/oasysdb/blob/b04772b5dc9fc27faab3e2c42a1f39885f9c2628/src/func/collection.rs#L297

https://github.com/oasysai/oasysdb/blob/b04772b5dc9fc27faab3e2c42a1f39885f9c2628/src/func/utils.rs#L337-L349

Testing

I added a new test in Python to check the result.

Chore checklist