Type "how do I reset my password" into a good search box, and it finds a page titled "account recovery." Zero words in common. Nothing matched on text. So how did it know they mean the same thing?
Your app turned meaning into numbers — and once meaning is numbers, a computer can measure it. That trick is called an embedding. Get this one idea and half the AI buzzwords — "vector search," "cosine similarity," "vector database" — stop being scary.
Prefer to watch? Full walkthrough with the meaning-space animation:
Start with the machine itself. You hand it a piece of text — a word, a sentence, a whole paragraph. It hands back a list of numbers. That list is the embedding. Same text in, same numbers out, every time.
How long is the list? For a common model — OpenAI's text-embedding-3-small — it's 1,536 numbers. That sounds like a lot, until you think of each number as a coordinate.
Two numbers place a point on a map. Three place it in a room. 1,536 place it in a space you can't picture — but the math works exactly the same as the map.
Here's the whole point of that space: the model places text so that similar meaning lands in a similar spot. "cat" and "dog" end up as neighbors. "car" ends up far away.
Nobody wrote that rule. The model learned it — it read a mountain of text and noticed which words keep the same company. Words used the same way get pushed together; words used differently get pushed apart. This is an old idea from linguistics called the distributional hypothesis: a word's meaning is shaped by the words it usually appears next to. Meaning, in this space, is just where you land relative to everything else.
Now the real question in search: are these two things close? You embed the question, you embed every document, and you grab the points nearest the question. But "nearest" means one specific thing — and it's simpler than it sounds.
Draw an arrow from the center of the space out to each point.
That angle is cosine similarity. A value near 1 means the arrows point the same way (very similar). A value near 0 means they're unrelated. That's the whole comparison — "cosine similarity" is just measuring the angle between two arrows.
Every "AI search" feature you've used is basically this, under a nicer name:
const doc = embed("account recovery steps") // → [0.02, -0.91, …] · 1536 numbers
const query = embed("how do I reset my password?")
// cosine: 1 = same direction, 0 = unrelated
const score = cosine(query, doc) // ≈ 0.86 — close
Embed your text, embed your query, compare them, keep the closest. (Those scores are illustrative — the real point is high = same direction.)
These coordinates are only meaningful within a single model. A vector from model A and a vector from model B are not comparable — it's gibberish. Same coordinates, different maps.
So embed your query and your documents with the exact same model, always. Change the model, and you have to re-embed everything you're searching over.
Embeddings are great at meaning — which makes them bad at things that have no meaning. An error code. A product ID. SKU-4417. There's nothing to place on the meaning-map; it's just an exact string, and pure vector search fumbles it, because nothing is "close in meaning" to a serial number.
That's why real systems run both: keyword search to catch exact strings, vector search to catch meaning, and the results merged. If you've built RAG and watched it miss an obvious error code, this is usually why.
An embedding, start to finish:
Once you see it as numbers on a map, the buzzwords fall away — and you can actually debug your search instead of trusting it. When a result looks wrong, you're not staring at magic; you're asking a concrete question about distance on a map.
What's the weirdest match your vector search ever returned — the one that made no sense at all? Drop it in the comments — I read them.
I make Vlad's Stack — how the tools you use every day actually work, for people who write code. Full video walkthrough is above.