Vector Databases

Vector databases are specialized data stores designed to handle high-dimensional vector representations—typically generated from embeddings—and enable efficient similarity search at scale.

Purpose

Traditional databases are inefficient for similarity-based search (e.g., find documents similar to this one”). Vector DBs solve this by indexing dense vectors and optimizing for Approximate Nearest Neighbor (ANN) retrieval.

Core Features

  • Indexing Methods:
    • HNSW (Hierarchical Navigable Small World)
    • IVF (Inverted File Index)
    • PQ (Product Quantization)
    • Flat (brute force, for small datasets)
  • Similarity Metrics:
    • Cosine Similarity
    • Euclidean Distance
    • Dot Product
  • Operations:
    • Insert / upsert vectors
    • Search (KNN queries)
    • Delete / update vectors
    • Metadata filtering

Use Cases

  • RAG (Retrieval-Augmented Generation)
  • Semantic Search / Q&A
  • Recommendation Systems
  • Anomaly Detection
  • Clustering and Classification
  • Pinecone — Scalable managed vector DB with filtering and namespaces
  • Weaviate — Open source, schema-based with hybrid search
  • Qdrant — Rust-based with strong filtering support
  • Chroma — Local-first, easy to use for prototyping
  • FAISS — Facebook’s ANN library (not a DB but often used as backend)

Considerations

  • Embedding model and dimensionality must be consistent across insert/search.
  • Choose index type based on dataset size and performance needs.
  • Normalize vectors if using cosine similarity.

Example Flow

  1. Generate embeddings for a corpus
  2. Store vectors in DB alongside metadata
  3. At query time, embed the query
  4. Search the DB for top K nearest vectors
  5. Use results in your application (e.g., LLM context)