【问题标题】:What is the difference between wmd (word mover distance) and wmd based similarity?wmd(词移动距离)和基于 wmd 的相似性有什么区别?
【发布时间】:2017-08-04 08:59:17
【问题描述】:

我正在使用 WMD 来计算句子之间的相似度。例如:

distance = model.wmdistance(sentence_obama, sentence_president)

参考:https://markroxor.github.io/gensim/static/notebooks/WMD_tutorial.html

不过也有基于大规模杀伤性武器的相似方法(WmdSimilarity).

参考: https://markroxor.github.io/gensim/static/notebooks/WMD_tutorial.html

除了明显的是距离和相似度之外,两者之间有什么区别?

更新:两者完全相同,只是表示方式不同。

n_queries = len(query)
result = []
for qidx in range(n_queries):
    # Compute similarity for each query.
    qresult = [self.w2v_model.wmdistance(document, query[qidx]) for document in self.corpus]
    qresult = numpy.array(qresult)
    qresult = 1./(1.+qresult)  # Similarity is the negative of the distance.

    # Append single query result to list of all results.
    result.append(qresult)

https://github.com/RaRe-Technologies/gensim/blob/develop/gensim/similarities/docsim.py

【问题讨论】:

  • 当您说“还有 WMD 相似选项”时,您指的是什么? (我搜索了 gensim word2vec.py 和 keyedvectors.py 文件,并没有明白你的意思。只有词向量到词向量的相似性方法,这与 Word Mover 的距离完全不同向量集的计算。)通常的情况是,“相似性”度量只是 (1.0 - scaled_distance),但最好知道您正在比较什么。跨度>
  • @gojomo 我的意思是 Word movers 基于距离的相似性。我将在问题中添加详细信息。
  • 感谢您提供准确的代码参考。

标签: nlp nltk gensim word2vec word-embedding


【解决方案1】:

我认为通过“更新”,您或多或少地回答了您自己的问题。

一个是距离,另一个是相似度,这是两个计算之间的唯一区别。作为笔记本,您可以在relevant section 中链接笔记:

大规模杀伤性武器是距离的度量。 WmdSimilarity 中的相似性只是负距离。小心不要混淆距离和相似之处。两个相似的文档会有很高的相似度得分和很小的距离;两个非常不同的文档的相似度得分低,距离大。

正如您摘录的代码所示,此处使用的相似度度量并不完全是“负”距离,而是按比例缩放,因此所有相似度值都从 0.0(不包括)到 1.0(包括)。 (也就是说,零距离变成 1.0 的相似度,但越来越大的距离变得越来越接近 0.0。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-16
    • 2019-07-03
    • 2016-08-15
    • 2016-06-24
    • 2021-02-14
    • 2010-11-13
    相关资源
    最近更新 更多