title: Gensim Doc2vec model: how to compute similarity on a corpus obtained using a pre-trained doc2vec model?
body: <p>I have a model based on <code>doc2vec</code> trained on multiple documents. I would like to use that model to infer the vectors of another document, which I want to use as the corpus for comparison. So, when I look for the most similar sentence to one I introduce, it uses this new document vectors instead of the trained corpus.
  Currently, I am using the <code>infer_vector()</code> to compute the vector for each one of the sentences of the new document, but I can't use the <code>most_similar()</code> function with the list of vectors I obtain, it has to be <code>KeyedVectors</code>.</p>
  
  <p>I would like to know if there's any way that I can compute these vectors for the new document that will allow the use of the <code>most_similar()</code> function, or if I have to compute the similarity between each one of the sentences of the new document and the sentence I introduce individually (in this case, is there any implementation in Gensim that allows me to compute the cosine similarity between 2 vectors?).</p>
  
  <p>I am new to Gensim and NLP, and I'm open to your suggestions.</p>
  
  <p>I can not provide the complete code, since it is a project for the university, but here are the main parts in which I'm having problems.</p>
  
  <p>After doing some pre-processing of the data, this is how I train my model:</p>
  
  <pre><code>documents = [TaggedDocument(doc, [i]) for i, doc in enumerate(train_data)]
  assert gensim.models.doc2vec.FAST_VERSION &gt; -1
  
  cores = multiprocessing.cpu_count()
  
  doc2vec_model = Doc2Vec(vector_size=200, window=5, workers=cores)
  doc2vec_model.build_vocab(documents)
  doc2vec_model.train(documents, total_examples=doc2vec_model.corpus_count, epochs=30)
  </code></pre>
  
  <p>I try to compute the vectors for the new document this way:</p>
  
  <pre><code>questions = [doc2vec_model.infer_vector(line) for line in lines_4]
  </code></pre>
  
  <p>And then I try to compute the similarity between the new document vectors and an input phrase:</p>
  
  <pre><code>text = str(input('Me: '))
  
  tokens = text.split()
  
  new_vector = doc2vec_model.infer_vector(tokens)
  
  index = questions[i].most_similar([new_vector])
  </code></pre>