arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.29571cs.CL
收藏

各向异性决定文本嵌入的余弦度量与排序度量

Anisotropy Decides Cosine vs. Rank Metrics for Text Embeddings

University of California, San Diego(加州大学圣地亚哥分校)

V. S. Raghu Parupudi

AI总结:

通过19个编码器和7个数据集的实验,发现嵌入空间的各向异性决定余弦相似度与其他度量(如基于排序的度量)的相对性能,各向异性时排序度量平均提升约20%。

摘要:

比较两个文本嵌入的标准方法是余弦相似度。零星的研究报告说不同的度量效果更好,但从未确定决定何时或为何的几何条件。我们通过全面的实证研究解决了这两个问题:在19个编码器上测试了19种无参数相似度度量,从紧凑的句子变换器到70亿参数的大语言模型,跨越7个数据集。答案是几何性的。当编码器将其方差均匀分布在各个方向上时,余弦是最佳的无参数选择,没有其他度量能带来有用的提升。当方差集中在少数主导方向上(即各向异性)时,基于排序和L1类型的度量明显优于余弦。绝对增益不大,但由于余弦在这些编码器上起点较低,相对改进显著,平均约20%,在余弦最弱的地方改进最大。决定因素的是嵌入空间的几何形状,而不是模型的训练方式:当两者不一致时,度量遵循几何形状。一个数字——单个最主导维度所持有的方差比例——可以预测所有19个编码器上替代度量的帮助程度,秩相关为0.86,线性相关为0.95。为了测试这是原因而非相关,我们投影出主导方向:余弦恢复,其他度量的优势几乎消失,但仅对最初各向异性的编码器有效。这种效应是方向性的,而非基于幅度的,因为它在将每个向量归一化为单位长度后仍然存在。因此,在无参数度量中,余弦是编码器分布良好时的正确工具,这包括通常用于检索的微调嵌入器,我们给出了一个单数诊断来判断何时不是这样。

英文摘要:

The standard way to compare two text embeddings is cosine similarity. Scattered studies report that a different metric does better, but never pin down the geometric condition that decides when, or why. We settle both with a comprehensive empirical study: nineteen parameter-free similarity metrics on nineteen encoders, from compact sentence transformers up to seven-billion-parameter large language models, across seven datasets. The answer is geometric. When an encoder spreads its variance evenly across directions, cosine is the best parameter-free choice and no other metric helps by a usable margin. When the variance concentrates into a few dominant directions, a property known as anisotropy, rank-based and L1-type metrics beat cosine by a clear margin. The absolute gain is modest, but because cosine starts low on these encoders it is a sizable relative improvement, around twenty percent on average and largest where cosine is weakest. What decides this is the geometry of the embedding space, not how the model was trained: where the two disagree, the metric follows the geometry. One number, the fraction of variance held by the single most dominant dimension, predicts how much the alternatives help across all nineteen encoders, with a rank correlation of 0.86 and a linear correlation of 0.95. To test this as the cause rather than a correlate, we project out the dominant directions: cosine recovers and the advantage of the other metrics nearly vanishes, but only on the encoders that were anisotropic to begin with. The effect is directional, not magnitude based, since it survives normalizing every vector to unit length. Among parameter-free metrics, then, cosine is the right tool wherever an encoder is well spread, which includes the fine-tuned embedders commonly deployed for retrieval, and we give a one-number diagnostic for when it is not.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑