Anisotropy Decides Cosine vs. Rank Metrics for Text Embeddings
Summary
A comprehensive empirical study investigated nineteen parameter-free similarity metrics across nineteen text encoders, ranging from compact sentence transformers to seven-billion-parameter large language models, on seven datasets. The research definitively establishes that the geometric property of anisotropy dictates the optimal metric choice for comparing text embeddings. When an encoder's variance is evenly distributed, cosine similarity is the best parameter-free option. However, if variance concentrates into a few dominant directions (anisotropy), rank-based and L1-type metrics significantly outperform cosine, yielding around a twenty percent relative improvement where cosine is weakest. This effect is driven by the embedding space's geometry, not the model's training. A single diagnostic number, the fraction of variance held by the most dominant dimension, accurately predicts the utility of alternative metrics, showing a 0.86 rank correlation and 0.95 linear correlation.
Key takeaway
For Machine Learning Engineers deploying text embedding models, your choice of similarity metric should not default to cosine. If you are working with encoders exhibiting high anisotropy, diagnose this using the provided one-number variance diagnostic. Switching to rank-based or L1-type metrics can yield a significant relative performance improvement, especially where cosine is weakest. Conversely, for well-spread, fine-tuned embedders, cosine remains the appropriate and effective tool.
Key insights
Anisotropy in text embedding spaces determines whether cosine or rank-based metrics are optimal for similarity comparisons.
Principles
- Anisotropy dictates optimal text embedding similarity metric.
- Cosine similarity is best for evenly spread embedding variance.
- Rank-based/L1 metrics outperform cosine on anisotropic embeddings.
Method
Calculate the fraction of variance held by the most dominant dimension as a predictive diagnostic for metric utility.
In practice
- Use the one-number diagnostic to evaluate encoder geometry.
- Employ rank-based or L1-type metrics for anisotropic encoders.
- Deploy cosine similarity for well-spread, fine-tuned embedders.
Topics
- Text Embeddings
- Cosine Similarity
- Anisotropy
- Similarity Metrics
- Embedding Geometry
- Large Language Models
Best for: Research Scientist, AI Engineer, AI Scientist, Machine Learning Engineer, NLP Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Takara TLDR - Daily AI Papers.