Repolode
facebookresearch

facebookresearch/faiss

A C++ library with Python bindings for efficient similarity search and clustering of dense vectors, with optional GPU acceleration.

Stars
41,171
Forks
4,561
Open issues
352
Last commit
11 hours ago

What is it?

Faiss is a library for similarity search and clustering of dense vectors. It provides indexes that search sets of vectors ranging from small collections up to ones too large to fit in RAM. Comparisons use L2 distance or dot product, and cosine similarity is supported through normalized vectors.

Index types trade off search speed, result quality, memory per vector, and training or insertion time. Compressed representations such as binary vectors and quantization codes avoid storing original vectors and can scale to billions of vectors on a single server. Graph-based structures like HNSW and NSG add an index on top of raw vectors for faster queries.

The library is written in C++ with Python and numpy wrappers. GPU implementations accept CPU or GPU input, support single and multi-GPU setups, and can be swapped in for CPU indexes such as IndexFlatL2 by replacing them with GpuIndexFlatL2. Building requires CMake and a BLAS implementation.

Key features

  • 01Exact and approximate nearest neighbor search over dense vectors with L2 or dot-product metrics.
  • 02Compressed indexes based on binary vectors and quantization codes that scale to very large collections.
  • 03Graph-based indexes such as HNSW and NSG for faster approximate search.
  • 04Optional GPU implementations that work as drop-in replacements for CPU indexes.
  • 05Python wrappers with numpy support alongside the C++ core.

Use cases

  • Building semantic search or retrieval over embedding vectors.
  • Running nearest-neighbor lookups on collections too large for memory using compressed indexes.
  • Clustering large sets of vectors with GPU-accelerated k-means.

Quick start

  1. 1

    Install the precompiled faiss-cpu package for Python from Anaconda

  2. 2

    Read the getting-started tutorial on the project wiki

Things to know

  • GPU acceleration requires NVIDIA CUDA or AMD ROCm hardware.
  • Building from source needs cmake and a BLAS implementation; see INSTALL.md.

Topics

FAQ

What is faiss?
A C++ library with Python bindings for efficient similarity search and clustering of dense vectors, with optional GPU acceleration. Faiss is a library for similarity search and clustering of dense vectors. It provides indexes that search sets of vectors ranging from small collections up to ones too large to fit in RAM. Comparisons use L2 distance or dot product, and cosine similarity is supported through normalized vectors.
Is faiss free to use? What license does it have?
faiss is open source under the MIT license. Check the license terms before using it in commercial products.
Is faiss still maintained?
Actively maintained. The last commit to faiss was on Oct 20, 2026.
What can I use faiss for?
Building semantic search or retrieval over embedding vectors. Running nearest-neighbor lookups on collections too large for memory using compressed indexes. Clustering large sets of vectors with GPU-accelerated k-means.
How do I install faiss?
Install the precompiled faiss-cpu package for Python from Anaconda Read the getting-started tutorial on the project wiki
Where can I get faiss?
The source code and installation instructions are on GitHub: https://github.com/facebookresearch/faiss

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects