facebookresearch/faiss
DataA C++/Python library for efficient similarity search and clustering of dense vectors, with optional GPU acceleration.
What Faiss does
Faiss is a library for similarity search and clustering of dense vectors: each item is stored as a vector plus an integer id, and queries return the vectors closest under L2 distance, dot product, or cosine similarity on normalized vectors. Its index types cover the trade-off between search speed, recall, memory per vector, and indexing time. Compact and binary-vector indexes keep only a compressed representation, allowing billions of vectors to live in the main memory of one server at lower precision, while graph-based indexes such as HNSW and NSG add a structure over raw vectors for faster search.
The core is C++ with complete Python/numpy wrappers and optional GPU implementations via CUDA or AMD ROCm. GPU indexes can replace CPU ones almost directly (for example GpuIndexFlatL2 in place of IndexFlatL2), with memory copies handled automatically; keeping inputs and outputs on the GPU gives the best speed. It is developed primarily at Meta's Fundamental AI Research group and is useful for recommendation, image or text embedding retrieval, deduplication, and clustering work.
Install
The README points to precompiled Conda packages: faiss-cpu for CPU use, and faiss-gpu and faiss-gpu-cuvs for GPU variants. After installing a matching package, import Faiss in Python and build an index.
A minimal CPU example, with vectors represented as a float32 numpy array:
import numpy as np
import faiss
d, nb, nq, k = 128, 10000, 5, 10
xb = np.random.random((nb, d)).astype('float32')
xq = np.random.random((nq, d)).astype('float32')
index = faiss.IndexFlatL2(d)
index.add(xb)
D, I = index.search(xq, k) # distances and ids of k nearest neighbors
print(I)
Building from source uses CMake; see INSTALL.md for prerequisites and build flags. The getting-started tutorial walks through other index types and evaluation workflows. Faiss assumes the caller supplies vectors and does not include embedding models, so an application needs its own encoding pipeline before indexing.
Usage constraints
The only hard dependency for the CPU build is a BLAS implementation; GPU support is optional and requires CUDA or ROCm. Python support is also optional, so the C++ library can be used without Python. Which index to choose depends on dataset size, memory budget, latency, and acceptable recall loss; compressed indexes trade accuracy for scale, and approximate structures may need training data before adding vectors. The project is MIT-licensed.
Community and references
Questions and bug reports go to GitHub Discussions and the issue tracker. For deeper material, an unofficial manual was written by Pinecone after the authors found limited learning resources around Faiss. A practitioner in the HN thread noted using Faiss for LiDAR map building during a PhD and relying heavily on its wiki and example code for guidance. Faiss is also one of the indexing options used inside the Milvus vector database according to a Milvus contributor.
HotRepo's take
On the C++ daily list for 2026-11-11, Faiss added 68 stars and reached 2nd place, with 41,402 stars in total. The discussion record is long-running: an HN thread in March 2023 drew 263 points and 52 comments (source:3), after earlier threads in 2021 and 2017. The comments are not uniformly promotional. A 2023 thread includes users arguing that hnswlib is simpler and faster on CPU in their experience, and one commenter describes using Faiss as one of several indexing engines behind Milvus alongside other libraries. For readers deciding between vector-search libraries, these discussions are more useful than the star count: Faiss provides a broad set of index types and GPU paths, while simpler CPU libraries may be preferred for embedded, lower-throughput cases.
Written by AI from the project's README, updated . The project's own docs are the source of truth.