Write a function to compute the cosine similarity between millions of user profiles efficiently for Amplify HR.