What is Vector Database?

A vector database is a specialized database designed to store, index, and query high-dimensional vector embeddings, enabling efficient similarity search and retrieval of unstructured data like text, images, and audio.

Quick Facts

CreatedConcept emerged in 2010s, popularized with LLMs in 2022-2023
SpecificationOfficial Specification

How It Works

Vector databases store embeddings and retrieve nearby vectors using distance metrics such as cosine similarity, Euclidean distance, or dot product. Their indexes, including HNSW, IVF, and product quantization, trade recall, latency, memory, build time, and update behavior rather than making exact search universally fast. A production design usually combines vector retrieval with metadata filters, access controls, source-document storage, observability, and evaluation. Dedicated products are one option; relational, search, and cache systems with vector extensions can also be the right choice when they fit the data and operational requirements.

Key Characteristics

  • Optimized for high-dimensional vector storage and similarity search
  • Uses approximate nearest neighbor (ANN) algorithms for fast retrieval
  • Supports various distance metrics: cosine, Euclidean, dot product
  • Scales to billions of vectors with sub-second query latency
  • Often includes metadata filtering alongside vector search
  • Integrates with embedding models from OpenAI, Cohere, and others

Common Use Cases

  1. Semantic search: Find documents by meaning rather than keywords
  2. RAG systems: Retrieve relevant context for LLM responses
  3. Recommendation engines: Find similar products, content, or users
  4. Image search: Find visually similar images in large collections
  5. Anomaly detection: Identify outliers in high-dimensional data

Example

loading...
Loading code...

Frequently Asked Questions

What is the difference between a vector database and a traditional database?

Traditional databases store structured data and perform exact matches on values. Vector databases store high-dimensional embeddings and find similar items using distance calculations. While SQL databases excel at filtering and joining tables, vector databases excel at semantic similarity search where the goal is finding conceptually related items rather than exact matches.

What are the most popular vector databases?

Popular dedicated vector databases include Pinecone, Weaviate, Milvus, Qdrant, and Chroma. Traditional databases with vector extensions include PostgreSQL with pgvector, Elasticsearch, and Redis. Cloud providers offer managed solutions like AWS OpenSearch, Google Vertex AI Vector Search, and Azure Cognitive Search.

How do vector databases achieve fast similarity search?

Vector databases use Approximate Nearest Neighbor (ANN) algorithms that trade perfect accuracy for speed. Common algorithms include HNSW (graph-based), IVF (clustering-based), and PQ (compression-based). These techniques create index structures that enable sub-linear search time, making it possible to query billions of vectors in milliseconds.

What embedding dimensions should I use?

Embedding dimensions depend on your model and use case. OpenAI's text-embedding-3-small uses 1536 dimensions, while text-embedding-3-large uses 3072. Higher dimensions capture more nuance but require more storage and compute. Many applications work well with 384-1536 dimensions. Some vector databases support dimension reduction for cost optimization.

How do I choose the right distance metric?

Cosine similarity is most common for text embeddings as it measures angle between vectors regardless of magnitude. Euclidean distance works well when vector magnitude matters. Dot product is fastest computationally and works when vectors are normalized. Most embedding models are trained with cosine similarity, making it the default choice.

Related Tools

Related Terms

Related Articles