SPTAG icon indicating copy to clipboard operation
SPTAG copied to clipboard

SPTAG Module has no Attribute AnnIndex

Open Man8246 opened this issue 4 years ago • 3 comments

Loadnf sptag indexes into the memory

index = SPTAG.AnnIndex.Load('sptag_index')

batch_size = 20

Local index test on the vector search

index = SPTAG.AnnIndex.Load('sptag_index') results = [] for val in embeddings:

result = index.SearchWithMetaData(val, batch_size) # Search k=3 nearest vectors for query vector q
results.append([str(r).replace("b\'","").replace("\\n\'","") for r in result[2]])

So, whenever we load SPTAG and calling AnnIndex attribute with it throws an error.

AttributeError Traceback (most recent call last) in 1 # Loadnf sptag indexes into the memory ----> 2 index = SPTAG.AnnIndex.Load('sptag_index')

AttributeError: module 'SPTAG' has no attribute 'AnnIndex'

Man8246 avatar Sep 09 '21 04:09 Man8246

Same to me. Very confusing. I got this error when I build index

yuand23 avatar Sep 09 '21 07:09 yuand23

There is no document/hint provided anywhere so that it can be fixed anyhow.

Man8246 avatar Sep 09 '21 07:09 Man8246

I had this issue as well. I realised that, when build the cmake module, the Release folder was being created with the SPTAG module inside. For that reason I had to do the import as:

from Release import SPTAG

This then allowed me to call the AnnIndex attribute as SPTAG.AnnIndex.Load().

mastertilla avatar Oct 06 '21 13:10 mastertilla