Let's Train The Model

Once we have configured the gensim word2vec object, we need to give the model some training.  Be prepared, as this might take some time depending on the amount of data and the computation power you have.  In this process we have to define the number of epochs we need to run, it can vary depending on your data size. You can play around with this values and evaluate you word2vec models performance.

Also, we will save the trained model so that we can use it later on while building our language models:

"""**Start training, this might take a minute or two...**"""

model2vec.train(sentences ,total_examples=model2vec.corpus_count , epochs=100)

"""**Save to file, can be useful later**"""

if not os.path.exists(os.path.join("trained",'sample')):
os.makedirs(os.path.join("trained",'sample'))

model2vec.save(os.path.join("trained",'sample', ".w2v"))

Once the training process is completed you can see a binary file stored in /trained/sample.w2v . You can share this file with other and load it later into any other NLP task.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.142.2