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

为余弦相似度辩护:归一化消除了规范自由度

In Defense of Cosine Similarity: Normalization Eliminates the Gauge Freedom

Taha Bouhsine

AI总结:

本文证明,当嵌入被约束到单位球面时,对角规范矩阵的歧义消失,余弦距离与欧氏距离单调等价,从而解决了余弦相似度任意性的问题。

摘要:

Steck、Ekanadham 和 Kallus [arXiv:2403.05440] 表明,来自矩阵分解模型的学习嵌入的余弦相似度可以通过对角“规范”矩阵 $D$ 变得任意。他们的结果对于使用点积目标训练嵌入并计算余弦相似度的从业者来说是正确的且重要的。然而,我们认为,他们得出的普遍反对余弦相似度的结论,混淆了不兼容训练目标的病理与单位球面上余弦距离的几何有效性。我们证明,当嵌入被约束到单位球面 $\mathbb{S}^{d-1}$ 时(无论是在训练期间还是之后使用适当的目标),$D$ 矩阵的歧义完全消失,并且余弦距离恰好等于平方欧氏距离的一半。这种单调等价性意味着,在归一化嵌入上,基于余弦和基于欧氏距离的邻居排名是相同的。余弦相似度的“问题”不在于余弦相似度本身,而在于未能进行归一化。

英文摘要:

Steck, Ekanadham, and Kallus [arXiv:2403.05440] demonstrate that cosine similarity of learned embeddings from matrix factorization models can be rendered arbitrary by a diagonal ``gauge'' matrix $D$. Their result is correct and important for practitioners who compute cosine similarity on embeddings trained with dot-product objectives. However, we argue that their conclusion, cautioning against cosine similarity in general, conflates the pathology of an incompatible training objective with the geometric validity of cosine distance on the unit sphere. We prove that when embeddings are constrained to the unit sphere $\mathbb{S}^{d-1}$ (either during or after training with an appropriate objective), the $D$-matrix ambiguity vanishes identically, and cosine distance reduces to exactly half the squared Euclidean distance. This monotonic equivalence implies that cosine-based and Euclidean-based neighbor rankings are identical on normalized embeddings. The ``problem'' with cosine similarity is not cosine similarity, it is the failure to normalize.

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

↑