Coder Social home page Coder Social logo

Threaded add_items issue about hnswlib HOT 3 OPEN

nmslib avatar nmslib commented on August 15, 2024
Threaded add_items issue

from hnswlib.

Comments (3)

yurymalkov avatar yurymalkov commented on August 15, 2024 6

I see. Thanks!
It seems there are only two options to solve this:

  1. use single-threaded construction.
  2. setting high ef/efConstruction values, so the search will be almost exact.

There is a potential fix that can stabilize the randomness to some extent - setting the element levels before the actual insertion (it would require updating bindings), but it will not solve the problem completely.
I think that hnsw in faiss (e.g. https://github.com/facebookresearch/faiss/blob/master/benchs/bench_hnsw.py) works that way. You can try it (although it is generally slower than hnswlib at fixed accuracy).

from hnswlib.

yurymalkov avatar yurymalkov commented on August 15, 2024

Hi @sumsuddin,
Can you please provide a demo script to understand what is going on?

from hnswlib.

sumsuddin avatar sumsuddin commented on August 15, 2024

I can't share the private data that I was working on. But here is a randomly generated numpy array that I saved in a file. I attached the saved file here so that you can investigate.

# Generating sample data
#data = np.float32(np.random.random((num_elements, dim)))
#np.savetxt('data.txt', data)
data = np.loadtxt('data.txt')

For this specific random number combination (attached file) I get following two different recall accuracy randomly in different run.

Recall for two batches: 0.99990000000000001 (this happens rarely)
Recall for two batches: 1.0 (I mostly get this one)

Increasing the item size makes the issue more obvious in my experiments.
num_elements = 100000

I guess you can find easier ways to regenerate the issue.
Thanks for your time.

Python version : Python 2.7.6
OS: Ubuntu 14.04.5 LTS

data.txt

from hnswlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.