0%
Retrieval-Augmented Generation12 min

Vector Databases and Embeddings

Vector databases are the storage layer that makes semantic search possible at scale. Understanding how they work enables you to make better architecture and vendor decisions.

Embeddings

An embedding is a numerical representation of text — a vector of hundreds or thousands of numbers — that encodes semantic meaning. Texts with similar meaning have embeddings that are close together in this high-dimensional space. Embeddings are generated by embedding models (separate from generation models) and are the core technology enabling semantic search.

How vector search works

Vector databases store millions of embeddings and return the k most similar embeddings to a query embedding using approximate nearest-neighbour search algorithms. Unlike keyword search (which matches exact terms), vector search matches by meaning — "heart attack" and "myocardial infarction" return similar results.

Vector database options

Dedicated vector databases — Pinecone, Weaviate, Qdrant, Milvus. Purpose-built for vector storage and retrieval at scale, with features like metadata filtering, hybrid search (combining vector and keyword search), and multi-tenant isolation.

PostgreSQL with pgvector — the vector extension for Postgres enables vector storage and search within your existing database. Suitable for smaller scale and simpler architectures. Lower operational overhead than running a separate vector database.

Hybrid search

Pure vector search sometimes misses exact keyword matches that are relevant. Hybrid search combines vector similarity and BM25 keyword search, ranking results using reciprocal rank fusion or a weighted combination. For most enterprise applications, hybrid search outperforms pure vector search.

Embedding model choice is often more consequential than vector database choice. Embeddings from a model trained on your domain will produce significantly better retrieval than generic embeddings, regardless of the database storing them.

Check your understanding

3 questions, 70% to pass
1. What is an embedding?
2. How does vector search differ from keyword search?
3. What is pgvector?