📜  doc2vec 相似度 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:05.471000             🧑  作者: Mango

代码示例1
from gensim.models import doc2vec
from scipy import spatial

d2v_model = doc2vec.Doc2Vec.load(model_file)

fisrt_text = '..'
second_text = '..'

vec1 = d2v_model.infer_vector(fisrt_text.split())
vec2 = d2v_model.infer_vector(second_text.split())

similairty = spatial.distance.cosine(vec1, vec2)
# similarity is how much two text differ from each other, higher values mean more distinct texts