Machine learning models · Phase 4 · Lesson 34

Embeddings and representation learning

Understand embeddings as learned coordinates where useful relationships become geometric.

This is one focused step in the 60-lesson course. Use the retrieval check before moving on.

Lesson goal

Understand embeddings as learned coordinates where useful relationships become geometric.

The core idea

An embedding turns a discrete object into a vector. The training objective shapes which similarities are useful, so there is no universally correct embedding space.

Mental model

Picture it this way. An embedding turns a discrete object into a vector. The training objective shapes which similarities are useful, so there is no universally correct embedding space. The important question is what assumption this picture makes, and whether that assumption fits the data.

Mathematical core

A lookup table maps an index to a vector. Contrastive, predictive or co-occurrence objectives adjust vectors so selected relationships are closer or more useful.

Worked example

A product embedding can place products with similar browsing or purchase contexts near one another, enabling retrieval and recommendations.

When to use it

It earns a place when

  • Use embeddings for text, users, items, categories, images and other high-cardinality objects where similarity or downstream prediction matters.
  • You can evaluate it against a credible baseline.
  • Its output fits the decision and data constraints.

Do not make it the default when

  • Do not assume nearby vectors share a moral or causal meaning, and do not expose sensitive attributes through an embedding without auditing.
  • A simpler model has not been tested.
  • The data or target definition is still unclear.

Failure modes

Watch for this. Embeddings inherit dataset bias and can encode shortcuts. Nearest neighbours can look plausible while failing on rare cases.

When a result looks surprisingly good, inspect the split, target timing, error slices and data-generating process before celebrating.

Practice

Use this as a small experiment rather than a recipe to copy blindly. Change one thing, record the result and explain the change.

Do this. Train a small embedding model or inspect pretrained vectors. Retrieve nearest neighbours, then check whether the similarity matches the task rather than intuition.

Retrieval check

Answer from memory first. The buttons reveal feedback, but the durable step is explaining why.

1. What is an embedding?

2. What determines what an embedding means?

3. Why audit embeddings?

Transfer prompt. Describe one real problem where this model or idea would be a sensible candidate. Name the target, the main risk and the metric you would inspect.

Primary source

Google ML Crash Course. Use the source for the deeper treatment after you can explain the lesson's core idea without looking.