EMZETT.
Login

Vector databases and similarity search

In short: A vector database stores embeddings and quickly finds the ones most similar to a query. It is the memory behind semantic search and RAG.

In more detail: Texts, images or products are turned into vectors with an embedding model (see Embedding (vector representation)). Similar meaning means small distance. The database searches for the “nearest neighbours”.

In detail

  • Similarity: cosine similarity or dot product (the larger, the more similar), sometimes Euclidean distance.
  • Exact search: compare all vectors. Too slow for millions.
  • Approximate search (ANN): fast with slight inaccuracy. HNSW (layered graph), IVF (clusters), product quantisation (compression).
  • Systems: pgvector (PostgreSQL), Qdrant, Weaviate, Milvus, Pinecone, FAISS (library), SQLite extensions.
  • Metadata filters: “only documents from 2024 and language de” combined with similarity.
  • Chunking: split long documents into sections (200–1000 tokens), each gets a vector.
  • Hybrid search: combine keyword search (BM25) and vector search, then a reranker.
  • Quality: depends strongly on the embedding model and the chunks.

See also: Retrieval-augmented generation (RAG), Embedding (vector representation)