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

Uploaded CPython 3.14Windows x86-64

faiss_cpu-1.14.2-cp313-cp313-win_amd64.whl (16.1 MB view details)

Uploaded CPython 3.13Windows x86-64

faiss_cpu-1.14.2-cp312-cp312-win_amd64.whl (16.1 MB view details)

Uploaded CPython 3.12Windows x86-64

faiss_cpu-1.14.2-cp311-cp311-win_amd64.whl (16.1 MB view details)

Uploaded CPython 3.11Windows x86-64

faiss_cpu-1.14.2-cp310-cp310-win_amd64.whl (16.1 MB view details)

Uploaded CPython 3.10Windows x86-64

faiss_cpu-1.14.2-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (18.2 MB view details)

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

faiss_cpu-1.14.2-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (9.6 MB view details)

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

faiss_cpu-1.14.2-cp310-abi3-macosx_15_0_x86_64.whl (6.7 MB view details)

Uploaded CPython 3.10+macOS 15.0+ x86-64

faiss_cpu-1.14.2-cp310-abi3-macosx_14_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.10+macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: faiss_cpu-1.14.2-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.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 b736813d853d36693f7b5affdc8788adfa73efa2f45ac6493c8ce2cbb2584f19
MD5 653933de60a6dc69131d85b5db32e69c
BLAKE2b-256 9e59ff73cb48bd1a98a355ff5a6a2018f3cfe4980ec2196b4938bf8af4fb828b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: faiss_cpu-1.14.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 16.1 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.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d81857f1fcf6c5dc76f75b35112158f731aeb7804ca971c51d74edf6e9b1b8c7
MD5 b60a1b2c576ece67b3d9f4a778dfce61
BLAKE2b-256 6004555551ceec73248e76b758014a6fba702349824270be27d0e5db1f740feb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: faiss_cpu-1.14.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 16.1 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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 292124ba3d2bbeed920ef8519451cfba0f139b77db1607170cffbe68dc72e604
MD5 204ccb44d4867b525ca2b8ba8d39eba1
BLAKE2b-256 f242af4df8012e0ed817df2c4094a816b538d99bfbbcbf567cd9f5f36d5fb9b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: faiss_cpu-1.14.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 16.1 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.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a9d81699ff3ae6e25244efda48c52e406963bbce16d5754073725c14620885c6
MD5 0173b33924b745dca556d478c91e2add
BLAKE2b-256 56b9a4d076acd9eeaf6fb6f5a29de1a7a0a34de411d0fbe3d8f8c91abb9f97e0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: faiss_cpu-1.14.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 16.1 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.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9bfbbb323347e4bbb861dcc4db80d27ca750a2a1375d6b28c39729d2f9cc6217
MD5 bffccdb173c48febd5ec9ee49210b48b
BLAKE2b-256 5669a7e00faed1c756433830f1c530c1d1c5cd38e78a48f74b9e068eee93ffa6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for faiss_cpu-1.14.2-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ec4784d9a14973f2eead3a3480e6d14e74253b234e2c12717d4319f21dfadfcd
MD5 0c20f5afa3a82e93621101d260b5d693
BLAKE2b-256 7f66108f7075591b84852a6b285a81922e773c1c6d3b2c45da8ec4822f1bfab4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for faiss_cpu-1.14.2-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b340c33212351f04d4f167cb7b22c9e756705a634d3b7b58987651f3ba1f6217
MD5 1963a733817e12e1c7ccbeab2028ea1e
BLAKE2b-256 35b4d130a1908ad548671cd5ee9a1b537c7d3753cfdf0b2b134f3c10ccc6b537

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for faiss_cpu-1.14.2-cp310-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 6ba528b5803fe5206bbb38e6ea2c537de0d1482a47c5765982af4e4a48c135e2
MD5 f8a6cf1009561c4907ba9275212d551c
BLAKE2b-256 84b105876aa7ceafd67a8c53667f574c0354e50ebadfdaf0632d7d9f5c80fffe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for faiss_cpu-1.14.2-cp310-abi3-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a20011b8a97318e6d5e29143a773277ca71f1c33140024aeec91f05ad56cdd04
MD5 190b9c3052f6ad78f9ccec1e5fdbb044
BLAKE2b-256 c88b5d2cd7c9fd60bc4d1ca6e9f5e8b0eb57254a7b301daaa12d5853fdf48afe

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