Skip to main content

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.

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.15.0-cp314-cp314-win_amd64.whl (16.5 MB view details)

Uploaded CPython 3.14Windows x86-64

faiss_cpu-1.15.0-cp313-cp313-win_amd64.whl (16.3 MB view details)

Uploaded CPython 3.13Windows x86-64

faiss_cpu-1.15.0-cp312-cp312-win_amd64.whl (16.3 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.10Windows x86-64

faiss_cpu-1.15.0-cp310-abi3-musllinux_1_2_x86_64.whl (19.5 MB view details)

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

faiss_cpu-1.15.0-cp310-abi3-musllinux_1_2_aarch64.whl (11.4 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

faiss_cpu-1.15.0-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (18.8 MB view details)

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

faiss_cpu-1.15.0-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (9.8 MB view details)

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

faiss_cpu-1.15.0-cp310-abi3-macosx_15_0_x86_64.whl (7.1 MB view details)

Uploaded CPython 3.10+macOS 15.0+ x86-64

faiss_cpu-1.15.0-cp310-abi3-macosx_14_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.10+macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: faiss_cpu-1.15.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 16.5 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.15.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 37170d5e9ead4b6bfd9c314afc39e17e92064068a0c5a4063dd3f39568c2667e
MD5 b63ee9bb0b7a51c8e16c21032fec5daf
BLAKE2b-256 ec130a021b9df16963f839a3f325657656b70f23b5a6dbeb422eaa187d0121b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: faiss_cpu-1.15.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 16.3 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.15.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 22dddb013e764aad66dac6cd15b49c7598d60339e0591b73b5e081629419c21b
MD5 e482a3bf99b128704979e83a8ce2fb7d
BLAKE2b-256 96744a70395a6e07036628a1bd0b3f709101a6aecfa6a746db13b6e7921cf291

See more details on using hashes here.

File details

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

File metadata

  • Download URL: faiss_cpu-1.15.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 16.3 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.15.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5b940897b317febaa761088513a3db164fad3ac71a5e1ed7be9a052c9bf1a447
MD5 8c2e238e74709175ea168bafaf417365
BLAKE2b-256 b276021398ec5608314124b554bb025878a86f129bcf3576c293826352d9a783

See more details on using hashes here.

File details

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

File metadata

  • Download URL: faiss_cpu-1.15.0-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.15.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 90169515a95ea58a9a95d419e518907927a8ef54c46788396365ec5902c9c8df
MD5 088d4bb7a4028a6a317cffe365ae022d
BLAKE2b-256 5bb147967207659650ad74c1b06c42671e6beb4f7d798fe6eb2d53ba5e77ad90

See more details on using hashes here.

File details

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

File metadata

  • Download URL: faiss_cpu-1.15.0-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.15.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e0fe7278f3784b7d205ae715a115801cafb75f6e55db6b0fbe83c4ff379f003f
MD5 cdc30feedd10dbeb73e962d5385fe5d5
BLAKE2b-256 f41ef073d88436f1d4d4f7dcd638c5512197ad78fcdc1eb77db1d9929cf158ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for faiss_cpu-1.15.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 88fbe1acac6978869063cb2f9477f85718da596a6e0a17751618f9c756bce255
MD5 330ee7e7861a37e37773f9f2277bded8
BLAKE2b-256 9d8c0a0f09659c1972aa83b9820cd3dd7f68f6678cfcfebde542e1c23d7d8663

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for faiss_cpu-1.15.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 30da3029952f0de69f16ce31946fd63fc3e292c867749bbcd2c0a0f09fd06f65
MD5 d8f80196444b8a4dcfee52da0753fcc7
BLAKE2b-256 db2a654116e6ee2808562a6b2a11c396bdb46d45689e3bf7206ee99400589cab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for faiss_cpu-1.15.0-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ec9b29aae29e428c085c2d49dbb02e4673cdea75db418d420f9e60e0b4184498
MD5 0dee3f3e93525d64770cbcdda837520e
BLAKE2b-256 c83b8878dbfc78a0084bbd408b34827a58b530be98132fcf620b7e15f9191614

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for faiss_cpu-1.15.0-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5d0a2d5d33fe023e263d0d355a837f20db67578e3be27fc5f4012a273274abf6
MD5 ae8f44bc8342798ef0e940739fb21c68
BLAKE2b-256 94c888b072bf55714405d0d7e11c12349510f15a69ae56033b1cd894fb2be7d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for faiss_cpu-1.15.0-cp310-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 dd383bb1ce06fabcff5785f998f253aa88f88dcbe1fe36c922417cd6666dd896
MD5 e5bbd8b49cc926a4dcf977b9b4339086
BLAKE2b-256 d2cdef4cf498977c4a84af7a8920bc97ca49fc19060c8464c63fab58847b4692

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for faiss_cpu-1.15.0-cp310-abi3-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 50ea471ef1f4f3580eda8ab0ec9727d4bf65fd71c444bf306ce7cdbba8a42b21
MD5 4f9188984355b4ca4711d827c52fe477
BLAKE2b-256 596820e91694ad9a8b2bb48af956899e52b645cb1501e7e2ec31cb733da4d4c5

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 Sentry Error logging StatusPage Status page