The Faiss Library

Matthijs Douze, Alexandr Guzhva, Chengqi Deng, Jeff Johnson, Gergely Szilvasy, Pierre-Emmanuel Mazaré, María Lomelí, Lucas Hosseini, Hervé Jeǵou

TL;DR

Faiss is the industry-standard library for efficient vector similarity search, providing a modular "toolbox" of indexing, compression, and hardware-optimized search algorithms. It enables high-accuracy retrieval across datasets ranging from millions to trillions of vectors by meticulously balancing the trade-offs between speed, memory usage, and accuracy.

What Problem Does This Paper Address?

The explosion of deep learning has made embeddings—high-dimensional vector representations of data—the primary way we store and search complex information like text, images, and user preferences. However, finding the "nearest neighbor" to a query vector in a database of billions is computationally staggering.

Traditional databases (DBMS) are built for structured data and exact matches, not high-dimensional similarity. While Approximate Nearest Neighbor Search (ANNS) algorithms exist, they often force a choice between a single specific method. This paper presents Faiss as a comprehensive framework that addresses the need for a flexible, highly optimized, and scalable solution that can be integrated into larger vector database systems.

Methods

Faiss is designed as a pipeline rather than a single algorithm. Its core components include:

  • Vector Compression (Codecs): To save memory, Faiss converts raw 32-bit floats into compact codes. This includes standard Product Quantization (PQ) and more advanced Additive Quantization (AQ) methods like Residual Quantization (RQ) and Local Search Quantization (LSQ).
  • Non-Exhaustive Search (Indexing): To avoid checking every vector, Faiss uses two main strategies:
  • Inverted Files (IVF): Partitioning the vector space into clusters and only searching the most relevant ones.
  • Graph-based Methods: Using structures like HNSW (Hierarchical Navigable Small World) to navigate the vector space via a web of connections.
  • Refinement: A two-stage process where a fast, approximate index retrieves a "shortlist" of candidates, which are then re-ranked using a more accurate (but slower) distance computation.
  • Hardware Optimization: Faiss features deep integration with CPU SIMD instructions (AVX2, AVX512, NEON) and massive GPU acceleration to maximize throughput.

Datasets

The authors evaluate Faiss using several standard and modern benchmarks:

  • BIGANN: 1 million to 1 billion 128-dimensional SIFT features (image keypoints).
  • Deep1B: 1 billion 96-dimensional image features extracted via Google LeNet.
  • Contriever: A newly introduced dataset of 768-dimensional text embeddings, representing modern NLP and LLM workloads.

Key Insights and Ideas

  • The "Embedding Contract": The authors emphasize that vector search is bound by a contract: the embedding extractor (e.g., a neural net) must ensure distances reflect semantic similarity, while the index must retrieve those neighbors as accurately as possible based on that metric.
  • Pareto-Optimal Tuning: Faiss includes a framework to automatically prune the hyperparameter space. By identifying "Pareto-optimal" settings, users can find the fastest possible search for a specific accuracy target without exhaustive manual testing.
Example of Pareto-optimal parameter exploration
  • Quantizer Hierarchy: The paper defines a strict hierarchy of quantizers, showing that more complex methods like Additive Quantization provide better accuracy for small memory budgets, while simpler Scalar Quantizers are faster for very long codes.
Accuracy vs. code size trade-off for different codecs
  • Scaling Laws: Empirical analysis shows that for IVF indexes, search time scales at a rate below $\sqrt{N}$ (the square root of the database size), making it highly efficient for massive datasets.

Key Results

  • State-of-the-Art Performance: Benchmarks show Faiss is faster than or on par with other leading libraries like Google's SCANN and Microsoft's DiskANN, particularly in batch search modes.
  • Trillion-Scale Success: The authors demonstrate a real-world application indexing 1.5 trillion vectors. By sharding the index across hundreds of machines and using memory-mapped files, they achieved search times of roughly 1 second per query on a massive 83 TiB index.
  • Compression Efficiency: Additive Quantizers (RQ/LSQ) significantly outperform standard Product Quantization in low-memory regimes, though they require more time to train and encode.
Comparison of additive quantizers: encoding time vs. accuracy

Limitations and Future Work

The authors are clear about what Faiss is not:

  • Not a Database: It lacks features like concurrent write access, transaction management, and automatic query optimization. It is intended to be a component of a database, not a replacement.
  • Feature Extraction: Faiss does not create embeddings; it only indexes them.
  • Future Directions: The team is looking toward better hardware support for emerging architectures and exploring "associative vector memories" to further integrate vector search with transformer-based AI models.

Summary updated

BibTeX
@article{douze2025faiss,
  author = {Matthijs Douze and Alexandr Guzhva and Chengqi Deng and Jeff Johnson and Gergely Szilvasy and Pierre-Emmanuel Mazaré and María Lomelí and Lucas Hosseini and Hervé Jeǵou},
  title = {{The Faiss Library}},
  journal = {IEEE Transactions on Big Data},
  year = {2025},
  doi = {10.1109/tbdata.2025.3618474},
}
Figure