unum-cloud / usearch

Fast Open-Source Search & Clustering engine × for Vectors & 🔜 Strings × in C++, C, Python, JavaScript, Rust, Java, Objective-C, Swift, C#, GoLang, and Wolfram 🔍
https://unum-cloud.github.io/usearch/
Apache License 2.0
2.27k stars 142 forks source link

Bug: MultiIndex returns strange search results #274

Closed kimihailv closed 1 year ago

kimihailv commented 1 year ago

Describe the bug

MultiIndex (even from one index) gives wrong nearest neighbours.

Steps to reproduce

import numpy as np
from usearch.index import Indexes, Index

np.random.seed(42)
data = np.random.random((10_000, 256))

index = Index(ndim=256)
index.add(np.arange(data.shape[0]), data)

gt = np.arange(1000)[:, np.newaxis]
print('Single index recall@1:', (index.search(data[:1000], 1).keys == gt).sum(axis=1).mean())

multi = Indexes(
    indexes=[index]
)

print('Multi index recall@1:', (multi.search(data[:1000], 1).keys == gt).sum(axis=1).mean())

Output:

Single index recall@1: 0.927
Multi index recall@1: 0.001

Expected behavior

Similar performance

USearch version

2.5.1

Operating System

Ubuntu 23.04

Hardware architecture

x86

Which interface are you using?

Python bindings

Contact Details

No response

Is there an existing issue for this?

Code of Conduct

ashvardanian commented 1 year ago

This was just a matter of putting the return statement one line lower 🤦 Thanks!

ashvardanian commented 1 year ago

:tada: This issue has been resolved in version 2.7.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: