Embedding distance metrics are mathematical functions used to compare vector embeddings. They determine which items are considered similar in vector search, recommendation systems, clustering, and retrieval pipelines.
Common metrics include:
- Cosine distance: compares the angle between vectors, often used for text embeddings.
- Euclidean distance: measures straight-line distance in vector space.
- Dot product or inner product: rewards vectors that point in similar directions and have large magnitude.
- Manhattan distance: sums absolute coordinate differences, used less often in modern text retrieval.
The metric must match the embedding model and index configuration. If embeddings were trained or normalized for cosine similarity, ranking them with raw Euclidean distance may produce weaker results. Some vector databases also convert similarity into a distance where lower scores are better, which can confuse evaluation and threshold selection.
Distance metrics are first-stage retrieval signals. For user-facing quality, they are often combined with metadata filters, hybrid search, and reranking.
Redis documents cosine, L2, and inner-product metrics in its vector search concepts guide.
The LLM Knowledge Base is a collection of bite-sized explanations for commonly used terms and abbreviations related to Large Language Models and Generative AI.
It's an educational resource that helps you stay up-to-date with the latest developments in AI research and its applications.