# FAISS (Facebook AI Similarity Search)

> A free code tool for fast vector search. It goes inside your own program.

**Field:** Artificial Intelligence  
**Category:** Retrieval & Search  
**Also known as:** FAISS, Faiss Library

## Think of it like

It is like a very fast sorting machine. It is a part you build into your own shop, not a shop.

## Definition

FAISS is a free code library for finding similar vectors fast. It is a part you build into your own program, not a database server. It holds the vectors in memory and offers many kinds of index, from exact to very fast and rough. It is written in C++, can be used from Python and can run on graphics cards. Meta's AI research group builds it. Many vector databases started out on ideas like it.

## Example

A research team searches 100 million image vectors. They load them into a FAISS index on one graphics card and get the closest ten in milliseconds.

## Example code

```python
import faiss
index = faiss.IndexFlatL2(384)
index.add(vectors)
distances, ids = index.search(query, 5)
```

An exact index for 384-number vectors, then a search for the 5 closest.

## Why it matters

It gives top search speed with no server to run. It is a common choice for research and big offline jobs.

## Common mistake

Treating it as a database. It has no users, no backups and no filters out of the box, so you build those yourself.

## Three principles

- **A library.** Lives inside your program.
- **Many index types.** Exact, or fast and rough.
- **Graphics card ready.** Huge searches in milliseconds.

## Related terms

- [Vector Index](https://learn.benibix.com/term/ai/vector-index)
- [Approximate Nearest Neighbor (ANN)](https://learn.benibix.com/term/ai/approximate-nearest-neighbor)
- [Vector Database](https://learn.benibix.com/term/ai/vector-database)
- [Nearest Neighbor Search](https://learn.benibix.com/term/ai/nearest-neighbor-search)
- [Hierarchical Navigable Small World (HNSW)](https://learn.benibix.com/term/ai/hierarchical-navigable-small-world)

## Told apart from

- [FAISS vs Vector Database](https://learn.benibix.com/compare/faiss-vs-vector-database): People think FAISS is a vector database, and it is not. FAISS is a library: the fast search part, built into your own program. A vector database is a whole system around that part. It adds storage, updates, filters, backups and users. Pick FAISS to build it yourself, and a database to have it done.

![Four columns, from you build more to you run less. A library inside your program: FAISS. An add-on in a database you run: pgvector. A vector database, open source, to run or rent: Chroma, Qdrant and Weaviate. A hosted service you rent: Pinecone.](https://learn.benibix.com/diagrams/ai3-vector-stores.svg)

---

Source: https://learn.benibix.com/term/ai/faiss
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
