Cosine similarity is a metric that measures the cosine of the angle between two non-zero vectors in a multi-dimensional space, quantifying their orientation-based similarity irrespective of their magnitude. In machine learning, it is the standard measure for assessing the semantic similarity of vector embeddings, where a value of 1 indicates identical direction, 0 indicates orthogonality (no correlation), and -1 indicates opposite direction. This focus on angular separation makes it ideal for comparing text or image embeddings, where the overall meaning (direction) matters more than sheer size or frequency (magnitude).
