I am using nmslib with hnsw method for vector similarity search. I have built index class for index creation:
class NMSLIBIndex():
def __init__(self, vectors, labels):
self.dimention = vectors.shape[1]
self.vectors = vectors.astype('float32')
self.labels = labelsdef build(self):
self.index = nmslib.init(method='hnsw', space='cosinesimil')
self.index.addDataPointBatch(self.vectors)
self.index.createIndex({'post': 2})
def query(self, vector, k=10):
indices = self.index.knnQuery(vector, k=k)
return [self.labels[i] for i in indices[0]]
I was referring to this article https://towardsdatascience.com/comprehensive-guide-to-approximate-nearest-neighbors-algorithms-8b94f057d6b6
And now i want to load this indices to my database to use in online environment. My question is, how could i save these indices built on my vectors?