About this project

Faiss is a library for efficient similarity search and clustering of dense vectors, developed primarily at Meta's Fundamental AI Research group. It assumes instances are represented as vectors identified by integers, compared using L2 (Euclidean) distance or dot products; cosine similarity is supported via dot products on normalized vectors. The library contains algorithms that search in sets of vectors of any size, including sets that may not fit in RAM. It also includes supporting code for evaluation and parameter tuning. Faiss is written in C++ with complete wrappers for Python/numpy, and some of the most useful algorithms are implemented on the GPU. Index types range from simple exact-search baselines to structures that trade off search time, search quality, memory per index vector, training time, adding time, and the need for external data for unsupervised training. Methods based on binary vectors and compact quantization codes use only a compressed representation and do not need to keep original vectors, generally at the cost of less precise search but with the ability to scale to billions of vectors in main memory on a single server. Other methods such as HNSW and NSG add an indexing structure on top of raw vectors to make searching more efficient. The GPU implementation accepts input from either CPU or GPU memory. On a server with GPUs, GPU indexes can be used as a drop-in replacement for CPU indexes (for example, replacing IndexFlatL2 with GpuIndexFlatL2), with copies to and from GPU memory handled automatically. Results are faster when both input and output remain resident on the GPU. Single and multi-GPU usage is supported. Installation: precompiled libraries are available for Anaconda in Python (faiss-cpu, faiss-gpu, faiss-gpu-cuvs). The library is mostly implemented in C++; the only dependency is a BLAS implementation. Optional GPU support is provided via CUDA or AMD ROCm, and the Python interface is optional. Backend GPU implementations of NVIDIA cuVS can also be enabled optionally. It compiles with cmake; see INSTALL.md for details. Documentation entry points include the project wiki (with a getting-started tutorial, FAQ, and troubleshooting section), doxygen documentation at faiss.ai for per-class information extracted from code comments, and benchmark READMEs for reproducing results from research papers such as Polysemous codes, Billion-scale similarity search with GPUs, and Link and code. Faiss is MIT-licensed. Public discussion takes place in GitHub Discussions, and the issues page is monitored for bug reports and questions.