Overview
How text becomes a point in a high-dimensional space — and why cosine similarity, not distance, is what makes retrieval work.
Why it matters
An embedding model maps a piece of text to a vector of a few hundred to a few thousand numbers (e.g. 1536 dimensions for a common OpenAI model). The model is trained so that texts with similar meaning end up as vectors that point in similar directions — 'the cat sat on the mat' and 'a feline rested on the rug' land close together even though they share almost no words.
This is why retrieval uses cosine similarity instead of raw distance: cosine similarity measures the angle between two vectors, ignoring their length. That matters because a long, repetitive chunk can produce a vector with a much larger magnitude than a short, precise chunk about the same topic — if you compared raw Euclidean distance, the long chunk could look 'far away' purely because of its length, not its meaning. Cosine similarity strips that out: two vectors pointing the same direction score 1.0 (identical meaning), perpendicular vectors score 0 (unrelated), and opposite vectors score -1 (contradictory).
The practical payoff: once every chunk and every query is a point in this shared space, retrieval becomes a geometric operation — 'find the k chunks whose vectors have the smallest angle to the query vector' — instead of a keyword match. That's also why embeddings fail on pure keyword or exact-number lookups: the model has smoothed away the specific digits or IDs in favor of general meaning, which is precisely where hybrid (keyword + vector) search earns its keep.
