I have been given a doc2vec model using gensim which was trained on 20 Million documents. The 20 Million documents it was trained are also given to me but I have no idea how or which order the documents were trained in from the folder. I am supposed to use the test data to find the top 10 match from the training set. The code I use is -
model = gensim.models.doc2vec.Doc2Vec.load("doc2vec_sample.model")
test_docs=["This is the test set I want to test on."]
def read_corpus(documents, tokens_only=False):
count=0
count=count+1
for line in documents:
if tokens_only:
yield gensim.utils.simple_preprocess(line)
else:
# For training data, add tags
yield gensim.models.doc2vec.TaggedDocument(gensim.utils.simple_preprocess(line), [count])
test_corpus = list(read_corpus(test_docs, tokens_only=True))
doc_id=0
inferred_vector = model.infer_vector(test_corpus[doc_id])
maxx=10
sims = model.docvecs.most_similar([inferred_vector], topn=maxx)
for match in sims:
print match
` The output I get is -
(1913, 0.4589531719684601)
(3250, 0.4300411343574524)
(1741, 0.42669129371643066)
(1, 0.4023148715496063)
(1740, 0.3929900527000427)
(1509, 0.39229822158813477)
(3189, 0.387174129486084)
(3145, 0.3842133581638336)
(1707, 0.3813004493713379)
(3200, 0.3754497170448303)
How do I get to know which document does document id "1913" refer to? How can I access the documents of the trained data set from these 10 job ids?