Notes

Faiss

Once your documents are embeddings, finding the relevant ones means finding the nearest vectors — and comparing a query against ten million of them one at a time is not a plan. Faiss, short for Facebook AI Similarity Search, is the library that makes that search fast enough to sit inside a request.

How it buys speed

Faiss is a toolkit of index structures, each a different bargain between recall, memory and latency. A flat index compares against everything and is exact. An IVF index clusters the vectors first and scans only the nearest clusters. HNSW builds a navigable graph and walks it. Product quantization compresses each vector to a few bytes so a billion of them fit in RAM, at some cost in precision. Search-time parameters move you along that curve, and the GPU indexes push the whole search onto the device.

What it is not
  • A library, not a database: no server, no metadata filtering, no replication, and persistence means writing the index to a file yourself.
  • Awkward to update — most index types expect to be trained on a representative sample and rebuilt rather than edited incrementally.
Where it fits in a RAG stack

That trade is why Faiss is the default for local and embedded retrieval — the vector store behind a LangChain or LlamaIndex prototype on a laptop — while managed systems like Milvus or Pinecone take over when you need filtering, multi-tenancy and uptime. Several of them run the same family of algorithms underneath.

Faiss is Meta's open-source library for similarity search over dense vectors — the component that finds the nearest embeddings to a query among millions or billions. It offers exact and approximate indexes, including IVF, HNSW and product quantization, on CPU and GPU, trading recall against memory and latency. It is the retrieval engine inside many RAG systems and under several vector databases, but it is a library, not a managed store.

Suppose every document you own has been turned into a point on a huge invisible map, where things that mean similar things sit close together. To answer a question, you need the handful of points nearest to it. Checking every point one by one would take forever. Faiss is a free tool from Meta that organises that map in advance — a bit like the index at the back of a book — so the nearest neighbours can be found in a blink. It is the part that lets an AI assistant pull the three relevant pages out of your company's files before it answers you.