pynndescent icon indicating copy to clipboard operation
pynndescent copied to clipboard

Updating a compressed index fails with `AttributeError: 'NNDescent' object has no attribute '_neighbor_graph'`

Open lsorber opened this issue 1 year ago • 2 comments

Minimal example that reproduces the problem:

import numpy as np
from pynndescent import NNDescent

X = np.random.randn(1024, 384).astype(dtype=np.float32)
ann_index = NNDescent(X, metric="cosine", compressed=True)
ann_index.prepare()

X_update = np.random.randn(1024, 384).astype(dtype=np.float32)
ann_index.update(X_update)

Results in an AttributeError: 'NNDescent' object has no attribute '_neighbor_graph'.

With compressed=False this issue doesn't occur.

Thank you for the great package 🙏!

lsorber avatar Aug 11 '24 06:08 lsorber

compressed=True indexes are, unfortunately, not updateable; a bunch of the information needed for the update is dropped to compress the whole thing down to be smaller.

lmcinnes avatar Aug 11 '24 13:08 lmcinnes

Thanks for the clarification! Would it make sense to for instance raise a more informative error when attempting to update a compressed index to help other users know about this limitation?

lsorber avatar Aug 12 '24 05:08 lsorber