<p>I have no idea what the <code>tinyTextR</code> package's <code>Doc2Vec</code> function that you've mentioned is doing - Google searches turn up no documentation of its functionality. But if it's instant, and it requires word-vectors as an input, perhaps it's just averaging all the word-vectors for the text's words together.</p>
<p>You can read all about Gensim's <code>Doc2Vec</code> model in the Gensim documentation:</p>
<p><a href="https://radimrehurek.com/gensim/models/doc2vec.html" rel="nofollow noreferrer">https://radimrehurek.com/gensim/models/doc2vec.html</a></p>
<p>As its intro explains:</p>
<blockquote>
<p>Learn paragraph and document embeddings via the distributed memory and distributed bag of words models from <a href="https://arxiv.org/abs/1405.4053v2" rel="nofollow noreferrer">Quoc Le and Tomas Mikolov: “Distributed Representations of Sentences and Documents”</a>.</p>
</blockquote>
<p>The algorithm that Gensim <code>Doc2Vec</code> implements is also commonly called 'Paragraph Vector' by its authors, including in the followup paper by Le et al <a href="https://arxiv.org/abs/1507.07998" rel="nofollow noreferrer">&quot;Document Embeddings With Paragraph Vector&quot;</a>.</p>
<p>'Paragraph Vector' uses a word2vec-like training process to learn text-vectors for paragraphs (or other texts of many words). This process does <em>not</em> require prior word-vectors as an input, but many modes will co-train word-vectors along with the doc-vectors. It <em>does</em> require training on a set of documents, but after training the <code>.infer_vector()</code> method can be used to train-up vectors for new texts, not in the original training set, to the extent they use the same words. (Any new words in such post-model-training documents will be ignored.)</p>
<p>You might be able to approximate your R function with something simple like an average-of-word-vectors.</p>
<p>Or, you could try the alternate <code>Doc2Vec</code> in Gensim.</p>
<p>But, the Gensim <code>Doc2Vec</code> is definitely something different, and it's unfortunate the two libraries use the same <code>Doc2Vec</code> name for different processes.</p>
Gensim: Is doc2vec a model or operation? Differences from R implementation
<p>I have been tasked with putting a document vector model into production.
I am an R user, and so my original model is in R. One of the avenues we have is to recreate the code and the models in Python.</p>
<p><strong>I am confused by the Gensim implementation of Doc2vec</strong>.</p>
<p>The process that works in R goes like this:</p>
<p><strong>Offline</strong></p>
<hr />
<ul>
<li><p>Word vectors are trained using the functions in the <code>text2vec</code> package, namely GloVe or GlobalVectors, on a large corpus This gives me a large Word Vector text file.</p>
</li>
<li><p>Before the ML step takes place, the <code>Doc2Vec</code> function from the <code>TextTinyR</code> library is used to turn each piece of text from a smaller, more specific training corpus into a vector. <em>This is not a machine learning step. No model is trained</em>. The Doc2Vec function effectively aggregates the word vectors in the sentence, in the same sense that finding the sum or mean of vectors does, but in a way that preserves information about word order.</p>
</li>
<li><p>Various models are then trained on these smaller text corpuses.</p>
</li>
</ul>
<hr />
<p><strong>Online</strong></p>
<hr />
<ul>
<li>The new text is converted to Document Vectors using the pretrained word vectors.</li>
<li>The Document Vectors are fed into the pretrained model to obtain the output classification.</li>
</ul>
<hr />
<p><strong>The example code I have found for Gensim appears to be a radical departure from this.</strong></p>
<p>It appears in <code>gensim</code> that Doc vectors are a separate class of model from word vectors that you can train. It seems in some cases, the word vectors and doc vectors are all trained at once. Here are some examples from tutorials and stackoverflow answers:</p>
<p><a href="https://medium.com/@mishra.thedeepak/doc2vec-simple-implementation-example-df2afbbfbad5" rel="nofollow noreferrer">https://medium.com/@mishra.thedeepak/doc2vec-simple-implementation-example-df2afbbfbad5</a></p>
<p><a href="https://stackoverflow.com/questions/27470670/how-to-use-gensim-doc2vec-with-pre-trained-word-vectors">How to use Gensim doc2vec with pre-trained word vectors?</a></p>
<p><a href="https://stackoverflow.com/questions/36815038/how-to-load-pre-trained-model-with-in-gensim-and-train-doc2vec-with-it?rq=1">How to load pre-trained model with in gensim and train doc2vec with it?</a></p>
<p><a href="https://stackoverflow.com/questions/45037860/gensim1-0-1-doc2vec-with-google-pretrained-vectors?noredirect=1&amp;lq=1">gensim(1.0.1) Doc2Vec with google pretrained vectors</a></p>
<p>So my questions are these:</p>
<p><strong>Is the gensim implementation of Doc2Vec fundamentally different from the TextTinyR implementation?</strong></p>
<p><strong>Or is the gensim doc2vec model basically just encapsulating the word2vec model and the doc2vec process into a single object?</strong></p>
<p><strong>Is there anything else I'm missing about the process?</strong></p>