Cosine similarity measures the closeness of two vectors by the cosine of the angle between them: 1 for the same direction, 0 for orthogonal vectors, -1 for opposite directions. It ignores vector norm, which makes it suitable for comparing embeddings or TF-IDF vectors.
Example
np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))