Bird
0
0

Given the code below, what will be the output of print(model.wv['king'])?

medium📝 Predict Output Q13 of 15
NLP - Word Embeddings
Given the code below, what will be the output of print(model.wv['king'])?
from gensim.models import Word2Vec
sentences = [['king', 'queen', 'man', 'woman'], ['apple', 'banana', 'fruit']]
model = Word2Vec(sentences, vector_size=10, window=2, min_count=1, epochs=5)
print(model.wv['king'])
AA 10-dimensional numpy array representing 'king'
BThe string 'king'
CA list of words similar to 'king'
DAn error because 'king' is not in vocabulary
Step-by-Step Solution
Solution:
  1. Step 1: Understand model.wv['word'] output

    Accessing model.wv['king'] returns the vector (array) for 'king'.
  2. Step 2: Check training and vocabulary

    'king' is in sentences and min_count=1, so it's in vocabulary and has a vector of size 10.
  3. Final Answer:

    A 10-dimensional numpy array representing 'king' -> Option A
  4. Quick Check:

    model.wv['word'] = vector array [OK]
Quick Trick: model.wv[word] returns vector array [OK]
Common Mistakes:
MISTAKES
  • Expecting a string instead of vector
  • Confusing with similar words list
  • Assuming 'king' is missing from vocabulary

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes