Anisotropy Decides Cosine vs. Rank Metrics for Text Embeddings
This paper demonstrates that the optimal metric for comparing text embeddings depends on the geometric anisotropy of the embedding space, showing that while cosine similarity is superior for isotropic encoders, rank-based and L1-type metrics significantly outperform it for anisotropic models, a relationship predictable by a single variance-dominance metric and causally confirmed by projecting out dominant directions.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
The Big Question: How Do We Measure "Similarity"?
Imagine you have a giant library of sentences. To find similar sentences, computers turn them into lists of numbers (vectors). To see if two sentences are alike, the computer needs a ruler to measure the distance between those lists.
For a long time, everyone has used the same ruler: Cosine Similarity. It's like checking if two arrows are pointing in the same direction, ignoring how long the arrows are.
But some researchers have whispered, "Hey, maybe this ruler isn't perfect for every situation." They tried different rulers (like measuring the actual distance between points or counting how many numbers match), and sometimes those new rulers worked better. But nobody could explain why or when to switch.
This paper is the detective work that finally solves the mystery.
The Discovery: It's All About the Shape of the Room
The authors tested 19 different "sentence encoders" (the machines that turn text into numbers) and 19 different "rulers" (metrics) across many tasks. They found a clear split:
The "Well-Spread" Room: On some encoders, the data points are scattered evenly throughout the space, like a crowd of people standing in a large, open field.
- The Result: The standard ruler (Cosine) works perfectly here. Trying a different ruler gains you almost nothing.
- The Takeaway: If the room is open, stick with the standard ruler.
The "Crowded" Room: On other encoders, the data points are squished into a narrow corner or a single line, like a crowd of people all huddled in one tiny doorway.
- The Result: The standard ruler (Cosine) fails miserably here. It thinks everything is similar because everyone is pointing in the same direction.
- The Fix: Switching to a different ruler (specifically Rank-based or L1-type metrics) makes a huge difference. It can improve accuracy by about 20% on average.
The "Why": The Rogue Dimension
Why does the "Crowded" room break the standard ruler?
Imagine a room where 90% of the weight is on one single wall. If you try to measure the distance between two people in that room, the measurement is dominated by how close they are to that heavy wall, not by where they are standing relative to each other.
In the paper's terms, this is called Anisotropy or having a "Rogue Dimension."
- In a "Crowded" encoder, one single number in the list of numbers is so huge that it drowns out all the other information.
- Cosine Similarity is like a magnifying glass that focuses entirely on that one huge number. It gets blinded by it.
- The New Rulers (Rank-based or L1) are like looking at the order of the numbers or the differences between them. They ignore the fact that one number is huge and focus on the actual pattern of the data.
The "Aha!" Moment: It's the Geometry, Not the Training
You might think, "Oh, so if a model was trained with a specific method, it uses the new ruler."
No. The paper proves that's not the case.
- Example A: A model trained specifically to be "good at cosine" (E5-Mistral) still ended up with a "Crowded" room. The new rulers helped it.
- Example B: A plain, untrained language model (Multilingual BERT) ended up with a "Well-Spread" room. The standard ruler worked fine.
The Lesson: It doesn't matter how the model was built or trained. It only matters what the shape of the data looks like after it's built. If the data is squished, you need a new ruler. If it's spread out, the old ruler is fine.
How They Proved It: The "Surgery" Experiment
To be 100% sure that the "Crowded" direction was the villain, the authors performed a little surgery.
- They took the "Crowded" encoders.
- They mathematically "cut out" the one dominant direction (the heavy wall) that was causing the problem.
- The Result: Suddenly, the standard ruler (Cosine) started working great again! The advantage of the new rulers vanished.
This proved that the "Crowded" direction was the cause of the problem, not just a side effect.
The Practical Takeaway
- For most people: If you are using standard, fine-tuned tools for search or similarity (like the ones companies usually deploy), your data is likely "Well-Spread." Keep using Cosine Similarity. It is the best tool for the job.
- For the edge cases: If you are using raw, untrained language models (like taking a giant AI and just using its raw output without fine-tuning), your data might be "Crowded."
- The Fix: Before you start, check one simple number (the "Rogue Dimension Dominance").
- If that number is high, switch to a Rank-based or L1 metric, or remove the dominant direction, and your results will get significantly better.
In short: The best ruler depends on the shape of the room, not the name of the architect. If the room is crowded, change your ruler. If it's open, stick with the classic.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.