Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Special operations on indexes
There are a few additional operations that are not supported for all types of indexes.
Reconstructing vectors from an index
reconstruct_n reconstruct one or several vector(s) from an index, given their ids.
Example usage: test_index_composite.py
IndexPreTransform (provided the underlying transform supports it)
Removing elements from an index
remove_ids removes a subset of vectors from an index. It takes an
IDSelector object that is called for every element in the index to decide whether it should be removed.
IDSelectorBatch will do this for a list of indices. The Python interface constructs this efficiently.
NB that since it does a pass over the whole database, this is efficient only when a significant number of vectors needs to be removed.
range_search returns all vectors within a radius around the query point (as opposed to the k nearest ones). Since the result lists for each query are of different sizes, it must be handled specially:
in C++ it returns the results in a pre-allocated
in Python, the results are returned as a triplet of 1D arrays
lims, D, I, where result for query i is in
IndexIVFFlat (CPU only).
Splitting and merging indexes
merge_fromcopies another index to this and deallocates it on-the-fly. You can use
IndexIVFs wrapped in a pre-transform.
copy_subset_tocopies a subset of this codes to another index. Example usage: to build indexes on a GPU and move them to CPU afterwards
The functions are implemented only for
IndexIVF subclasses because they are mainly interesting for large indexes.