01The problem keyword search can’t solve
A student searches your notice board for “fee deadline”. There is a perfect notice — but it says “last date for tuition payment”. Not one word matches. Old-style search, which looks for the letters you typed, finds nothing, and the student leaves thinking the notice does not exist.
That is the wall. Computers are brilliant at matching exact characters and hopeless at matching meaning — and humans almost never use the exact words the document used. We need a way for a computer to know that “fee deadline” and “last date for tuition payment” are close in meaning, even with zero shared words. Embeddings are that way.
02The one idea: give meaning a location
Here is the whole concept in a picture you already own. Imagine a giant map. On it, we place every word and sentence as a dot — and we arrange them so that things with similar meaning sit close together. “King” and “queen” are neighbours. “Dog” and “puppy” are neighbours. “Pizza” is far away in a different part of town with “pasta”. Meaning has become position. Drag the words around and watch it:
fee deadline is closest in meaning to tuition due date (~0.92) and burger (~0.70). Different words can be near; related words cluster; unrelated ones sit far apart.
Once meaning is a location, “find text that means the same thing” becomes “find dots that are near this dot” — and measuring nearness is something computers do instantly. That single translation, from meaning to distance, is the key that unlocks the rest of the journey.
03An embedding is a list of numbers
Now the real version. A location on a flat map needs two numbers — across and up. To capture something as rich as meaning, two numbers are nowhere near enough, so an embedding uses hundreds or thousands of them. A typical embedding is a list of, say, 1,536 numbers. That list is a position — not on a 2D map, but in a space with 1,536 directions.
Do not let that sentence scare you, and do not try to picture it — nobody can picture 1,536 dimensions, including the people who build these systems. You do not need to. The idea is identical to the map: it is just a position, and positions can be near or far. Each of those hundreds of numbers quietly captures some shade of meaning — how animal-like, how formal, how much about money — learned automatically. You will never read them by hand. You only ever ask one question of them: how close are these two positions?
04Where the numbers come from
Who decides that “fee” and “tuition payment” belong close together? A model does — an embedding model, a cousin of the LLM from Chapter 5, trained on enormous amounts of text. It learned, from seeing how words are actually used across the internet, that some words appear in similar company, and it places those near each other. You do not train it; you use it exactly like the models in Chapter 6 — send text to an API, get back the list of numbers.
Two facts that matter in practice. It is cheap and fast— embedding is far lighter than generating text, so turning a thousand notices into a thousand embeddings costs very little. And you must use the same model for everything you intend to compare: two embeddings are only comparable if they were made by the same model, because each model builds its own private map. Mix two maps and the distances mean nothing.
05Measuring nearness — cosine similarity
One honest piece of maths, and it stays gentle. To find the notice closest in meaning to a query, the computer measures the distance between their two embeddings. The usual measuring stick has a name you will hear constantly — cosine similarity — and all it really asks is: are these two positions pointing in the same direction?
You do not compute it by hand; a library does, in microseconds. But know how to read its answer, because it is a simple score: around 1.0 means “these mean almost the same thing”, around 0 means “unrelated”, and negative means “opposite-ish”. So “fee deadline” vs “last date for tuition payment” might score 0.9 — different words, nearly identical meaning — while “fee deadline” vs “cricket match” scores near 0. You have just turned “do these mean the same?” into a number you can sort by. (There is a cousin called dot product that hosted APIs often use for speed; same idea — higher means closer.)
06Text in, meaning out — the whole shape
That is the complete mechanic, and it is worth saying as one sentence you can keep: an embedding model turns any piece of text into a position, and cosine similarity measures how close two positions are. Everything semantic — smart search, recommendations, grouping similar things, and the retrieval at the heart of RAG — is built on exactly this and nothing more exotic.
07What this unlocks
Suddenly a whole class of features becomes possible, and you can now see how each one works underneath. Semantic search: embed the query, find the nearest document embeddings — the next chapter. Recommendations: “more like this” is just “nearest neighbours to this”. Grouping: notices that cluster together in the space are about the same topic, with nobody labelling them. Deduplication: two near- identical positions are two ways of saying the same thing. One idea, many products — which is why “embeddings” is on every AI job description, and why you now understand the thing behind the word.
08The honest limits
Two things to keep you clear-eyed. An embedding captures overall meaning, not exact facts — it is great at “these are about the same topic” and blunt about “which of these two dates is later”. And it inherits its model’s blind spots and biases from Chapter 5 — a model trained mostly on English maps other languages more coarsely, and prejudices in the training text can show up as positions. Embeddings are a powerful tool, not a truth machine, and knowing where the tool is blunt is what separates someone who uses it well from someone who trusts it too much.
09Do this today
Make it concrete. Ask your embedding API (or have Claude wire a tiny script) to embed three sentences: “the fee deadline is Friday”, “last date to pay tuition is Friday”, and “the cricket final is on Sunday”. Print the cosine similarity between each pair. Watch the first two score high despite sharing almost no words, and both score low against the third. When you see a computer measure that two different sentences mean the same thing, the magic of the next three chapters stops being magic and becomes something you understand.
You can now turn meaning into numbers. Next: store millions of these positions and find the nearest ones in milliseconds — the vector database, and real semantic search.
