How to find the closest word to a vector using word2vec

前端 未结 3 609
忘了有多久
忘了有多久 2021-02-02 10:16

I have just started using Word2vec and I was wondering how can we find the closest word to a vector suppose. I have this vector which is the average vector for a set of vectors

3条回答
  •  余生分开走
    2021-02-02 10:37

    Don't forget to add empty array with negative words in most_similar function:

    import numpy as np
    model_word_vector = np.array( my_vector, dtype='f')
    topn = 20;
    most_similar_words = model.most_similar( [ model_word_vector ], [], topn)
    

提交回复
热议问题