Every retrieval system computes this millions of times a second, and the difference between the loop version and the vectorised one is two orders of magnitude.
Given two matrices A of shape (n, d) and B of shape (m, d), return the (n, m) matrix where entry [i, j] is the cosine similarity between row i of A and row j of B.
Write it without any Python loops: no for, no while, no comprehension over rows.
Cosine similarity between vectors u and v is (u · v) / (||u|| * ||v||).
A zero vector has no direction, so its similarity to anything is defined here as 0.0 rather than nan. Handling that without a branch is most of the exercise.
Build the architecture on a canvas: place the components, configure them, connect them into a data flow, and write a short reason for each one. The AI reviewer grades your design against a rubric written specifically for this problem.
Minimum 5 components · needs a wide desktop screen