billkle1n
billkle1n
@yhpku something like that: ```python from faiss import normalize_L2 # ... index.train(normalize_L2(training_vectors)) index.add(normalize_L2(index_vectors)) index.search(normalize_L2(search_vectors), 5) ```
@mdouze assuming vectors are normalized before indexing/training/search, wouldn't `(2-distances**2)/2` convert the `METRIC_L2` distances (returned by the search function) to cosine similarities (inner product metric)? My maths are a bit rusty...
@mdouze thanks. I just noticed that the distances returned by IVFPQ are already squared so it would be `(2-distance) / 2`
I'm in the same boat. It's not even clear if I can run the software on my work laptop with the current license.
Thanks. Does `key` refer to the vector's ID? I tried the following: ```python # ... print(index.reconstruct(2)) ``` But am getting this error: ```python ../../../../.pyenv/versions/3.6.2/envs/rise/lib/python3.6/site-packages/faiss.py:134: in replacement_reconstruct self.reconstruct_c(key, swig_ptr(x)) _ _...
Printed those values: ```python print('index.ntotal =', index.ntotal) # >>> index.ntotal = 3 print('index.direct_map.size() =', index.direct_map.size()) # >>> index.direct_map.size() = 0 ``` So it looks like `direct_map` is empty, whatever that...
Tried again with an IndexIDMap but different error: ```python import faiss from sklearn.preprocessing import normalize def l2_normalize(v): return normalize(v, norm='l2') d=128 nlists=8 M=32 nbits=8 coarse_quantizer = faiss.IndexFlatL2(d) ivfpq_index = faiss.IndexIVFPQ(...
Oh, setting `index.maintain_direct_map = True` fixed the issue. Is that because otherwise there's no way to access a vector by ID in constant time (e.g. you'd have to iterate over...
Thanks for the quick replies 👍
Thanks. I'm not exactly sure but now that it's in the issues it is a bit more searchable.