Forward-deployed / Learning zone
RAG & vector databasesa Generative AI module
Lesson 02

Embeddings & semantic search

TL;DR

To retrieve by meaning rather than exact words, you first turn text into numbers that capture what it means. An embedding is that translation: a model reads a piece of text and outputs a long list of numbers (a vector) positioned so that texts with similar meaning land near each other in space. Then "search" becomes geometry — the passages most relevant to a question are simply the vectors closest to the question's vector. This is semantic search, and it's why a RAG system can answer "how do I cancel?" using a help article titled "ending your subscription" that shares not a single keyword. The magic has sharp edges: embeddings capture fuzzy similarity, not truth or logic; they can rank a confidently-wrong-but-similar passage above the right one; and the embedding model you choose, and the fact that queries and documents look different, quietly cap how good retrieval can ever be.

🎯 For the product leader

Why it matters — Embeddings are the substrate under every RAG feature, semantic search bar, recommendation, and dedup system you'll ship. Not knowing what they can and can't do leads to promising "it understands meaning" and then being blindsided when it confidently retrieves something merely similar to the answer.

What it changes in your decisions — You treat the embedding model and the retrieval approach as product choices with quality consequences, not infrastructure to rubber-stamp — and you insist retrieval is measured (recall/precision), not eyeballed on a few happy-path queries.

Ask yourself — "For a question worded nothing like our documents, does retrieval still find the right passage — and how would we even know?"

Risk if ignored — A feature that dazzles on demo queries and fails on the long tail of real phrasings, because 'similar' silently diverged from 'relevant' and nobody was measuring.

The mental model: meaning as a map

Imagine every possible sentence placed on an enormous map, arranged so that things meaning similar things sit close together — "cancel my plan," "end my subscription," and "stop billing" cluster in one neighbourhood; "reset my password" sits far away. An embedding is just the coordinates of a piece of text on that map. Semantic search is then trivial: embed the question, go to its coordinates, and grab whatever passages are nearby.

Embeddings

Text becomes a point in meaning space · near = similar

Real embeddings have hundreds of dimensions — the 2-D picture keeps the intuition.

The pipeline
Any text → embedding model → vector
Any text
→
Embedding model
→
Vector
[0.02, -0.4, 0.9, …]
Meaning space · simplified to 2-D
Distance ≈ meaning · similar phrasings cluster · unrelated phrases sit far apart
end my subscription cancel my plan query: how do I cancel? reset password near near far

Real embeddings don't have 2 dimensions — they have hundreds or thousands, so "nearby" can capture topic, tone, entities, and intent all at once. But the intuition holds: distance in the space is (approximately) dissimilarity of meaning. Everything a vector database does (lesson 3) is bookkeeping to find nearby points fast.

How it actually works

Why it beats keyword search — and where it doesn't

Keyword (lexical) search matches strings: fast, exact, and blind to paraphrase. It nails "error E-4021" and whiffs on "the app crashed with that timeout code." Semantic search is the mirror image — it gets the paraphrase and can miss the exact string (a product SKU, a person's name, a rare acronym). Neither wins everywhere, which is exactly why production systems run both and blend them (hybrid search).

Keyword (lexical) Semantic (embeddings)
Matches Exact words / strings Meaning / paraphrase
Great at IDs, names, codes, jargon, exact quotes Natural-language questions, synonyms, intent
Blind to Synonyms, rephrasing Exact tokens it deems "unimportant"
Fails quietly when The user doesn't know the exact term The right passage is worded very differently and something merely similar outranks it

The sharp edges

Three properties of embeddings routinely surprise teams, and each is a product risk:

The through-line: embeddings are a powerful first-pass filter, not a final judge of relevance. Design the pipeline to assume the first pass is fuzzy and add a sharper stage after it.

Failure modes

Practitioner checklist