Embeddings intuition
Everything in RAG rests on one idea. Embeddings turn text into vectors — lists of numbers — positioned so that text with similar meaning sits close together in space. Once meaning becomes position, you can find text by what it means rather than by the exact words it uses.
Why it matters
Keyword search fails the moment someone phrases a question differently from the document. "How do I cancel" and "end my subscription" share no words, yet they mean the same thing — and in embedding space they land right next to each other. Your whole system's quality rests on this, because if retrieval brings back the wrong text, no amount of clever prompting downstream can save the answer. Retrieval quality is the ceiling on RAG quality.
The mental picture to keep
Imagine every sentence as a point on a map. Sentences about remote work cluster in one region; sentences about password rotation cluster in another, far away. A question is also a point. Retrieval is just "find the nearest points to this question." No maths is required to use embeddings well, but this picture of meaning-as-position is non-negotiable — hold it firmly.
The one decision you own
Which embedding model. `text-embedding-3-small` is the cheap, capable default. Larger models buy accuracy at higher cost. Open models let data stay on your own hardware when privacy demands it.
Critical
Lock the model in early
Switching embedding models later means re-embedding every document. Choose deliberately and lock it in.
What you will do
Embed a handful of Northwind sentences, embed some questions, and read the similarity scores. You will watch a question with zero shared words score high against the right sentence, and near zero against an unrelated one. That is the whole engine, seen once — so you trust it for the rest of the module.
Running example throughout this module: the Northwind Robotics internal docs (handbook, expenses, security, product spec) from the examples pack.
Watch out
Common mistakes
- Treating embeddings as a black box you never inspect.
- Switching models mid-project without planning a full re-index.
- Optimizing the generation prompt while retrieval still returns the wrong neighbourhood.
Go deeper (optional)