0
0
NLPml~10 mins

FastText embeddings 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 load FastText model from gensim.

NLP
from gensim.models import FastText
model = FastText.load('[1]')
Drag options to blanks, or click blank then click option'
Afasttext.txt
Bfasttext.bin
Cfasttext.model
Dfasttext.vec
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong file extension like .bin or .vec which are not gensim model files.
Trying to load a text vector file instead of the model.
2fill in blank
medium

Complete the code to get the vector for the word 'apple' using FastText model.

NLP
vector = model.wv.[1]('apple')
Drag options to blanks, or click blank then click option'
Aget_vector
Bword_vec
Cvector
Dembedding
Attempts:
3 left
💡 Hint
Common Mistakes
Using model.wv.vector which does not exist.
Using model.wv.word_vec which is deprecated.
3fill in blank
hard

Fix the error in the code to train a FastText model on sentences.

NLP
from gensim.models import FastText
sentences = [['hello', 'world'], ['fasttext', 'embedding']]
model = FastText(sentences=[1], vector_size=50, window=3, min_count=1, epochs=10)
Drag options to blanks, or click blank then click option'
Asentence
Bcorpus
Cdata
Dsentences
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sentence' instead of 'sentences' causes a TypeError.
Passing data with wrong parameter name.
4fill in blank
hard

Fill both blanks to create a FastText model and train it on data.

NLP
model = FastText([1], vector_size=100, window=5, min_count=2)
model.[2](sentences, total_examples=len(sentences), epochs=5)
Drag options to blanks, or click blank then click option'
Asentences
Btrain
Cfit
Dfit_transform
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fit' or 'fit_transform' which are not methods of gensim FastText.
Not passing the training data correctly.
5fill in blank
hard

Fill both blanks to create a dictionary of word vectors for words longer than 3 characters.

NLP
word_vectors = {word: model.wv.[1](word) for word in model.wv.index_to_key if len(word) [2] 3 and word.isalpha()}
filtered_vectors = {k: v for k, v in word_vectors.items() if v is not None and v.any()}
print(len(filtered_vectors))
Drag options to blanks, or click blank then click option'
Aget_vector
B>
C<
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect comparison operators like '<' or '=='.
Using wrong method names to get vectors.