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

How can I ensure consistent results every time I run the code? I get different results each time I run the code #540

Open
Chengwei-Yan opened this issue Mar 1, 2024 · 7 comments

Comments

@Chengwei-Yan
Copy link

How can I ensure consistent results every time I run the code? I get different results each time I run the code

@yurymalkov
Copy link
Member

Search should be deterministic. Construction is not deterministic if using more than a single thread

@Chengwei-Yan
Copy link
Author

Search should be deterministic. Construction is not deterministic if using more than a single thread

thanks for your reply

@Chengwei-Yan
Copy link
Author

Search should be deterministic. Construction is not deterministic if using more than a single thread

Search should be deterministic. Construction is not deterministic if using more than a single thread

I tried setting only one thread, but the results are still different every time

@yurymalkov
Copy link
Member

Hm. That is strange. Is the data order is the same?

@Chengwei-Yan
Copy link
Author

Hm. That is strange. Is the data order is the same?

the data order is the same.I used hnswlib in python. I tried calculating mutual nearest neighbors, but each time the same group of data is calculated, the quantity is different.

@Chengwei-Yan
Copy link
Author

Hm. That is strange. Is the data order is the same?

here is the code:
dim = dataset2.shape[1]
num_elements = dataset2.shape[0]
tree = hnswlib.Index(space="cosine", dim=dim)
tree.init_index(max_elements=num_elements, ef_construction=200, M=16)
tree.set_ef(50)
tree.set_num_threads(1)
tree.add_items(dataset2)
ind, _ = tree.knn_query(dataset1, k=knn,num_threads =1)

@rdy5644
Copy link

rdy5644 commented Jul 24, 2024

@Chengwei-Yan did you find anything here?
We are also facing this issue

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

No branches or pull requests

3 participants