โœ… Checkpoint: Vectors and Similarity

By Better Wise

Quiz

  1. You create `v = np.array([3.0, 2.0])` and `row = np.array([[3.0, 2.0]])`. What are their shapes?
    • v has shape (2,) and row has shape (1, 2)
    • Both have shape (2,)
    • v has shape (1, 2) and row has shape (2,)
    • v has shape (2, 1) and row has shape (1, 2)
  2. For v = (3, 2), what does multiplying by the scalar -1 do to the arrow?
    • It keeps the same length and flips the arrow to the opposite direction
    • It keeps the same direction and triples the length
    • It shrinks the arrow to half its length
    • It collapses the arrow to the zero vector
  3. Which NumPy call returns the L1 norm of the vector v?
    • np.linalg.norm(v, ord=1)
    • np.linalg.norm(v, ord=2)
    • np.linalg.norm(v)
    • np.linalg.norm(v, ord=np.inf)
  4. For u = (1, -2, 2), what are the L1, L2 and max norms?
    • L1 = 3, L2 = 5, max = 2
    • L1 = 5, L2 = 5, max = 5
    • L1 = -1, L2 = 3, max = 2
    • L1 = 5, L2 = 3, max = 2
  5. You compute the dot product of a = [2, 1] and b = [-1, 3] and get 1. What does the sign tell you about the angle between them?
    • The vectors point in exactly opposite directions
    • The angle is obtuse, above 90 degrees
    • The angle is acute, below 90 degrees
    • The angle is exactly 90 degrees, so they are orthogonal
  6. Two vectors have norms 3 and 7 and cosine similarity 0.6. What is their raw dot product?
    • 4.2
    • 12.6
    • 21
    • 0.6
  7. You scale one of two vectors by 10 before computing cosine similarity. What happens to the score?
    • It becomes undefined because the norms no longer match
    • It is divided by 10
    • It is multiplied by 10
    • It stays the same, because scaling changes length but not direction
  8. The L2 norm of the vector (3, 4) is ____.
  9. The distance between two vectors u and v is defined as the norm of their ____.
  10. In your own words, explain why a raw dot product can mislead you when ranking documents by similarity, and how cosine similarity fixes this. Then describe one situation where the raw dot product is still the better choice.

Sign in to submit answers.