CLI tool
facebookresearch/faiss avatar
facebookresearch/faiss

Faiss: a C++ similarity search library that scales past RAM, with sharp edges

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

40,905 stars4,524 forksC++MIT

At a glance

What is it?
Faiss is Meta's library for similarity search and clustering of dense vectors, written in C++ with Python bindings and optional GPU support. It is the right tool for billion-scale approximate search, but its training requirements and index tuning curve make it a poor fit for small or quick projects.
Who is it for?
Adopt Faiss if you manage dense vector collections larger than a few million items and need sub-linear search time with tunable accuracy, especially if you have GPU capacity or a Python deployment via conda. Skip it if your dataset fits trivially in memory and you need a zero-configuration exact search, or if you cannot afford the unsupervised training step required by most approximate indexes.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly C++, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 14, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

What Faiss actually solves

Faiss solves the problem of finding nearest neighbors in a set of dense vectors when the set is too large for a brute-force scan. The README states it contains algorithms that search in sets of vectors of any size, up to ones that possibly do not fit in RAM. That is the core promise: exact search is present, but the value sits in the approximate indexes that trade a little accuracy for a large cut in search time and memory. The intended user is someone building a recommendation engine, a duplicate detector, or a retrieval pipeline on embeddings, where the vector count is in the millions or billions. The library assumes vectors are identified by an integer and compared with L2 distance or dot product. Cosine similarity is supported only as a dot product on normalized vectors, which is a constraint you must design around.

The index abstraction and the trade-off space

Faiss is built around an index type that stores vectors and offers a search function. The README lists six trade-offs that distinguish index types: search time, search quality, memory per index vector, training time, adding time, and the need for external data for unsupervised training. That list is the mental model you need. Some indexes, like IndexFlatL2, are exact baselines: they store raw vectors and scan everything. Others, such as HNSW and NSG, add a graph structure on top of the raw vectors to prune the search space. Still others, based on binary vectors or compact quantization codes, keep only a compressed representation and never store the original vectors. The last category is what lets Faiss scale to billions of vectors in main memory on a single server, at the cost of a less precise search. The README does not give a default index, and that is deliberate: picking one is a tuning exercise, not a configuration step.

Getting it running: conda packages and cmake

The fastest path is a precompiled Anaconda package. The README lists faiss-cpu, faiss-gpu, and faiss-gpu-cuvs on the pytorch conda channel. The GPU packages bundle CUDA support, and the cuvs variant enables NVIDIA's cuVS backend. For a CPU-only setup, installing faiss-cpu from conda is one command, though the README does not print the exact command. If you need a custom build, the library compiles with cmake and the only hard dependency is a BLAS implementation. Optional pieces include CUDA or AMD ROCm for GPU support and a Python interface. The README points to INSTALL.md for details, which is where the actual build flags live. A Python user who does not need GPU can likely avoid compiling entirely, which is a real advantage over many C++ libraries.

GPU support: drop-in but with residency caveats

The GPU implementation accepts input from either CPU or GPU memory. The README says you can replace IndexFlatL2 with GpuIndexFlatL2 and copies to and from GPU memory are handled automatically. That is a genuinely low-friction design for someone who already has an index working on CPU. But the README is explicit that results are faster if both input and output remain resident on the GPU. The automatic copies are a convenience, not a performance feature. Multi-GPU usage is supported, and the README claims the GPU implementation is likely the fastest exact and approximate nearest neighbor search for high-dimensional vectors, fastest Lloyd's k-means, and fastest small k-selection algorithm as of March 2017. That claim is dated, and the README does not provide newer benchmarks, so treat it as a historical statement rather than a current guarantee.

A real limitation: training and the external data requirement

Many Faiss indexes require an unsupervised training step. The README lists the need for external data for unsupervised training as one of the trade-offs. That means you cannot just add vectors to an IndexIVFFlat or a product-quantization index and search. You must first train the index on a representative sample of your data, which adds a preprocessing stage and a dependency on the sample quality. If your data distribution shifts after training, the index may degrade. This is a genuine failure mode for a streaming or rapidly changing dataset. The README does not discuss how to retrain or update an index, so you are on your own for that lifecycle. For a small dataset where exact search is fast enough, this training step is pure overhead with no benefit.

Alternatives: cuVS and the exact-scan baseline

The README mentions NVIDIA cuVS as an optional backend for GPU indexes, but cuVS is also a standalone library. The difference in approach is that cuVS is built specifically for GPU-accelerated nearest neighbor search on RAPIDS, while Faiss is a broader C++ library with GPU as one optional path. If you are already in a RAPIDS or cuDF pipeline, cuVS may integrate more directly. On the other end, the simplest alternative is not a library at all: a brute-force exact scan using numpy or a BLAS matrix multiply. For datasets up to a few million vectors with moderate dimensionality, that exact scan is often fast enough and requires no training, no index tuning, and no memory compression. Faiss wins when that scan becomes too slow or too memory-heavy. The README does not compare Faiss to any other library, so this judgement comes from the described trade-offs.

Maintenance, licensing, and upgrade cost

The repository is active. The last push was 2026-08-03, and the most recent release is v1.15.0 from the same date. That cadence suggests regular maintenance, but the README does not state a support policy or a deprecation cycle. Upgrading Faiss can be non-trivial because index binary formats may change between versions, and the README does not promise backward compatibility for serialized indexes. You should plan to reindex or at least test loading old indexes after an upgrade. The license is MIT, which is permissive for commercial use, including the GPU code. The README notes the library is copyright Meta Platforms, Inc., but the MIT license imposes few obligations beyond preserving the copyright notice. No legal advice here, just the plain reading of the license text.

Editorial conclusion

Adopt Faiss if you manage dense vector collections larger than a few million items and need sub-linear search time with tunable accuracy, especially if you have GPU capacity or a Python deployment via conda. Skip it if your dataset fits trivially in memory and you need a zero-configuration exact search, or if you cannot afford the unsupervised training step required by most approximate indexes. Before committing, verify your distance metric (L2 or dot product) is supported, confirm your GPU driver and CUDA version match the precompiled packages, and benchmark the recall-versus-latency trade-off on your own vectors, because Faiss exposes many knobs and the default index may not suit your distribution.

Official sources

  1. Official documentation
  2. Official README
  3. Project repository
  4. Release notes
Community notes

Community notes