Skip to main content

A library for efficient similarity search and clustering of dense vectors.

Project description

Faiss

Faiss is a library for efficient similarity search and clustering of dense vectors. It contains algorithms that search in sets of vectors of any size, up to ones that possibly do not fit in RAM. It also contains supporting code for evaluation and parameter tuning. Faiss is written in C++ with complete wrappers for Python/numpy. Some of the most useful algorithms are implemented on the GPU. It is developed primarily at Meta's Fundamental AI Research group.

News

See CHANGELOG.md for detailed information about latest features.

Introduction

Faiss contains several methods for similarity search. It assumes that the instances are represented as vectors and are identified by an integer, and that the vectors can be compared with L2 (Euclidean) distances or dot products. Vectors that are similar to a query vector are those that have the lowest L2 distance or the highest dot product with the query vector. It also supports cosine similarity, since this is a dot product on normalized vectors.

Some of the methods, like those based on binary vectors and compact quantization codes, solely use a compressed representation of the vectors and do not require to keep the original vectors. This generally comes at the cost of a less precise search but these methods can scale to billions of vectors in main memory on a single server. Other methods, like HNSW and NSG add an indexing structure on top of the raw vectors to make searching more efficient.

The GPU implementation can accept input from either CPU or GPU memory. On a server with GPUs, the GPU indexes can be used a drop-in replacement for the CPU indexes (e.g., replace IndexFlatL2 with GpuIndexFlatL2) and copies to/from GPU memory are handled automatically. Results will be faster however if both input and output remain resident on the GPU. Both single and multi-GPU usage is supported.

Installing

Faiss comes with precompiled libraries for Anaconda in Python, see faiss-cpu, faiss-gpu and 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 also optional. The backend GPU implementations of NVIDIA cuVS can also be enabled optionally. It compiles with cmake. See INSTALL.md for details.

How Faiss works

Faiss is built around an index type that stores a set of vectors, and provides a function to search in them with L2 and/or dot product vector comparison. Some index types are simple baselines, such as exact search. Most of the available indexing structures correspond to various trade-offs with respect to

  • search time
  • search quality
  • memory used per index vector
  • training time
  • adding time
  • need for external data for unsupervised training

The optional GPU implementation provides what is likely (as of March 2017) the fastest exact and approximate (compressed-domain) nearest neighbor search implementation for high-dimensional vectors, fastest Lloyd's k-means, and fastest small k-selection algorithm known. The implementation is detailed here.

Full documentation of Faiss

The following are entry points for documentation:

Authors

The main authors of Faiss are:

  • Hervé Jégou initiated the Faiss project and wrote its first implementation
  • Matthijs Douze implemented most of the CPU Faiss
  • Jeff Johnson implemented all of the GPU Faiss
  • Lucas Hosseini implemented the binary indexes and the build system
  • Chengqi Deng implemented NSG, NNdescent and much of the additive quantization code.
  • Alexandr Guzhva many optimizations: SIMD, memory allocation and layout, fast decoding kernels for vector codecs, etc.
  • Gergely Szilvasy build system, benchmarking framework.

Reference

References to cite when you use Faiss in a research paper:

@article{douze2024faiss,
      title={The Faiss library},
      author={Matthijs Douze and Alexandr Guzhva and Chengqi Deng and Jeff Johnson and Gergely Szilvasy and Pierre-Emmanuel Mazaré and Maria Lomeli and Lucas Hosseini and Hervé Jégou},
      year={2024},
      eprint={2401.08281},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}

For the GPU version of Faiss, please cite:

@article{johnson2019billion,
  title={Billion-scale similarity search with {GPUs}},
  author={Johnson, Jeff and Douze, Matthijs and J{\'e}gou, Herv{\'e}},
  journal={IEEE Transactions on Big Data},
  volume={7},
  number={3},
  pages={535--547},
  year={2019},
  publisher={IEEE}
}

Join the Faiss community

For public discussion of Faiss or for questions, visit https://github.com/facebookresearch/faiss/discussions.

We monitor the issues page of the repository. You can report bugs, ask questions, etc.

Legal

Faiss is MIT-licensed, refer to the LICENSE file in the top level directory.

Copyright © Meta Platforms, Inc.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

faiss_cpu-1.14.3-cp314-cp314-win_amd64.whl (16.4 MB view details)

Uploaded CPython 3.14Windows x86-64

faiss_cpu-1.14.3-cp313-cp313-win_amd64.whl (16.2 MB view details)

Uploaded CPython 3.13Windows x86-64

faiss_cpu-1.14.3-cp312-cp312-win_amd64.whl (16.2 MB view details)

Uploaded CPython 3.12Windows x86-64

faiss_cpu-1.14.3-cp311-cp311-win_amd64.whl (16.2 MB view details)

Uploaded CPython 3.11Windows x86-64

faiss_cpu-1.14.3-cp310-cp310-win_amd64.whl (16.2 MB view details)

Uploaded CPython 3.10Windows x86-64

faiss_cpu-1.14.3-cp310-abi3-musllinux_1_2_x86_64.whl (19.2 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

faiss_cpu-1.14.3-cp310-abi3-musllinux_1_2_aarch64.whl (11.2 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

faiss_cpu-1.14.3-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (18.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

faiss_cpu-1.14.3-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (9.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

faiss_cpu-1.14.3-cp310-abi3-macosx_15_0_x86_64.whl (6.9 MB view details)

Uploaded CPython 3.10+macOS 15.0+ x86-64

faiss_cpu-1.14.3-cp310-abi3-macosx_14_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.10+macOS 14.0+ ARM64

File details

Details for the file faiss_cpu-1.14.3-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: faiss_cpu-1.14.3-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 16.4 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for faiss_cpu-1.14.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 54b0ea832be5bce75ef9abf1297fe4613d760bf7cfe7a963da040cb0314e8f58
MD5 f67b15cfa4d5cceb41f345c7c376267c
BLAKE2b-256 fdaa100d3b706b8e2aa561e2673ed7d07c4c7c26f92d938a88d193dd54f90c45

See more details on using hashes here.

File details

Details for the file faiss_cpu-1.14.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: faiss_cpu-1.14.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 16.2 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for faiss_cpu-1.14.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ea2340f675db59af8db6da4535b541ce6948d68a008989c656c292c7b0c77127
MD5 42fd4c60c04a161f8ec58e74f7f87de8
BLAKE2b-256 1dc12fb14f58ff74d7a7d6fd13084c016d9b144ce0bcdf77f6526cc2e4828278

See more details on using hashes here.

File details

Details for the file faiss_cpu-1.14.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: faiss_cpu-1.14.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 16.2 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for faiss_cpu-1.14.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0a5eb27184123c7ac1060c6b862978eabf0e30c1369ccf8bdb1497d35c06ad3d
MD5 128714842e8df826eeed6f379db87ec3
BLAKE2b-256 59aabfa53255a6aa6e79b2471bb5af895f662feb02b612e1e0f9efc3d893286e

See more details on using hashes here.

File details

Details for the file faiss_cpu-1.14.3-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: faiss_cpu-1.14.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 16.2 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for faiss_cpu-1.14.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f278003d00c30c90cf118b98428bb96f73eba4b9dadac6993c788966d2e983bd
MD5 fa3c08e6b19c61277efc513e84ceae60
BLAKE2b-256 786cbbf670ad727502102fa90c52f9b47c73753f0adda880d30427ac1d48b37b

See more details on using hashes here.

File details

Details for the file faiss_cpu-1.14.3-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: faiss_cpu-1.14.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 16.2 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for faiss_cpu-1.14.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 20414d5c98fb6ab9eedfb3df79841865911c2d67b6efe829dc46adfeab6f51b1
MD5 09c854cec799e2bbb4cf48c601a9fd9b
BLAKE2b-256 3fb2bee73e3514afd88602e606a52f99559872e277ed0010fd04769a6eff41d3

See more details on using hashes here.

File details

Details for the file faiss_cpu-1.14.3-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for faiss_cpu-1.14.3-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cdcb90850cb4b7c27d270839b37bcc0dc8d1fb6a62d1e13053e51ac95061ca25
MD5 bc920615aacc405056374e41e4417623
BLAKE2b-256 935fb405692913a301251749cb175cb3f564ed257fdaa80a22c9a36444d0095d

See more details on using hashes here.

File details

Details for the file faiss_cpu-1.14.3-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for faiss_cpu-1.14.3-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 b28ba083e8c02f2c9be03783402537fd3f00d27e68799c44bf88931500ee12ec
MD5 f9b65e1133321e46987285998df1e441
BLAKE2b-256 e7d3c6ca8c44a63b909e78aa8a69e14501c79c89613e62261d58455ea603d710

See more details on using hashes here.

File details

Details for the file faiss_cpu-1.14.3-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for faiss_cpu-1.14.3-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8780b526c06e57aad90a8c4655dfba2ff1b3195bd600ff4499752fc45159c9fc
MD5 e1711c2707a29e353429052b9fb9275b
BLAKE2b-256 a0ed57335bc18c9e18677587bec9bf070c675b29c8e683e13f4def0440731ca0

See more details on using hashes here.

File details

Details for the file faiss_cpu-1.14.3-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for faiss_cpu-1.14.3-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1d734cfa9ac90b6a5dfed3a27cb706d05f22824703dafc3969b4e2071877a31c
MD5 c9fb56db1bae587b3323c129cbc9fdd6
BLAKE2b-256 7c8ab451af4b3c6dd18749ecfb58ccb68503b77e49c9aa4a89d950e9d521e058

See more details on using hashes here.

File details

Details for the file faiss_cpu-1.14.3-cp310-abi3-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for faiss_cpu-1.14.3-cp310-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 f9d0e84d909194f63f027bbd3c1e35e905e48c9345c2db6e6f24da09a6bc5906
MD5 bce8f8f8086592315900aeaa308b0f3b
BLAKE2b-256 ab346b04ef5bae3eada6b5a9457d7875cce041c040d53c890815cbd1e9821c65

See more details on using hashes here.

File details

Details for the file faiss_cpu-1.14.3-cp310-abi3-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for faiss_cpu-1.14.3-cp310-abi3-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a9369863290a3f0e033757e4c10577b6ef7431f1cede394dabd0a137e4e2ed45
MD5 4e79c4134d89ddc8d72f7ba9c59883a7
BLAKE2b-256 83b048c083d01b7b68c463c1d56507147a9d733f791e1c469a77215a872a9fb5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page