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

RuntimeError: Error initializing searcher: #347

Closed
najafmurtaza opened this issue Aug 7, 2020 · 2 comments
Closed

RuntimeError: Error initializing searcher: #347

najafmurtaza opened this issue Aug 7, 2020 · 2 comments

Comments

@najafmurtaza
Copy link

najafmurtaza commented Aug 7, 2020

Code:

def f(x):
       return np.random.rand(100)

train_data['emb'] = train_data['text'].apply(f)
test_data['emb'] = test_data['text'].apply(f)

dataset = np.array(train_data['emb'].tolist(), dtype=np.float32)
queries = np.array(test_data['emb'].tolist(), dtype=np.float32)

Error:

normalized_dataset = dataset / np.linalg.norm(dataset, axis=1)[:, np.newaxis]
# configure ScaNN as a tree - asymmetric hash hybrid with reordering
# anisotropic quantization as described in the paper; see README

#  ----- At this line -----

searcher = scann.ScannBuilder(normalized_dataset, 10, "dot_product").tree(
    num_leaves=2000, num_leaves_to_search=100, training_sample_size=250000).score_ah(
    2, anisotropic_quantization_threshold=0.2).reorder(100).create_pybind()

Traceback (most recent call last):
  File "/home/dev/.local/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3331, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-7-c748bb36181c>", line 6, in <module>
    2, anisotropic_quantization_threshold=0.2).reorder(100).create_pybind()
  File "/home/dev/.local/lib/python3.6/site-packages/scann/scann_ops/py/scann_builder.py", line 203, in create_pybind
    self.training_threads)
  File "/home/dev/.local/lib/python3.6/site-packages/scann/scann_ops/py/scann_ops_pybind.py", line 60, in create_searcher
    scann_pybind.ScannNumpy(db, scann_config, training_threads))
RuntimeError: Error initializing searcher: 
@najafmurtaza
Copy link
Author

The issue is resolved.
It turns out, searcher expects lots of training(dataset) examples.
In my case I had only 50 in dataset var.

@CarolineTong
Copy link

hello, I meet the same problem. How to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants