What Is a Siamese Network?
A Siamese neural network is built to answer one question: how similar are these two things? It passes both inputs through the same network, turns each into a list of numbers (an embedding), and measures the distance between the two lists. A small distance means similar; a large distance means different.
The name comes from the picture of two identical networks side by side, like twins. In practice there is only one network, used twice. Its two branches share exactly the same weights.
Why the Shared Weights Matter
Because both inputs go through the same weights, their embeddings live in the same space and the distance between them means something. Two separately trained networks would each invent their own coordinate system, and comparing their outputs would be like comparing a distance in miles with one in kilometres.
Shared weights also mean that anything can be embedded once and compared later. That is what makes large-scale search practical: every stored item is embedded ahead of time, and a new query only needs one pass through the network.
How Siamese Networks Are Trained
The classic way to train a Siamese network is with pairs. Contrastive loss shows the network two examples labelled same or different, pulling same pairs together and pushing different pairs at least a set margin apart. Triplet loss uses an anchor, a matching example and a non-matching one, and asks the match to be closer to the anchor than the non-match by a margin.
Pair and triplet training learn a general sense of similarity rather than a fixed list of classes, so the network can compare things it has never seen before. That is exactly what face matching needs: the celebrities you are compared with were not in the training data.
Siamese Networks in Face Recognition
Early deep face recognition systems leaned heavily on these ideas. Google's FaceNet (2015) trained with triplet loss and reached 99.63% on the LFW benchmark.
Later research found a more stable route to the same goal. Losses such as SphereFace (2017), CosFace (2018) and ArcFace (2019) train the network to classify thousands of people with an extra margin, then throw the classifier away and keep the embedding. The result is used exactly like one branch of a Siamese network: embed two faces, measure the distance.
How Ollie Relates to the Siamese Idea
Ollie's network was trained with CosFace on the MS1MV2 dataset, not with pairs. At search time, though, it works on the Siamese principle: the same network with the same weights embeds your photo and every celebrity photo, and the closest embeddings are your matches.
The celebrity embeddings are computed once, ahead of time. When you search, only your photo goes through the network, and comparing your embedding with thousands of stored ones takes milliseconds.
Beyond Faces
The same design shows up wherever two things need comparing: checking a signature against a known one, finding near-duplicate images, matching product photos, and one-shot learning, where a system must recognise something new from a single example.
