← Lessons

quiz vs the machine

Gold1450

Databases

The Vector Database for Embeddings

Storing high dimensional vectors and finding the nearest ones fast.

5 min read · core · beat Gold to climb

The Vector Database for Embeddings

A vector database stores embeddings, which are lists of numbers that capture the meaning of text, images, or audio. Two items with similar meaning have vectors that point in similar directions, so search becomes finding the vectors closest to a query vector.

Similarity search

The core operation is nearest neighbor search: given a query vector, return the stored vectors with the smallest distance. Distance is often cosine similarity or Euclidean distance. An exact search compares the query to every vector, which is too slow at scale.

Approximate nearest neighbor

To go fast, vector databases use approximate nearest neighbor or ANN indexes. A popular one is a navigable small world graph, which links each vector to a few neighbors and lets search hop greedily toward the closest match.

  • ANN trades a little recall for huge speed gains.
  • Indexes are tuned with parameters that balance accuracy and latency.
  • Results often feed a language model in a retrieval pattern.

Key idea

A vector database indexes embeddings so a query finds its nearest neighbors quickly, usually through approximate search that trades slight recall for speed.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a vector database primarily search for?

2. What does approximate nearest neighbor search trade away?