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.
You have read the opening. The rest is free with a Bezen account, and no card is needed.
Behind the sign-in