Bird
0
0

Given the following Python code snippet using pre-trained GloVe embeddings, what will be the output?

medium📝 Predict Output Q13 of 15
NLP - Word Embeddings
Given the following Python code snippet using pre-trained GloVe embeddings, what will be the output?
from gensim.models import KeyedVectors

glove = KeyedVectors.load_word2vec_format('glove.6B.50d.txt', binary=False)
result = glove.similarity('king', 'queen')
print(round(result, 2))
A0.00
B0.78
C1.00
D-0.50
Step-by-Step Solution
Solution:
  1. Step 1: Understand similarity method

    The similarity method returns a cosine similarity score between two word vectors, usually between 0 and 1 for related words.
  2. Step 2: Interpret expected similarity for 'king' and 'queen'

    These words are closely related, so the similarity is high but less than 1, typically around 0.78.
  3. Final Answer:

    0.78 -> Option B
  4. Quick Check:

    Similarity('king','queen') ≈ 0.78 [OK]
Quick Trick: Related words have similarity close to but less than 1 [OK]
Common Mistakes:
MISTAKES
  • Assuming similarity is always 1 for related words
  • Confusing similarity with distance
  • Expecting negative similarity for related words

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes