Back to explorer
Databases & Storage 5 Min

Vector Databases

MEDIUM

Vector Databases (LLM Search & Retrieval)

Vector databases store, index, and query high-dimensional vector embeddings generated by machine learning models.


1. Key Concepts

Traditional databases index text fields literally. Vector databases represent text semantically as arrays of floats (embeddings) and query using vector distance metrics:

code
Distance calculations: Cosine Similarity, Euclidean Distance (L2), Dot Product

Search Algorithms (ANN)

To find matches within milliseconds across billions of high-dimensional vectors, databases use Approximate Nearest Neighbor (ANN) indices:

  • HNSW (Hierarchical Navigable Small World): A multi-layered graph representation offering fast logarithmic searches.
  • IVF (Inverted File): Clusters vectors into subsets using k-means, querying only the closest centroids.
  • PQ (Product Quantization): Compresses vector footprints to fit inside RAM.

2. Dynamic Retrieval-Augmented Generation (RAG)

Clients generate vector query embeddings using OpenAI/Cohere APIs, query the vector database for matching context indices, and append the results to LLM system prompts.


3. References & Tech Blogs

Capacity Calculator

Estimate QPS, bandwidth, and database sizing in real time based on active users and payload characteristics.

Daily Active Users (DAU)10M
Read Ratio vs Write Ratio90% / 10%
Payload Size (Bytes)500 B
Average Read QPS:521
Average Write QPS:58
Total Request QPS:579 req/s
Write Bandwidth:0.03 MB/s
Read Bandwidth:0.50 MB/s
Storage / Year:913 GB/yr