Glossary
FAISS
FAISS is Meta's open-source library for fast nearest-neighbour search over dense vectors, with exact and compressed approximate indexes on CPU and GPU.
FAISS (Facebook AI Similarity Search) is an open-source library for finding the nearest neighbours of a vector among millions or billions of other vectors. It was released by Meta's AI research group in 2017, is written in C++ with Python bindings, and runs on CPUs and NVIDIA GPUs. FAISS gives you a set of index types, from exact brute-force search to heavily compressed approximate indexes, and lets you combine them. It is a library rather than a database: it holds vectors in memory and answers similarity queries, while storage, metadata, access control, updates and serving are left to the application around it. Many vector databases and search tools either use FAISS internally or borrow its index designs.
The problem FAISS solves
An embedding model turns text, images or audio into vectors, and similar items end up close together. Finding the items most similar to a query means finding the vectors closest to the query vector, which is k-nearest neighbors search. Done exactly, that means comparing the query with every stored vector. With 10 million vectors of 768 dimensions, one query is about 7.7 billion multiply-add operations. That is fine for an offline job and too slow for an interactive search box that has to answer in a few milliseconds.
FAISS addresses this in two ways. It makes exact search as fast as the hardware allows, using optimised matrix routines and GPU kernels. And it provides approximate nearest neighbor indexes that skip most of the comparisons, trading a little recall for large gains in speed and memory.
How FAISS works
Every FAISS index exposes the same small interface. You train it if the index type needs training, add vectors, then search with a batch of query vectors and a value of k. The search returns two arrays: the distances and the integer IDs of the k closest vectors for each query. IDs are positions by default, and wrapping an index in an ID map lets you attach your own 64-bit IDs.
Distances come in two main flavours. L2 is squared Euclidean distance. Inner product is the dot product, and if every vector is normalised to unit length first, inner product gives the same ranking as cosine similarity. Choosing the metric that matches how the embedding model was trained matters more than most index settings.
The main index types
Flat indexes. A flat index stores the raw vectors and compares the query with all of them. Results are exact, there is no training, and memory is four bytes per dimension per vector. Flat search is the baseline every other index is measured against, and on a GPU it is fast enough for collections of a few million vectors.
IVF indexes. An IVF index clusters the vectors around a set of centroids learned with k-means, and at query time scans only the lists for the few closest centroids. Two settings control it: the number of clusters, fixed at training time, and the number of clusters probed per query, which can be changed on every search.
HNSW indexes. HNSW builds a layered graph in which each vector links to its near neighbours, and a search walks the graph towards the query. It gives high recall at low latency, needs no training, and uses more memory because the graph links are stored alongside the vectors.
Product quantisation. Product quantization splits each vector into sub-vectors and replaces each piece with the ID of the nearest entry in a small learned codebook. A 768-dimension float vector that takes 3,072 bytes can be stored in 64 or 96 bytes. Distances become approximate, but memory falls by an order of magnitude or more. FAISS also offers scalar quantisation to 8 or 4 bits per dimension, and binary quantization style indexes that use Hamming distance.
These pieces compose. The most common large-scale design is IVF combined with product quantisation, often with a rotation applied first so the sub-vectors carry roughly equal information. FAISS describes such combinations with a short factory string, so “IVF4096,PQ64” means 4,096 clusters with 64-byte codes. Experimenting with index designs is a matter of changing that string and measuring the result.
A worked example
A research team wants to search 20 million paper abstracts embedded at 768 dimensions. Stored flat, the vectors take about 61 GB, which does not fit on their search machine, and an exact query takes several hundred milliseconds on CPU.
They build a ground truth first: 2,000 sample queries with their true top 10 neighbours, computed once with a flat index on a GPU. Then they try candidates. An HNSW index reaches 0.97 recall at 10 in about 2 ms but needs more than 70 GB with the graph. An IVF index with 16,384 clusters and 64-byte product-quantised codes fits in about 1.5 GB, and probing 64 clusters gives 0.86 recall at 10 in about 3 ms. Adding a re-ranking step, which fetches the top 100 candidates and rescores them against the full vectors kept on disk, lifts recall to 0.95.
The design they ship is the compressed IVF index plus re-ranking. None of these numbers are universal, and the point of the exercise is the method: a flat ground truth, a recall target, and a sweep over index settings measured against both.
What FAISS does not do
FAISS is deliberately narrow, and most of the work in a production system sits outside it.
Storage and durability. An index lives in memory. You can write it to a file and read it back, but there is no transaction log, replication or crash recovery. If the process dies, the index is whatever you last saved.
Metadata and filtering. FAISS stores vectors and integer IDs, nothing else. Titles, authors, tenant IDs and timestamps live in another store. FAISS can restrict a search to a set of allowed IDs, but metadata filtering of the kind a product needs (“only this customer’s documents from the last 90 days”) has to be built by the application, and filters that remove most of the collection interact badly with approximate indexes.
Updates and deletes. Adding vectors is easy. Removing or changing them is supported by some index types and awkward or slow in others, and IVF indexes drift as the data changes until the centroids are retrained. Teams with frequently changing data usually rebuild indexes on a schedule.
Text, keywords and documents. FAISS knows nothing about the content behind a vector. There is no tokeniser, no BM25, no hybrid search, no chunking, and no idea which page of which PDF a vector came from. Getting from a file to a vector, and from a result ID back to a cited passage, is the application’s job.
Serving. There is no network API, authentication or multi-tenancy. To serve queries you wrap FAISS in your own service, or use a vector database that does it for you.
FAISS compared with a vector database
Concern | FAISS | Typical vector database |
|---|---|---|
What it is | C++ and Python library | Server or managed service |
Index types | Flat, IVF, HNSW, PQ, SQ, LSH and combinations | Usually HNSW, sometimes IVF or disk-based indexes |
GPU search | Yes, a core strength | Varies by product |
Persistence | Save and load index files | Durable storage, replication, backups |
Metadata filtering | Allowed-ID lists only | Filters on stored fields |
Updates and deletes | Depends on index type | Supported as normal operations |
Keyword and hybrid search | No | Often included |
Access control and tenants | No | Usually included |
The difference is the same as between a sorting algorithm and a database table. FAISS is the right tool when you control the whole pipeline and need the fastest or most compact nearest-neighbour search: offline deduplication, clustering, recommendation candidate generation, research benchmarks, or as the index inside a larger system. A vector store or database is the better fit when the vectors belong to an application with users, permissions and changing data. The best vector databases roundup compares the main options, and pages such as Pinecone alternatives and Milvus alternatives cover specific products, some of which use FAISS-style indexes internally.
Choosing and tuning a FAISS index
Start with the size of the collection and the memory you have. Under a million vectors, a flat index is often good enough and removes every tuning question. Up to tens of millions with ample memory, HNSW is the usual choice for low-latency search. Beyond that, or when memory is tight, IVF with product or scalar quantisation is the standard design, with re-ranking if recall matters.
Then measure. Build an exact ground truth with a flat index on a sample of real queries, pick a recall target such as 0.95 at 10, and sweep the settings that trade speed for accuracy: probes for IVF, search depth for HNSW, code size for PQ. Plot recall against latency and pick the cheapest point that meets the target. Embedding dimensions matter here too, because halving the dimensions halves memory and compute; dimensionality reduction or a model with shorter outputs is sometimes a better lever than index tuning.
Finally, plan for change. Decide how new vectors are added, how deletes are handled, how often IVF centroids are retrained, and how the index file is rebuilt and swapped without downtime. These operational questions take more engineering time than choosing the index.
How FAISS relates to retrieval quality
FAISS answers one question well: which stored vectors are closest to this query vector. It does not decide whether those vectors are the right answer. In a RAG pipeline, most wrong answers come from earlier and later stages: chunks that split the answer in two, an embedding model that does not separate near-duplicates, queries that need exact terms, or a top-k cut-off that returns related but unhelpful passages. As a corpus grows, many results start to look equally plausible, which is the effect described in semantic collapse. A perfect nearest-neighbour index does not fix any of these. Reranking, hybrid retrieval and passage-level matching are the usual remedies, and RAG accuracy covers them in more detail.
Where Exabase fits
Exabase is not a FAISS replacement, and it does not expose index types, metrics or quantisation settings. It sits a level above, at the point where FAISS stops. Files, notes, bookmarks, audio and video stored as Resources are extracted and indexed automatically, and Deep Search returns the matching passage with its page number, the timestamp in a recording, or the scene in a video. Text queries combine semantic search with typo-tolerant keyword matching, filters cover folders, tags, resource types and dates, and a single precision parameter between 0 and 1 controls how broad or strict the results are.
Each Base is an isolated environment with its own storage and index, so per-customer separation does not depend on filters inside a shared index; the multi-tenant page explains the model. Teams that need control over index internals, or that are running offline vector jobs, are well served by FAISS or a dedicated engine. Teams that want to store content and query it without building ingestion, chunking and citation logic can use the searching resources guide and the search endpoint reference. Exabase vs pgvector and How we index millions of files without an embedding pipeline describe the difference in approach, and the RAG pipelines use case shows it in an application.
Frequently asked questions
What does FAISS stand for?
FAISS stands for Facebook AI Similarity Search. It was developed by Meta’s AI research group and released as open source in 2017.
Is FAISS a vector database?
No. FAISS is a library for building and searching vector indexes in memory. It has no server, durable storage, metadata store or access control, which a vector database provides.
Is FAISS free to use?
Yes. FAISS is open source under the MIT licence and can be used in commercial products.
Does FAISS support cosine similarity?
Yes, indirectly. Normalise every vector to unit length and use an inner-product index; the ranking is then identical to cosine similarity.
Which FAISS index should I use?
Use a flat index for small collections or exact results, HNSW for low-latency search when memory allows, and IVF with product quantisation for very large collections or tight memory. Measure recall against a flat ground truth before choosing.
Can FAISS filter by metadata?
Only partly. FAISS can restrict a search to a set of allowed IDs, but storing and evaluating metadata such as tenants or dates is left to the application. Filters that exclude most of the collection also reduce recall in approximate indexes.
Does FAISS run on GPUs?
Yes. GPU support for NVIDIA cards is one of its main strengths, and many index types, including flat and IVF indexes, can be built and searched on GPU.
Do I need FAISS to use Exabase?
No. Exabase indexes stored content automatically and Deep Search handles retrieval, so there is no index to build or tune.
Related pages: IVF index, HNSW, Product quantization, Vector quantization, Approximate nearest neighbor search, Vector index, Vector search, Dense vectors, Best vector databases, RAG accuracy