Cosine similarity compares two vectors by the angle between them. Vectors pointing in nearly the same direction receive a high score; scores near 0 indicate unrelated directions, while scores near -1 indicate opposite directions. In face matching, the vectors are facial embeddings rather than raw pixels, so the score estimates whether two detected faces represent the same person. section 7.2.1
A practical face-matching flow is: detect and crop a face from each image, generate an embedding for each crop, then calculate cosine similarity between the embeddings. High scores support a match and low scores support a mismatch, but a threshold turns the continuous score into an operational duplicate or identity decision. section 7.2.1 section 7.2.3
Cosine similarity can also participate directly in training. A Siamese network runs two images through replicas of the same CNN, compares the resulting embeddings, passes the similarity through a sigmoid, and measures error against a same-person or different-person label using binary cross-entropy. Backpropagation then encourages same-person embeddings to become similar and different-person embeddings to become separable. section 7.2.2
Duplicate and ID checks
Two photos of Albert Einstein produced 76.52% similarity, while Einstein versus John McCarthy produced 9.92%; a 50% threshold was suggested for that duplicate-check example. Comparing an Einstein selfie with an ID photo produced 61.54%, whereas a different person's ID produced 2.52%. A 100% score may be suspicious when the identical photo was uploaded twice or pasted onto a fraudulent ID. section 7.2.3 section 7.2.4
Figure 7.17 Demonstration of duplicate check implemented using face-matching which is broken down into three stages – face detection, face recognition, and cosine similarity. For the 4 example pairs, the first two pairs are of the same person (Einstein), therefore a high similarity score. The third pair contains different people (Einstein and McCarthy) leading to a low score. Last pair has the exact same photos, producing an abnormally high score of 100%.
Inspect the end-to-end duplicate-check pipeline and compare high, low, and abnormally perfect similarity scores across face pairs. section 7.2.3
























