Skip to content

Latest commit

 

History

History
 
 

sentence_similarity

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

句子相似度

本示例展示如何使用word2vec_skipgram模型进行句子相似度预测。

该示例运用最简单的方法,将一个句子中所有单词的word embedding叠加,得到句子向量。之后计算余弦相似度。

预测

python sensim.py

程序运行结束后, 可以看待预测的两个文本的余弦相似度

text_a: 驾驶 违章 一次 扣 12分 用 两个 驾驶证 处理 可以 吗; text_b:  一次性 扣 12分 的 违章 , 能用 不满 十二分 的 驾驶证 扣分 吗; cosine_similarity: 0.39889
text_a: 水果 放 冰箱 里 储存 好 吗; text_b: 中国银行 纪念币 网上 怎么 预约; cosine_similarity: -0.08258
text_a: 电脑 反应 很 慢 怎么 办; text_b: 反应 速度 慢 , 电脑 总是 卡 是 怎么回事; cosine_similarity: 0.40820