Search code examples
word2vecgensimdoc2vec

doc2vec: any way to fetch closest matching terms for a given vector?


The use-case I have is to have a collection of "upvoted" documents and "downvoted" documents and using those to re-order a set of results in a search.

I am using gensim doc2vec and am able to run the most_similar queries for word(s) and fetch matching words. But how would I be able to fetch the matching keywords given a vector fetched by a vector sum of the above doc vectors?


Solution

  • Ohh silly me, I found the answer staring right in my face, posting here in case anyone else has the issue:

    similar_by_vector(vector, topn=10, restrict_vocab=None)
    

    This is however found not in the Doc2Vec class, but in the KeyedVector class.