The Faiss library

Matthijs Douze, Alexandr Guzhva, Chengqi Deng, Jeff Johnson, Gergely Szilvasy, Pierre-Emmanuel Mazaré, Maria Lomeli, Lucas Hosseini, Hervé Jégou · DOI

Abstract

Faiss (Facebook AI Similarity Search) is a high-performance library for similarity search and clustering of dense vectors, developed by Meta's Fundamental AI Research (FAIR) team. It addresses the challenges of searching through billions of high-dimensional embeddings by providing a modular toolkit of algorithms for compression, pruning, and hardware optimization. This paper summarizes the core architecture, evaluation benchmarks, and key performance trade-offs of the library.

Introduction

In modern deep learning, data—be it text, images, or user profiles—is frequently represented as high-dimensional vectors known as embeddings. Finding similar items requires performing a k-nearest neighbor (k-NN) search in this vector space. As datasets scale to billions of items, brute-force search becomes computationally prohibitive. Faiss provides a comprehensive suite of algorithms to build indices that prune the search space and compress data, enabling efficient retrieval at scale.

Methods

Faiss employs a compositional design, allowing users to combine different algorithmic components to meet specific engineering constraints.

  1. Vector Codecs (Compression): Techniques like Product Quantization (PQ) partition vectors into sub-vectors for quantization. Advanced Additive Quantizers, such as Residual Quantizer (RQ) and Local Search Quantizer (LSQ), provide higher accuracy for constrained memory budgets.
  2. Non-Exhaustive Search (Pruning): To avoid exhaustive comparisons, Faiss uses Inverted Files (IVF) to cluster the space and search only relevant buckets, or graph-based indices like HNSW for navigable small-world search.
  3. Hardware Optimization: The C++ core is optimized for SIMD instructions on CPUs and leverages massive parallelism on GPUs.
Comparison of encoding time vs. MSE for various quantization methods on Deep1M and Contriever1M datasets.

Datasets

The library is evaluated on several benchmarks:

  • BIGANN: 128-dimensional SIFT features (up to 1 billion vectors).
  • Deep1B: 96-dimensional image features extracted via Google LeNet.
  • Contriever: 768-dimensional text embeddings from Wikipedia, representing modern AI retrieval tasks.
  • Trillion-scale: A 1.5 trillion vector experiment demonstrating extreme scalability.

Key Insights and Ideas

A central concept in Faiss is the Pareto Frontier. There is no single optimal index; instead, engineers must navigate trade-offs between search speed, memory usage, and accuracy. Faiss provides the tools to explore this frontier effectively.

The Pareto frontier illustrating the trade-off between search speed (queries per second) and accuracy (1-recall@1).

Other key ideas include:

  • Residual Encoding: Compressing the difference (residual) between a vector and its cluster center often yields higher accuracy than compressing the raw vector.
  • Filtered Search: Efficient handling of metadata constraints (e.g., time-based filters) using bit signatures as fast pre-filters before performing vector math.

Key Results

Faiss consistently achieves state-of-the-art performance, rivaling specialized libraries like ScaNN or DiskANN. Its GPU implementation offers orders-of-magnitude speedups for brute-force search, and the library has successfully scaled to an index of 1.5 trillion vectors distributed across 100 machines, demonstrating its capacity for the world's largest retrieval problems.

Limitations and Future Work

Faiss is a library of algorithms, not a full-featured database. It lacks concurrent write access and transaction management, serving instead as a foundational component for systems like Milvus or Pinecone. Graph-based indices (HNSW), while fast, suffer from high memory overhead. Future work focuses on supporting associative vector memories in transformer architectures and further optimizing for emerging hardware.

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 Maria Lomeli and Lucas Hosseini and Hervé Jégou},
  title = {{The Faiss library}},
  journal = {IEEE Transactions on Big Data},
  year = {2025},
  doi = {10.1109/tbdata.2025.3618474},
}
Figure