Digital Product Engineering6.4 Embeddings & Vector Search
VOL. VI · CH. 6.4 · AI SYSTEMS

Embeddings & Vector Search

The mathematical trick that lets a computer judge whether two pieces of text mean similar things.

DivisionAI Engineering
DifficultyAdvanced
Prerequisites6.3
Related5.1 5.12
2 min read · 343 words

6.4.1Definition

An embedding is a numerical vector representation of a piece of text (or image, or audio), positioned in a high-dimensional space such that semantically similar content ends up near each other. Vector search finds the nearest embeddings to a query's embedding, surfacing content that means something similar — not just content that shares the same keywords.

6.4.2Why It Exists

Keyword search (5.12) fails when a query and a relevant document use different words for the same concept — "car" and "automobile" share no characters but mean nearly the same thing. Embeddings exist to capture meaning rather than exact word overlap, which is precisely what RAG's retrieval step (6.3) needs to find genuinely relevant chunks regardless of exact phrasing.

6.4.3Vector Database Options

OptionPatternBest fit
Dedicated vector DB (Pinecone, Weaviate)Purpose-built for large-scale similarity searchHigh-volume, production RAG systems
Postgres + pgvectorVector search added to an existing relational databaseProducts already on Postgres (5.1) wanting to avoid a second system
In-memory / small-scaleVectors held directly in application memorySmall, fixed document sets, prototypes

6.4.4Common Mistakes

  • Adopting a dedicated vector database for a small, fixed document set that an existing Postgres instance with pgvector would handle without adding a new system to operate.
  • Mixing embedding models across an index — re-embedding new content with a different model than was used for existing entries, producing vectors that aren't comparable to each other.
  • Ignoring embedding model versioning, so an upgrade to a newer embedding model silently breaks similarity comparisons against the old index.

6.4.5Best Practices

  • Start with pgvector on an existing Postgres instance before adopting a dedicated vector database.
  • Use a single, consistent embedding model across an entire index; re-embed everything on model upgrade rather than mixing versions.
  • Combine vector search with traditional keyword filtering (hybrid search) where exact-match precision also matters.
Real-World ExampleNotion's AI search feature combines embedding-based semantic search with traditional filters, letting a query like "the doc about Q3 pricing" surface the right page even when it never uses the word "pricing" verbatim.