Definition

A vector database is a database system built to store, index and search vector data. The “vectors” here are usually lists of numbers produced by an embedding model from text, images or audio, representing what that content means.

Traditional databases excel at exact matching: find the record with this ID, or titles containing this keyword. Vector databases excel at similarity matching: given a vector, find the closest vectors in the collection, meaning the most semantically similar content. Even with completely different wording, like “how do I return this” and “refund request process,” the match can still be found.

How It Works

Using a vector database involves three stages:

Ingest. Split documents into chunks, turn each into a vector with an embedding model, and store it alongside the original text and metadata such as source, date and permissions.

Index. Comparing a query against every stored vector (brute-force search) gets very slow at scale. So vector databases build approximate nearest neighbor (ANN) indexes, trading a little accuracy for a big speedup. Common index types:

  • HNSW: builds a multi-layer proximity graph; queries start coarse at the top and refine layer by layer.
  • IVF: clusters vectors in advance, and queries search only the most relevant clusters.
  • Product quantization (PQ): compresses vectors into shorter codes, saving memory and speeding up comparisons.

Query. Turn the user’s question into a vector with the same embedding model, then find the K nearest results in the index. “Nearness” is usually measured by cosine similarity, dot product or Euclidean distance. Many systems also support metadata filtering alongside similarity search, such as “only documents from a certain team, published after a certain date.”

Besides dedicated vector database products, many traditional databases and search engines have added vector search, such as the pgvector extension for PostgreSQL. There are also embeddable libraries like FAISS. When choosing, weigh data volume, query latency, filtering needs and operational overhead.

Typical Applications

  • Retrieval-augmented generation (RAG): retrieving relevant passages for an LLM.
  • Semantic search: finding documents, products or Q&A by meaning, not literal keywords.
  • Recommendations: surfacing items similar to a user’s interests or current content.
  • Image and audio similarity search: finding near matches in media libraries.
  • Deduplication and clustering: spotting near-duplicate articles or tickets.
  • Long-term memory: letting AI agents store and recall past information.
  • Embedding: where the stored vectors come from.
  • RAG: one of the most common uses of vector databases.
  • Semantic similarity: the measure of how close two vectors are.
  • Keyword search (e.g. BM25): often combined with vector search as hybrid retrieval.

References: HNSW paper, FAISS (GitHub), pgvector (GitHub)