gpt4 book ai didi

python手套相似度计算

转载 作者:太空宇宙 更新时间:2023-11-03 11:22:23 25 4
gpt4 key购买 nike

我正在尝试了解 python-glove 如何计算最相似 术语。

是否使用余弦相似度?

例子来自python-glove github https://github.com/maciejkula/glove-python/tree/master/glove: enter image description here

我从 gensim 的 word2vec 知道,most_similar 方法使用余弦距离计算相似度。
enter image description here

最佳答案

project website在这一点上有点不清楚:

The Euclidean distance (or cosine similarity) between two word vectors provides an effective method for measuring the linguistic or semantic similarity of the corresponding words.

欧氏距离与余弦相似度不同。听起来两者都很好,但它没有具体说明使用哪个。

但是,我们可以观察到the source您正在查看的 repo 协议(protocol):

dst = (np.dot(self.word_vectors, word_vec)
/ np.linalg.norm(self.word_vectors, axis=1)
/ np.linalg.norm(word_vec))

它使用 cosine similarity.

关于python手套相似度计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40337327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com