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
Popular Tools
- 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
- Generate embeddings for a corpus
- Store vectors in DB alongside metadata
- At query time, embed the query
- Search the DB for top K nearest vectors
- Use results in your application (e.g., LLM context)
Related Notes
- Embeddings
- Semantic Search
- RAG (Retrieval-Augmented Generation)
- Cosine Similarity
- LLM Infrastructure
Embeddings
are numerical vector representations of data—commonly text, but also images, code, etc.—that encode semantic meaning in a way machines
Top-K Retrieval
Top-K retrieval refers to the process of returning the K most relevant or closest results from a dataset in response to a query. In vector search
Approximate Nearest Neighbors (ANN)
is a class of algorithms designed to efficiently retrieve vectors that are close to a query vector in
AI Engineer
AI vs AGI LLMs Inference Training Embeddings Vector Databases AI Agents Roadmap RAG Prompt Engineering Benefits of Pre-trained Models Limitations