Bird
0
0

Given the following Python code using Gensim FastText model:

medium📝 Predict Output Q13 of 15
NLP - Word Embeddings
Given the following Python code using Gensim FastText model:
from gensim.models import FastText
sentences = [['cat', 'sat', 'on', 'mat'], ['dog', 'barked']]
model = FastText(sentences, vector_size=10, window=3, min_count=1, epochs=5)
print(model.wv['cat'])
What will be the output type of model.wv['cat']?
AA numpy array representing the vector embedding of 'cat'
BAn integer representing the frequency of 'cat'
CA list of words similar to 'cat'
DA string with the word 'cat'
Step-by-Step Solution
Solution:
  1. Step 1: Understand what model.wv['word'] returns in Gensim FastText

    model.wv['cat'] returns the vector embedding as a numpy array representing the word 'cat'.
  2. Step 2: Check other options for output type

    A list of words similar to 'cat' is for similar words, not the vector. An integer representing the frequency of 'cat' is frequency, which is not returned here. A string with the word 'cat' is just the word string, not the vector.
  3. Final Answer:

    A numpy array representing the vector embedding of 'cat' -> Option A
  4. Quick Check:

    model.wv['word'] returns vector array [OK]
Quick Trick: model.wv['word'] gives vector array, not word list [OK]
Common Mistakes:
MISTAKES
  • Expecting a list of similar words instead of vector
  • Thinking it returns frequency count
  • Confusing word string with vector

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes