Bird
0
0

Consider this Python code snippet:

medium📝 Debug Q7 of 15
NLP - Word Embeddings
Consider this Python code snippet:
king = np.array([0.5, 0.8])
man = np.array([0.6, 0.9])
woman = np.array([0.45, 0.75])
queen = king - man + woman
print(queen)

Why might this code not produce the expected analogy result?
ABecause the vectors have different dimensions
BBecause numpy arrays cannot be subtracted or added directly
CBecause the code does not find the closest word vector to the resulting vector
DBecause the print statement is missing parentheses
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the operation

    The code performs vector arithmetic but does not search for the closest matching word vector.
  2. Step 2: Check other options

    NumPy supports vector addition/subtraction; vectors have same dimensions; print syntax is correct.
  3. Final Answer:

    Because the code does not find the closest word vector to the resulting vector -> Option C
  4. Quick Check:

    Vector math alone doesn't find the best matching word [OK]
Quick Trick: Vector math needs nearest neighbor search [OK]
Common Mistakes:
MISTAKES
  • Assuming vector arithmetic returns a valid word vector
  • Ignoring the need to find closest vector in vocabulary

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes