Direction
Cosine similarity compares the angle between vectors. Parallel vectors score 1, orthogonal vectors 0, and opposite vectors -1.
Embedding models map text into high-dimensional vectors. Rotate a query through a teaching projection, change its magnitude, and watch cosine ranking separate semantic direction from raw vector length.
Enter the vector fieldCosine similarity compares the angle between vectors. Parallel vectors score 1, orthogonal vectors 0, and opposite vectors -1.
Unit normalization removes magnitude. After normalization, maximizing dot product is equivalent to maximizing cosine similarity.
Retrieval ranks stored vectors by a selected metric. Approximate indexes trade exact ranking for lower latency at large scale.
Raw dot product rewards both alignment and vector length. If model norms vary for reasons unrelated to relevance, long vectors can outrank better-aligned short vectors. Normalize when cosine semantics are intended.
Production embeddings often have hundreds or thousands of dimensions. This 3D field preserves designed relationships, but PCA, UMAP, or t-SNE projections can distort distances and neighborhoods.
A close vector means the encoder considers two inputs similar under its training objective. Retrieval still needs metadata filters, reranking, provenance, and evaluation against the task.
Positive scaling multiplies both the dot product and vector norm by the same factor, so they cancel in cosine similarity.
Use it when absolute geometry and magnitude are meaningful or when the embedding model was trained for L2 distance. Match the production metric to the model’s training and index configuration.
Yes. Dense encoders compress information, and domain shift or short ambiguous inputs can collide. Evaluate hard negatives and add reranking where mistakes matter.
Mikolov et al. (2013) established efficient distributed word representations. Reimers and Gurevych (2019) introduced Sentence-BERT for cosine-searchable sentence embeddings. Karpukhin et al. (2020) demonstrated dense passage retrieval. FAISS documentation explains similarity-search indexing and metrics.