← Blog

Evaluating language models

What is FAISS? Full form, index types, and is it a vector database

FAISS stands for Facebook AI Similarity Search. It is a vector search library from Meta, not a vector database. Index types, lookups, and memory.

Oct 12, 2026 · Updated Nov 9, 20266 min read13 sources

Why it matters

Retrieval decides which passages a system answers from, and a recall figure shows how well an index matches exact search, not whether it found the right page.

The short version

  1. 1FAISS stands for Facebook AI Similarity Search. Meta's FAIR group builds it as an open-source C++ library with Python wrappers.
  2. 2FAISS is not a vector database. Its own paper says it has no concurrent writes, sharding, transactions, or query optimization, and it does not store metadata.
  3. 3Only IndexFlatL2 and IndexFlatIP give exact results. Every other index trades some accuracy for speed or memory, and recall only measures agreement with exact search.

FAISS stands for Facebook AI Similarity Search (Meta AI, Faiss). FAISS is not a vector database. The project's own paper says it is a library, not a database and not a service (Faiss paper, Introduction).

In plain terms, FAISS finds the stored vectors closest to a query vector, fast. Meta's Fundamental AI Research (FAIR) group develops it in C++ with Python wrappers, and some algorithms run on a graphics processing unit (GPU) (README). The project writes the name "Faiss"; searchers usually type FAISS. Same thing.

What does FAISS stand for

Facebook AI Similarity Search. Meta announced the release under that name on March 29, 2017 (Engineering at Meta). If you searched "FAISS full form," that is the answer. The company is now Meta, but the name stayed.

Is FAISS a vector database

No. The Faiss paper lists what FAISS is not:

QuestionAnswer from the Faiss paper
Does it create embeddings?No. It only indexes vectors made by another model.
Is it a service or server?No. It runs as functions inside your own process.
Is it a database?No concurrent writes, load balancing, sharding, transactions, or query optimization.
Does it store metadata?No arbitrary metadata. Filtering uses a callback on each vector id.
Where does the index live?In RAM, for every index type (guidelines).

The paper calls vector similarity search "a core functionality of vector databases." It says FAISS is built to run from a simple script or as a building block inside a database system. Major vector database companies, such as Zilliz and Pinecone, either run on FAISS or reimplemented its algorithms, per the same paper.

So "FAISS DB" is a search engine without the database around it. Pick FAISS when you control the process and the data fits in memory. Pick a vector database when you need many writers, a network API, access control, or metadata filters.

What is FAISS used for

FAISS answers one question: which stored vectors are nearest this one? The FAISS docs put it as building a data structure in RAM from a set of vectors, then finding the nearest one to a new vector.

The workflow:

  1. Turn your items (passages, images, products) into embedding vectors with a separate model. FAISS does not do this step.
  2. Build a FAISS index for that vector dimension.
  3. Add the vectors.
  4. Search with a query vector and get back the ids of the nearest items.

That pattern powers semantic search and retrieval for question answering. For the embedding step, see what an embedding model is.

How a FAISS index lookup works

The Getting started page shows the whole loop:

import faiss
index = faiss.IndexFlatL2(d)   # d = vector dimension
index.add(xb)                  # database vectors
D, I = index.search(xq, k)     # k nearest neighbors per query
  • I is an nq by k matrix. Row i holds the ids of the k nearest vectors to query i, sorted by increasing distance.
  • D holds the matching squared distances.
  • index.is_trained says whether the index needs training before add. Flat indexes skip training.

Two details trip people up. FAISS reports squared L2 distance, not the square root (MetricType and distances). For cosine similarity, normalize the query and database vectors (faiss.normalize_L2) and use an inner-product index.

The ids are plain integers. Your code has to map each id back to a passage, page, and file.

FAISS index types

The Faiss indexes page lists the main classes. Here d is the vector dimension and M is links (HNSW) or sub-quantizers (PQ).

IndexFactory stringExact?Training?Bytes per vector
IndexFlatL2 / IndexFlatIPFlatExactNo4 * d
IndexHNSWFlatHNSW,FlatApproximateNo4 * d + x * M * 2 * 4
IndexIVFFlatIVFx,FlatApproximateYes4 * d + 8
IndexScalarQuantizerSQ8ApproximateNot statedd
IndexPQPQxApproximateYesceil(M * nbits / 8)
IndexIVFPQIVFx,PQyApproximateYesceil(M * nbits / 8) + 8
IndexLSHnoneApproximateYesceil(nbits / 8)

The guidelines say only IndexFlatL2 and IndexFlatIP guarantee exact results. HNSW needs no training. The wiki notes the flat inner-product index is also the one for cosine, with normalized vectors.

A 768-dimension embedding stored flat takes 4 times 768, or 3,072 bytes. One million of them take about 3 GB of RAM before any overhead.

How IVF trades speed for accuracy

An inverted file (IVF) index splits the space into nlist cells and searches only nprobe of them per query (Faster search). The default nprobe is 1. Raising it improves accuracy, and search time grows roughly linearly with it. Setting nprobe equal to nlist gives the brute-force result, only slower.

Which FAISS index to choose

From the guidelines:

  1. Only 1,000 to 10,000 searches planned? Use Flat. Building a faster index will not pay off.
  2. Need exact results? Use Flat.
  3. Plenty of RAM or a small dataset? Use HNSW, such as HNSW32, with M links per vector from 4 to 64. Higher M is more accurate and uses more RAM.
  4. Memory tight? Compress with an OPQ transform plus product quantization (PQ), which stores M bytes per vector. For maximum compression, RaBitQ stores d/8 + 8 bytes.
  5. Using IVF on under 1 million vectors? Set the number of cells K to 4 to 16 times the square root of the dataset size. Train on 30 times K to 256 times K vectors.

Need add_with_ids on a flat or HNSW index? Wrap it as IDMap,Flat or prefix IDMap.

FAISS library: install and GPU

FAISS installs through conda from the pytorch channel (INSTALL.md):

PackageWhat you getPlatforms
faiss-cpuCPU indexesLinux, macOS arm64, Windows
faiss-gpuCPU and GPU indexesLinux x86-64, CUDA 11.4 and 12.1
faiss-gpu-cuvsGPU indexes from NVIDIA cuVSLinux x86-64, CUDA 13.2

On the GPU, IndexFlat, IndexIVFFlat, IndexIVFScalarQuantizer, and IndexIVFPQ are implemented. k and nprobe must be 2048 or less (Faiss on the GPU). The 2017 GPU paper reported nearest-neighbor search 8.5 times faster than the prior GPU state of the art (Johnson, Douze, and Jegou). A GPU changes speed, not exactness.

What recall means for a FAISS index

The Faiss paper measures accuracy as n-recall@k: the share of the n true nearest neighbors found in the top k results (Faiss paper). That compares the index with exact search. A recall figure means little without the index type, nprobe, the dataset, and k.

Recall does not tell you whether the nearest passage answers the question. That depends on the embeddings. Measure it separately against passages a person marked relevant; see retrieval metrics.

What to do next

  • Start with IndexFlatL2 or IndexFlatIP as your exact baseline.
  • Normalize vectors before using inner product for cosine similarity.
  • Estimate RAM as 4 times d bytes per vector for flat storage, then switch to a PQ-compressed index if it does not fit.
  • Keep a table that maps every FAISS id to its passage, page, and file.
  • Report recall at a stated k and nprobe against flat search, and test relevance separately.
  • Need many writers, a server, or metadata filters? Put a vector database around FAISS or use one.

Azcuna's BABEL reads, translates, and searches foreign-language documents entirely on-device, with no cloud and no connection, and keeps every claim tied to the passage it came from. The long read on air-gapped RAG goes further.

Questions people ask

What does FAISS stand for?

FAISS stands for Facebook AI Similarity Search. Meta's AI tools page and the March 29, 2017 Engineering at Meta post that announced the release both give that full form. The project itself writes the name as Faiss. It is developed mainly at FAIR, Meta's Fundamental AI Research group.

Is FAISS a vector database?

No. The Faiss paper says Faiss is not a database because it does not provide concurrent write access, load balancing, sharding, transaction management, or query optimization. It is also not a service: it runs inside your own process. The paper adds that Faiss does not store arbitrary metadata with vectors. Vector databases use libraries like Faiss as their search engine and add the database layers around it.

What is FAISS used for?

Finding the stored vectors closest to a query vector, fast, at scale. You turn text, images, or other items into embedding vectors with a separate model, add them to a Faiss index, and search it for nearest neighbors. Common uses are semantic search, retrieval for question answering, deduplication, recommendation, and clustering. The project README calls it a library for similarity search and clustering of dense vectors.

What is a FAISS index?

An index is the Faiss object that stores your vectors and answers nearest-neighbor searches. You build it for a fixed dimension, train it if the type requires training, add vectors, then call search. Types range from IndexFlatL2, which compares every vector exactly, to IVF, HNSW, and product quantization indexes, which are approximate. The Faiss guidelines say all Faiss indexes are stored in RAM.

How does a FAISS index lookup work?

You call D, I = index.search(xq, k). For nq query vectors, Faiss returns two nq by k matrices. I holds the ids of the k nearest stored vectors for each query, sorted by increasing distance. D holds the matching squared distances. The ids are integers, so your own code must map each id back to its passage, page, or file.

Which FAISS index should I use?

The Faiss guidelines say use a flat index if you need exact results or plan only about 1,000 to 10,000 searches. If you have plenty of RAM or a small dataset, HNSW is the best option. If memory is tight, compress the vectors with product quantization. For IVF, set the number of cells to 4 to 16 times the square root of your dataset size.

Does FAISS run on a GPU?

Yes, for some index types. The Faiss GPU wiki page lists IndexFlat, IndexIVFFlat, IndexIVFScalarQuantizer, and IndexIVFPQ as implemented on the GPU, and k and nprobe must be 2048 or less. The 2017 GPU paper by Johnson, Douze, and Jegou reported nearest-neighbor search 8.5 times faster than the prior GPU state of the art.

Sources

  1. 1Faiss (Facebook AI Similarity Search) · Meta AI
  2. 2Faiss: A library for efficient similarity search (March 29, 2017) · Engineering at Meta
  3. 3The Faiss library · arXiv (Douze et al.)
  4. 4Billion-scale similarity search with GPUs · arXiv (Johnson, Douze, and Jegou)
  5. 5facebookresearch/faiss README · Faiss project (facebookresearch/faiss)
  6. 6Installing Faiss via conda · Faiss project (facebookresearch/faiss)
  7. 7Faiss indexes · Faiss project wiki (facebookresearch/faiss)
  8. 8Getting started · Faiss project wiki (facebookresearch/faiss)
  9. 9Guidelines to choose an index · Faiss project wiki (facebookresearch/faiss)
  10. 10Faster search · Faiss project wiki (facebookresearch/faiss)
  11. 11Faiss on the GPU · Faiss project wiki (facebookresearch/faiss)
  12. 12MetricType and distances · Faiss project wiki (facebookresearch/faiss)
  13. 13Faiss documentation · Faiss project

Where this shows up in our work

More on evaluating language models