faiss/contrib
Matthijs Douze 2d8886cd4f IVF sorting routine (#2846)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/2846

Adds a function to ivf_contrib to sort the inverted lists by size without changing the results. Also moves big_batch_search to its own module.

Reviewed By: algoriddle

Differential Revision: D45565880

fbshipit-source-id: 091a1c1c074f860d6953bf20d04523292fb55e1a
2023-05-04 09:59:06 -07:00
..
README.md IVF sorting routine (#2846) 2023-05-04 09:59:06 -07:00
__init__.py
big_batch_search.py IVF sorting routine (#2846) 2023-05-04 09:59:06 -07:00
client_server.py Put idx_t in the faiss namespace (#2582) 2022-11-30 08:25:30 -08:00
clustering.py make balanced clusters the default (#2796) 2023-03-28 07:23:30 -07:00
datasets.py Add GIST1M to datasets 2023-04-26 02:07:11 -07:00
evaluation.py evaluation script + IVF block search (#2781) 2023-03-24 13:54:08 -07:00
exhaustive_search.py Implemented Jaccard distance (#2684) 2023-02-27 07:49:42 -08:00
factory_tools.py
inspect_tools.py
ivf_tools.py IVF sorting routine (#2846) 2023-05-04 09:59:06 -07:00
ondisk.py Add assertion to merge_ondisk.py (#2190) 2022-02-03 05:14:22 -08:00
rpc.py Fix RPC lib logging (#2433) 2022-09-08 01:05:52 -07:00
torch_utils.py Faiss pytorch bridge: revert to TypedStorage (#2631) 2022-12-16 15:38:08 -08:00
vecs_io.py

README.md

The contrib modules

The contrib directory contains helper modules for Faiss for various tasks.

Code structure

The contrib directory gets compiled in the module faiss.contrib. Note that although some of the modules may depend on additional modules (eg. GPU Faiss, pytorch, hdf5), they are not necessarily compiled in to avoid adding dependencies. It is the user's responsibility to provide them.

In contrib, we are progressively dropping python2 support.

List of contrib modules

rpc.py

A very simple Remote Procedure Call library, where function parameters and results are pickled, for use with client_server.py

client_server.py

The server handles requests to a Faiss index. The client calls the remote index. This is mainly to shard datasets over several machines, see Distributed index

ondisk.py

Encloses the main logic to merge indexes into an on-disk index. See On-disk storage

exhaustive_search.py

Computes the ground-truth search results for a dataset that possibly does not fit in RAM. Uses GPU if available. Tested in tests/test_contrib.TestComputeGT

torch_utils.py

Interoperability functions for pytorch and Faiss: Importing this will allow pytorch Tensors (CPU or GPU) to be used as arguments to Faiss indexes and other functions. Torch GPU tensors can only be used with Faiss GPU indexes. If this is imported with a package that supports Faiss GPU, the necessary stream synchronization with the current pytorch stream will be automatically performed.

Numpy ndarrays can continue to be used in the Faiss python interface after importing this file. All arguments must be uniformly either numpy ndarrays or Torch tensors; no mixing is allowed.

Tested in tests/test_contrib_torch.py (CPU) and gpu/test/test_contrib_torch_gpu.py (GPU).

inspect_tools.py

Functions to inspect C++ objects wrapped by SWIG. Most often this just means reading fields and converting them to the proper python array.

ivf_tools.py

A few functions to override the coarse quantizer in IVF, providing additional flexibility for assignment.

datasets.py

(may require h5py)

Definition of how to access data for some standard datasets.

factory_tools.py

Functions related to factory strings.

evaluation.py

A few non-trivial evaluation functions for search results

clustering.py

Contains:

  • a Python implementation of kmeans, that can be used for special datatypes (eg. sparse matrices).

  • a 2-level clustering routine and a function that can apply it to train an IndexIVF

big_batch_search.py

Search IVF indexes with one centroid after another. Useful for large databases that do not fit in RAM and a large number of queries.