Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q5 of 15
NLP - Word Embeddings
What will be the output of this code?
from gensim.models import FastText
sentences = [['cat', 'dog'], ['dog', 'mouse']]
model = FastText(sentences, vector_size=5, window=2, min_count=1, epochs=3)
vector1 = model.wv['cat']
vector2 = model.wv['dog']
import numpy as np
print(np.dot(vector1, vector2))
AError: 'cat' not in vocabulary
Bnull
CA vector of length 5
DA float number representing similarity
Step-by-Step Solution
Solution:
  1. Step 1: Understand dot product of word vectors

    Dot product between two vectors returns a single float number representing similarity.
  2. Step 2: Check vocabulary and vector retrieval

    Both 'cat' and 'dog' are in the training sentences, so vectors exist and dot product is valid.
  3. Final Answer:

    A float number representing similarity -> Option D
  4. Quick Check:

    Dot product output = float number = B [OK]
Quick Trick: Dot product of vectors returns a single float [OK]
Common Mistakes:
MISTAKES
  • Expecting vector output from dot product
  • Assuming word missing from vocabulary
  • Confusing dot product with concatenation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes