Home>

This is a question when using gensim to output high-level words with high cosine similarity.

model.wv.most_similar (["word"])


If I want to put the direct vector of the argument of the most_similar function here, how should you write it?

a = [0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1 , 0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1 , 0.1]
    model.wv.most_similar (a)

I couldn't write it like this.

  • Answer # 1

    model.wv.most_similar ([may_country_vec], [], 5)

    Put a vector in may_country_vec

    5 displays 5 words with high similarity

  • Answer # 2

    Have you seen https://tedboy.github.io/nlps/generated/generated/gensim.models.Word2Vec.html?

    Isn't it similar_by_vector?