Measuring similarity: the actual math
Cosine similarity, dot product, and Euclidean distance — the three ways retrieval systems decide "how close" two pieces of meaning are, worked out by hand and in code.
9 min readUpdated 2026-09-03context-engineeringembeddingssimilaritymath