Vector Database
A type of database that stores and indexes data as high-dimensional vectors (embeddings).
Detailed Explanation
Vector databases (like Pinecone or Milvus) are essential for AI and Machine Learning applications. They allow for 'Similarity Search' rather than exact keyword matching. For example, they can find images that 'look like' a target image or text that is 'semantically similar' to a query. This is the technology powering recommendation engines and LLM memory (RAG).
Quick Summary
A vector database indexes embeddings so you can find "things like this" by semantic similarity, not just exact match. It's the storage layer behind RAG, recommendation engines, and modern semantic search.
Key Takeaways
- Documents are converted to vectors via an embedding model (OpenAI, Cohere, open-source like BGE/E5).
- Common index types: HNSW (graph-based, fast), IVF (cluster-based), DiskANN. They trade speed for accuracy.
- Similarity metrics: cosine (most common for text), dot product, Euclidean.
- Almost always paired with metadata filtering, "find similar docs but only from this customer."
- PostgreSQL with pgvector is often enough for under ~10M vectors; dedicated systems (Pinecone, Weaviate, Qdrant, Milvus) take over at higher scale.
When to use it
- Retrieval-Augmented Generation (RAG) for LLM apps that need to ground answers in your data.
- Semantic search over documents, support tickets, or product catalogs.
- Recommendation: "users who like X also liked" via item embeddings.
- Deduplication and clustering across large unstructured corpora.
Common Mistakes
- Embedding-model mismatch: changing the model invalidates every existing vector (different vector space).
- Skipping metadata filters, semantic search alone often returns plausible-but-wrong matches across tenants.
- Treating vector DB as the source of truth; keep the original document elsewhere and re-embed on demand.
- Picking a hosted vector DB before measuring whether pgvector would have been enough, vendor lock-in for low ROI.
Vector Database, Frequently Asked
Do I need a dedicated vector database?
Not until pgvector hits its limits, which is later than most people expect, millions of vectors with HNSW indexing perform well. Move to a dedicated system when you need very low p99 latency at high QPS, multi-tenant isolation at scale, or specialized filtering.
How big should chunks be for RAG?
Typically 200–1000 tokens with some overlap. Smaller chunks are more precise but lose context; larger chunks carry more context but dilute the embedding signal. Always test retrieval quality with real queries rather than relying on defaults.