How vector embeddings turn meaning into math
Semantic search depends on one core trick: turning a piece of text into a list of numbers — a vector — in a way that preserves meaning. Two pieces of text that mean similar things end up as vectors that sit close together in that space, even if they don't share a single word.
What a vector actually represents
An embedding model (typically a neural network trained on large amounts of text) reads a sentence and outputs a fixed-length vector, often a few hundred to a few thousand dimensions. Each dimension doesn't correspond to anything human-readable on its own — there's no "dimension 42 means food" — but the model has learned to place text with related meaning in nearby regions of that space.
This is why "tea with milk" and "milk tea" can end up close together despite sharing only one word, while "tea with milk" and "tea leaves for sale" can end up further apart despite sharing two.
Measuring "close"
Closeness is usually measured with cosine similarity (the angle between two vectors) or dot product. Both produce a single score: higher means more similar. A search query is embedded the same way as the documents, and the index returns whichever document vectors are closest to the query vector.
Why this needs an index, not a loop
Comparing a query against every document vector one by one works for a few thousand items but doesn't scale. Vector indexes (HNSW and IVF are the two most common families) organize vectors so that "find the closest ones" doesn't require touching every vector in the collection — this is what makes sub-second semantic search possible over millions of documents.
The trade-off worth knowing
Embeddings capture meaning but lose precision on exact strings. A vector search alone can miss an exact SKU or part number buried in noise, because "close in meaning" isn't the same as "identical." That's the actual reason hybrid search — combining embeddings with keyword matching — exists, not just as an extra feature but as a direct answer to what pure vector similarity can't guarantee.