Implement a function in Python to efficiently compute the cosine similarity between millions of document embeddings.