What is embedding similarity?

Quick answer

Embedding similarity is a measured, numerical score describing how close two pieces of content sit within an embedding model’s vector space, and it’s the underlying mechanism that makes semantic search, retrieval-augmented generation, and semantic caching work, converting the fuzzy, human notion of “these two things mean roughly the same thing” into a precise number a computer can calculate, sort, and threshold. Understanding how this similarity score is calculated, and what it does and doesn’t capture, matters for anyone building on top of embeddings, since nearly every retrieval decision a system makes ultimately comes down to comparing these similarity scores against each other or against some fixed cutoff.

Summary slides
Embedding similarity
Why comparing raw vectors directly doesn't tell you what you…
Other similarity measures and when they're actually used instead
What embedding similarity captures, and what it consistently misses
Common mistakes teams make around embedding similarity

Why comparing raw vectors directly doesn’t tell you what you actually want to know

An embedding model converts a piece of text into a list of numbers, a vector, and the most obvious way to compare two vectors might seem to be checking whether their individual numbers are close to each other, but this isn’t how meaningful similarity gets measured in practice. What matters for semantic similarity is the vectors’ relative direction and position within the overall embedding space, not the raw magnitude of their individual numeric values, since a well-trained embedding model places semantically related content in directions that meaningfully correlate with each other, and capturing that relationship requires a specific kind of mathematical comparison rather than a naive, number-by-number check.

This is why embedding similarity relies on established mathematical measures built specifically to capture this kind of directional and positional relationship between vectors, rather than any comparison a person might improvise on their own. Understanding which specific measure is being used, and why, matters for interpreting what a similarity score actually represents.

Cosine similarity and why it’s the most common measure used

The most widely used similarity measure for embeddings is cosine similarity, which measures the angle between two vectors rather than the distance between their endpoints, producing a score that stays consistent regardless of how large or small the vectors’ overall magnitude happens to be. Two vectors pointing in nearly the same direction produce a cosine similarity close to its maximum value, indicating strong semantic similarity, while two vectors pointing in very different directions produce a score close to its minimum, indicating little to no semantic relationship.

Cosine similarity’s popularity for this purpose comes specifically from ignoring vector magnitude and focusing purely on direction, which matters because many embedding models produce vectors whose magnitude can vary for reasons unrelated to semantic content, longer pieces of text sometimes producing vectors with different overall scale than shorter ones, for instance, and a similarity measure that got thrown off by this kind of magnitude variation would produce misleading results detached from actual semantic relatedness. By focusing only on direction, cosine similarity sidesteps this problem and produces a measure that more reliably tracks genuine semantic closeness.

Other similarity measures and when they’re actually used instead

Cosine similarity isn’t the only measure used in practice, dot product similarity, which does account for vector magnitude, is used by some embedding models specifically trained and calibrated with that measure in mind, and Euclidean distance, measuring the straight-line distance between two vectors’ endpoints, is used in certain specialized contexts as well. The right measure to use for a given embedding model isn’t a free choice, it’s determined by how that specific model was trained and calibrated, and using a mismatched similarity measure against a model that wasn’t trained with it in mind can produce meaningfully worse retrieval results than using the measure the model was actually designed around.

This is a detail that’s easy to overlook when adopting a new embedding model, and checking which similarity measure a given model’s documentation recommends, rather than assuming cosine similarity is universally the right default, is a small but consequential step that affects whether a retrieval system gets the full benefit of whatever quality the underlying embedding model actually has to offer.

Why a similarity score’s absolute value doesn’t mean the same thing across every embedding model

A similarity score from one embedding model isn’t directly comparable to a similarity score from a different embedding model, even when both use the same underlying measure, since each model’s own training process determines the overall distribution and scale of similarity scores it tends to produce, one model might typically produce scores clustered in a narrow, high range for genuinely related content, while another might spread its scores across a much wider range for the same kind of relatedness. This means a similarity threshold tuned carefully for one embedding model doesn’t transfer automatically to a different model, it needs to be recalibrated specifically against whatever model is actually being used.

This connects directly to the broader discussion of threshold calibration covered in this collection’s discussion of semantic caching, where getting a similarity threshold right requires empirical validation against real examples specific to the model and task at hand, rather than assuming a threshold that worked well for one embedding model or one application will transfer cleanly to a different context without re-validation.

What embedding similarity captures, and what it consistently misses

Embedding similarity captures overall semantic relatedness well, but it doesn’t reliably capture more precise distinctions that matter for many real applications, whether two pieces of text agree or contradict each other on a specific factual point, for instance, since text expressing opposing claims about the same topic can still produce a high similarity score simply because they’re discussing the same underlying subject matter using similar vocabulary and structure. This is a genuine limitation worth understanding clearly, high similarity indicates that two pieces of content are about the same general topic, it doesn’t indicate that they agree, or even that they’re both correct.

This limitation matters directly for the false-hit risk covered in this collection’s discussion of semantic caching, a high similarity score between a new request and a cached response doesn’t guarantee they warrant the exact same answer, since similarity captures topical closeness rather than the finer distinctions that can separate two questions that are superficially alike but meaningfully different in what they’re asking. Recognizing this gap between what similarity measures and what a specific application needs is essential for using embedding similarity responsibly rather than treating a high score as an unconditional guarantee of interchangeability.

How similarity search scales beyond comparing vectors one at a time

Computing similarity between a query and every single stored vector individually becomes impractical once a collection grows into the millions of items, since that approach requires a full, exhaustive comparison against the entire collection for every single search. This is why production retrieval systems rely on specialized indexing structures built specifically to find the most similar vectors quickly without checking every single one, trading a small amount of accuracy, occasionally missing the absolute best match in exchange for a dramatic improvement in search speed, an approach called approximate nearest neighbor search.

This tradeoff between exhaustive accuracy and practical search speed is an unavoidable part of running similarity search at real scale, and understanding that production retrieval systems are typically working with this approximation, rather than a perfectly exhaustive comparison, matters for setting realistic expectations about a retrieval system’s behavior, an occasional near-miss on the theoretically best match is an accepted, deliberate tradeoff rather than a system malfunction.

Common mistakes teams make around embedding similarity

1. Assuming cosine similarity is universally the correct measure to use, rather than checking which measure a specific embedding model was trained and calibrated around.

2. Treating similarity scores from different embedding models as directly comparable, missing that each model’s own training determines a distinct scale and distribution for its scores.

3. Interpreting a high similarity score as guaranteeing agreement or correctness between two pieces of content, rather than recognizing it only reflects topical relatedness.

4. Reusing a similarity threshold tuned for one application or model without recalibrating it against the specific model and task actually being used.

5. Expecting perfectly exhaustive, exact similarity search at large scale, without accounting for the approximate nature of the indexing structures most production systems actually depend on.

What connects these mistakes is treating embedding similarity as a simple, universal, self-explanatory number rather than a measure whose meaning depends entirely on the specific model, measure, and calibration behind it, using it well requires understanding those specifics rather than trusting a similarity score to mean the same thing regardless of where it came from.

The deeper point about embedding similarity is that it’s the mathematical bridge between the fuzzy, human intuition of meaning and the precise, sortable numbers a computer system needs to make retrieval decisions, and every quality issue in a retrieval-based system, from irrelevant search results to a false semantic cache hit, ultimately traces back to some mismatch between what this similarity score actually measures and what the application built on top of it assumed it measured.