liveBook · Manning

Embedding

As explained in Fight Fraud with Machine Learning

An embedding is a learned vector representation that encodes properties or relationships of an input such as an image, text, or word.

An embedding is a vector representation produced from an input such as an image, word, sentence, or graph node. Learned embeddings encode useful properties or relationships so that related inputs occupy similar positions in an embedding space. section 7.2.2 section 9.3.1

A fraud-oriented face-matching workflow uses embeddings as follows:

  • Run a face image through a CNN such as Inception Resnet V1 to produce an embedding. section 7.2.2 section 7.2.4
  • Compare selfie and identity-document embeddings with cosine similarity. section 7.2.4
  • Train a Siamese network on same-person and different-person image pairs, using binary cross-entropy to improve the embeddings. section 7.2.2

Embedding meaning depends on the input structure. Image embeddings summarize one image independently; text embeddings incorporate preceding-word context; node embeddings also incorporate a graph node’s neighborhood. section 9.3.1 section 5.2.1

Selfie-to-ID fraud check

An Einstein selfie compared with his genuine ID produces a 61.54% similarity score, while Monroe’s ID produces 2.52%. A fake ID reusing Einstein’s selfie produces 100%, an abnormally high result that signals image reuse rather than identity confidence. section 7.2.4

Figure 7.12 Demonstration of how a face recognition model is trained using the Siamese network. Two copies of a CNN model produce two different embeddings for two different faces (images). These embeddings produce a cosine similarity score. This score is passed through a sigmoid function and compared to the label (1 if faces are from same person and vice versa) using a loss function such as binary cross entropy.

Trace the Siamese-network pipeline from two face images through replicated CNNs, embeddings, cosine similarity, sigmoid scoring, and binary cross-entropy. section 7.2.2

How Fight Fraud with Machine Learning covers it

How deep it goes
Explains vector generation, similarity, pairwise training, contextual text, and graph neighborhoods, but stops short of embedding mathematics.
Examples
Demonstrates Einstein and Monroe face comparisons, one-hot word vectors, contextual sentences, and graph nodes whose neighborhoods reveal similarity.
What you can do after
Apply it via MTCNN and Inception Resnet V1 to compare selfie and ID faces with cosine similarity and flag suspicious scores.
How it connects
Ties embeddings to Siamese networks, cosine similarity, convolutional neural networks, transformers, positional encoding, and graph neural networks.

Also explained in

Compare how 72 books explain embedding →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fight Fraud with Machine Learning. The section links point to the parts of the book it draws on.