asg017 / sqlite-vss

A SQLite extension for efficient vector search, based on Faiss!
MIT License
1.59k stars 58 forks source link

Metric INNER_PRODUCT should return the maximum #117

Closed lkyhfx closed 5 months ago

lkyhfx commented 5 months ago

I set the metric type to inner product and use default index. When do vector search it sort the metric ascending, then return the top k, which return the smallest top k, but when using inner product it should return biggest top k https://github.com/facebookresearch/faiss/wiki/MetricType-and-distances.

Inner product is mainly used to calculate the cosine similarity, not vector distance, so the most similar one should return.

lkyhfx commented 5 months ago

Identify the issue: a typo in metric_type=INNER_PRODUCT was mistakenly written as metrci_type=INNER_PRODUCT. There is no error to indicate the typo, causing sqlite-vss to default to the L2 metric.