Embeddings, Visually
Theme
Palette
Download
Caption (tap to copy)
📖 Deep dive (full written explanation)
This post shifts from 'what' to 'why it matters,' and the framing is deliberately concrete: embeddings quietly run the internet. Almost every recommendation feed, search box, and AI assistant you touch leans on the same move — turn things into points, then find the nearest ones. Naming that shared mechanism is the goal of the whole post.
The cover overstates slightly for punch, but the substance is real. Search, recommendations, deduplication, clustering, and RAG are all special cases of nearest-neighbor lookup over learned vectors. Once you see that, a huge swath of modern systems collapses into one idea.
The motivation starts with the failure of keyword search, because contrast makes the value obvious. Keyword matching operates on strings, not meaning: it compares characters and counts overlap. Type 'car' and you simply will not retrieve a document that only says 'automobile,' because there is no shared token to match on.
This brittleness is not an edge case — it is the common case. Users describe their problems in their own words, which rarely match your documentation's words. Every synonym, paraphrase, and typo is a place keyword search silently fails, returning nothing useful while the right document sits unretrieved.
Semantic search is the fix, and the mechanism is elegant: embed the query and every document into the same space, then return whatever sits closest to the query. Because the space encodes meaning rather than spelling, 'how do I reset my password' and 'account recovery steps' land near each other despite sharing no words.
The phrase 'same space' is doing heavy lifting here. The query and the documents must be embedded by the same model so their vectors are comparable. Get that right and you search by meaning; get it wrong and you compare points from two unrelated geometries, which is the failure mode Post 5 covers in detail.
The keyword-versus-semantic comparison crystallizes the trade. Keyword search needs shared words, lets synonyms slip through, ranks by overlap, and is brittle to phrasing. Semantic search needs shared meaning, clusters synonyms naturally, ranks by distance, and is robust to how the user phrased the request.
It is worth noting these are not mutually exclusive. Production systems often combine them — hybrid search uses keywords for exact matches like product codes and embeddings for meaning. But the conceptual leap is understanding that distance-in-space can do what string overlap cannot, which is match intent.
RAG deserves its own slide because it is the dominant pattern in applied LLM work today, and it is fundamentally an embedding system. You embed your knowledge base once, embed each incoming question, retrieve the closest chunks, and hand them to the model as context. The LLM then answers grounded in retrieved text rather than its frozen training data.
The critical consequence is that retrieval quality caps answer quality. If the nearest-neighbor step grabs the wrong chunks, the model confidently answers from the wrong source — a failure that looks fluent and is therefore hard to catch. This is why teams that care about RAG spend most of their effort on the embedding and retrieval layer, not the prompt.
The pipeline diagram lays out RAG as four stages so the embedding dependency is unmistakable. Documents are embedded and stored in an index; the query is embedded with the same model; nearest neighbors are retrieved; and the LLM generates an answer grounded in them. Stages one through three are pure embedding machinery.
Reading it this way reframes 'RAG' from a buzzword into a concrete data flow. There is no magic — just embed, index, search, and condition the generation on what came back. Every knob you can turn for quality lives in those first three stages, which is exactly why understanding embeddings is the prerequisite for building good RAG.
Recommendations are the second killer application, and they reduce to the same primitive. Embed users and items into a shared space, and 'what should we show next' becomes 'what is nearest to this user.' Songs, products, and videos a person would like cluster near things they have already engaged with.
This is why the same skill transfers across wildly different products. Spotify's discover, Netflix's row of suggestions, and a store's 'you might also like' are all nearest-neighbor lookups over learned vectors. The domain changes; the geometry does not. That reuse is a big part of why embeddings are worth mastering once and applying everywhere.
The code makes 'search by meaning' tangible in eight lines. It defines cosine similarity, embeds a query as a vector, and scores it against two candidate documents — one about recovery, one about weather. The recovery document wins because its direction in space is closest to the query's, even though it shares no obvious keyword.
The snippet is deliberately model-free so the geometry is visible: these are hand-chosen vectors, but the logic is identical to a production system. Swap the hard-coded arrays for outputs of a real encoder and you have the core of semantic search. Seeing the whole loop in a few lines demystifies what looks like a heavyweight feature.
The mindmap shows that one geometry serves many jobs: search and RAG, recommendation, clustering and deduplication, and cross-modal matching. The point of the branching layout is breadth — to drive home that these are not separate technologies but one technique wearing different hats.
This is the most useful thing to remember from the post. When you encounter a new problem — 'find similar support tickets,' 'group near-duplicate images,' 'match resumes to jobs' — your first instinct should be 'can I embed both sides and measure distance.' Surprisingly often, the answer is yes.
The cross-domain trick is the climax of the post because it is genuinely surprising. Embeddings are not limited to text; images, audio, code, and users all map into vector spaces. More strikingly, models like CLIP train text and images into the SAME space, so the caption 'a photo of a dog' lands near actual photographs of dogs.
That shared-space property is what enables zero-shot image classification, text-to-image search, and multimodal assistants. It also reframes embeddings as the universal interface of modern AI: a common numeric language that lets different modalities be compared and combined. One geometry to rule them all is only a slight exaggeration.
The recap distills the payoff into five lines: keyword search misses meaning, embeddings search by meaning, RAG is embed-plus-nearest-neighbor, recommendations are neighbor lookups, and the same idea spans text, image, and audio. Each line is a different product built on one primitive.
The through-line to carry forward is that 'embed, then find nearest neighbors' is not one feature among many — it is the feature, reused everywhere. Holding that in mind makes the next two posts land: Post 3 explains how the space gets built and measured, and Post 4 lets you build a working version yourself.
This hands off to Post 3 by raising the obvious next question. You now know what embeddings are and why they matter, but not how the vectors actually get their values or how 'close' is computed under the hood. Those two gears — training and distance metrics — are the engine room.
The teaser promises to open that hood. It is the right moment: people are most motivated to learn the mechanics right after they have seen the payoff, because the math now has a clear purpose to serve.