0
0
NLPml~10 mins

Training Word2Vec with Gensim in NLP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Word2Vec model from gensim.

NLP
from gensim.models import [1]
Drag options to blanks, or click blank then click option'
AWordToVec
BWord2Vec
CWordVec
Dword2vec
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'word2vec' which is not the class name.
Misspelling the class name like 'WordVec' or 'WordToVec'.
2fill in blank
medium

Complete the code to initialize a Word2Vec model with vector size 100.

NLP
model = Word2Vec(sentences, vector_size=[1], window=5, min_count=1, workers=4)
Drag options to blanks, or click blank then click option'
A300
B50
C200
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Using vector size too small or too large without reason.
Confusing vector_size with window size.
3fill in blank
hard

Fix the error in the code to train the Word2Vec model on sentences.

NLP
model.[1](sentences)
Drag options to blanks, or click blank then click option'
Atrain
Bfit
Clearn
Dfit_transform
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fit' which is common in scikit-learn but not in gensim.
Using 'fit_transform' which is not a Word2Vec method.
4fill in blank
hard

Fill both blanks to create a dictionary of word vectors for words with frequency above 2.

NLP
word_vectors = {word: model.wv.[1](word) for word in model.wv.index_to_key if model.wv.get_vecattr(word, '[2]') > 2}
Drag options to blanks, or click blank then click option'
Aget_vector
Bcount
Cfrequency
Dvector
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'vector' instead of 'get_vector' to get word vectors.
Using 'frequency' instead of 'count' for word frequency attribute.
5fill in blank
hard

Fill all three blanks to save the trained model and then load it back.

NLP
model.[1]('word2vec.model')
loaded_model = Word2Vec.[2]('word2vec.model')
vector = loaded_model.wv.[3]('example')
Drag options to blanks, or click blank then click option'
Asave
Bload
Cget_vector
Dtrain
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'train' instead of 'save' or 'load'.
Using 'vector' instead of 'get_vector' to get word vectors.