0

How to find similarity of two words in Glove? We have model.similarity(word1, word2) in Word2vec. Is there a similar way in GloVe? How to save and load trained GloVe model?

halfer
  • 19,824
  • 17
  • 99
  • 186

2 Answers2

2

You can also use scikit-learn

from sklearn.metrics.pairwise import cosine_similarity
cosine_similarity([[1, 0, -1]], [[-1,-1, 0]])
array([[-0.5]])
nag
  • 749
  • 4
  • 9
1

You can use cosine similarity.

EDIT

You can use SciPy package. Python code for cosine similarity:

from scipy import spatial

word_1 = [3, 45, 7, 2]
word_2 = [2, 54, 13, 15]
result = 1 - spatial.distance.cosine(word_1, word_2)
Novak
  • 2,143
  • 1
  • 12
  • 22