I'm trying to use doc2vec(gensim) to identify the most similar sentence and get its label. That is, for example, when the data is composed of 36 types of TVs (each sentence explains a specific product and its labeled to that product), the doc2vec categorizes the user input and decides what TV the user is referring to.

I only know how to get the most similar word: model.most_similar('red/noun') How can you, instead of words, get the most similar sentence and its label?

Doc2Vec - How to label the paragraphs (gensim) (this tells that the above method is actually possible in doc2vec)

Thank you :)


As far as I understood you are using type of TV as tag of particular sentence , and you are using doc2vec model for future classification . So As above answer is suggesting that model will learn semantic meaning of type of TV(tag).

let's suppose s is your future sentence for prediction. then you use infer vector.

model = Load_model('model.doc2vec')

infer_vector = model.infer_vector(s)

similar_documents = model.docvecs.most_similar([infer_vector], topn = 1)

here similar document is list of tuples. where first element is label.

let me know if this help you.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.