Concept notebookChecking saved investigationReading browser-local route memory before showing a continuation.

Representation Learning & Embedding Geometry

How models turn inputs into vectors whose geometry can expose useful factors, contextual meaning, and similarity structure.

published · difficulty 3/5 · 18 min read

01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

PredictName the object in plain language, then predict what should change.Leave with one reusable mental picture before notation appears.

A model can only "think" in the space it uses internally. In deep learning, that internal space is usually a vector space: an embedding.

A common goal of representation learning is to make learned features expose useful factors of variation. We want vectors where:

  • things that "mean the same" are close,
  • things that are different point in different directions,
  • and simple operations (dot products, distances, averages) line up with useful questions (retrieval, clustering, analogy, control).

When this works, embeddings become an interface. Depending on the model and training objective, they are often used for similarity search, lightweight classifiers, or analyses of directions in representation space. When it fails, vectors collapse into weird shapes (anisotropy, degenerate norms) and similarity becomes noisy.

Context matters too. A static word vector gives one vector to a word type, but a contextual representation lets the token "bank" move depending on whether the surrounding sentence is about rivers or money. That is the ELMo lesson: the useful feature is not only the token identity, but the token identity as interpreted through its context.

Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

02

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

InspectTrack the same object through the notation and check each symbol.Leave with the invariant the equations preserve.

Let an encoder map inputs to vectors. If a simple downstream predictor can recover a useful factor from the vector, the representation has made that factor easier to extract. For contextual word representations, the token vector can depend on the whole sentence:

z=fθ(x)Rd,a^=gψ(z),ELMoktask=γtaskj=0Lsjtaskhk,jLM(t1,,tN).\begin{aligned} z &= f_\theta(x)\in\mathbb R^d,\qquad \hat a = g_\psi(z),\\ \operatorname{ELMo}^{\mathrm{task}}_k &= \gamma^{\mathrm{task}}\sum_{j=0}^{L}s^{\mathrm{task}}_j\, h^{\mathrm{LM}}_{k,j}(t_1,\ldots,t_N). \end{aligned}zELMoktask=fθ(x)Rd,a^=gψ(z),=γtaskj=0Lsjtaskhk,jLM(t1,,tN).

Here aaa is a useful factor or label we hope is easy to read from zzz, gψg_\psigψ is a simple extractor such as a classifier or probe, and hk,jLMh^{\mathrm{LM}}_{k,j}hk,jLM is the bidirectional language-model state for token position kkk at layer jjj. Peters et al. use task-specific softmax weights sjtasks_j^{\mathrm{task}}sjtask and scale γtask\gamma^{\mathrm{task}}γtask to combine the biLM layers, so the same token position can receive a different vector in a different sentence.

Similarity as a dot product (often cosine)

A common choice is cosine similarity, which is just a dot product of normalized vectors:

sim(z,z)=zzz2z2=z^z^.\mathrm{sim}(z, z') = \frac{z^\top z'}{\lVert z\rVert_2\,\lVert z'\rVert_2} = \hat z^\top \hat z'.sim(z,z)=z2z2zz=z^z^.

Normalization matters because it makes similarity depend on direction instead of length.

Contrastive learning (InfoNCE)

Suppose we have "positive pairs" (xi,yi)(x_i, y_i)(xi,yi) (two views of the same thing: two crops of an image, two versions of a sentence, etc.). Encode them:

zi=fθ(xi),ui=gθ(yi).z_i = f_\theta(x_i), \qquad u_i = g_\theta(y_i).zi=fθ(xi),ui=gθ(yi).

InfoNCE treats (zi,ui)(z_i, u_i)(zi,ui) as the correct match among a batch of candidates:

L=1Ni=1Nlogexp(sim(zi,ui)/τ)j=1Nexp(sim(zi,uj)/τ).\mathcal L = -\frac{1}{N} \sum_{i=1}^N \log \frac{\exp\big(\mathrm{sim}(z_i, u_i)/\tau\big)}{\sum_{j=1}^N \exp\big(\mathrm{sim}(z_i, u_j)/\tau\big)}.L=N1i=1Nlogj=1Nexp(sim(zi,uj)/τ)exp(sim(zi,ui)/τ).
  • τ>0\tau > 0τ>0 is the temperature: smaller τ\tauτ makes the softmax sharper (harder negatives, bigger gradients).
  • In contrastive-learning setups, this kind of objective scores the intended pair above other candidates.

A useful geometry sanity check: anisotropy

Embeddings often become anisotropic (many points bunch along a few dominant directions). A practical check is the covariance of normalized embeddings:

C=1Ni=1N(z^izˉ)(z^izˉ).C = \frac{1}{N}\sum_{i=1}^N (\hat z_i - \bar z)(\hat z_i - \bar z)^\top.C=N1i=1N(z^izˉ)(z^izˉ).

If a few eigenvalues dominate, the embedding cloud is highly directional, which can affect cosine-based comparisons. Normalization or whitening-style preprocessing can change this geometry.

Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

TraceMatch variables to symbols before reading the implementation.Leave with a runnable witness for the math.
import numpy as np

def unit(v):
    return v / (np.linalg.norm(v) + 1e-9)

# Toy handcrafted features: axis 0 = water-vs-finance context,
# axis 1 = the token identity "bank", axis 2 = filler.
feat = {
    "river": np.array([1.0, 0.0, 0.0]),
    "shore": np.array([1.0, 0.0, 0.0]),
    "money": np.array([-1.0, 0.0, 0.0]),
    "loan": np.array([-1.0, 0.0, 0.0]),
    "bank": np.array([0.0, 1.0, 0.0]),
}

def contextual(left, token, right):
    return unit(0.55 * feat[token] + 0.35 * (feat[left] + feat[right]))

static_bank = unit(feat["bank"])
river_bank = contextual("river", "bank", "shore")
money_bank = contextual("money", "bank", "loan")

water_probe = unit(np.array([1.0, 0.0, 0.0]))
def water_score(z):
    return float(z @ water_probe)

print("static bank:", round(water_score(static_bank), 3))
print("river bank: ", round(water_score(river_bank), 3))
print("money bank: ", round(water_score(money_bank), 3))

assert water_score(river_bank) > water_score(static_bank) > water_score(money_bank)
assert np.linalg.norm(river_bank - money_bank) > 1.4
Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

04

04

Interactive Demo

Use direct manipulation to connect the explanation to a moving system.

ManipulateChange one control and predict the visible response before reveal.Leave with the observed invariant or a repaired model.

Live Concept Demo

Explore Representation Learning & Embedding Geometry

The stage is code-native and interactive. Use it to test the explanation against the mechanism.

difficulty 3/5undergraduatecode-aligned
Demo inquiry checkpoint

Manipulate one control and predict the visible change.

01Choose lensTrace a quantity
02ObserveDemo state pending
03GroundName the equation, invariant, or control that explains it.
04CarryNext: superposition

Choose what to inspect in Representation Learning & Embedding Geometry. This shared fallback is an observation guide, not evidence of learning.

Loading interactive demo...

Use the demos to build geometric intuition:

  • how normalization changes similarity (direction vs length),
  • how "directions" in representation space can encode behaviors (task vectors),
  • and how geometric constraints like equivariance preserve structure.
Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

4/4 sections ready

Concept: Representation Learning & Embedding Geometry

What is the smallest example that makes Representation Learning & Embedding Geometry click without losing the math?

BeforeScaled Dot-Product Attention & Transformer LayersNow4/4 sections readyTryManipulate one control and predict the visible change.Nextsuperposition
Object contextRepresentation Learning
ConceptLearner lens

Representation Learning & Embedding Geometry

What is the smallest example that makes Representation Learning & Embedding Geometry click without losing the math?

Mode questionCan I say the mechanism back in one sentence before I reveal anything?

Start with the prediction checkpoint, then compare the reveal to the mental model.

Take this move

Study modes

Keep the object fixed; change the lens.

Route back through the notebook

Carry the same object through intuition, math, code, and demo.

4/4 sections ready
Carry inScaled Dot-Product Attention & Transformer Layers

Bring the mental model from Scaled Dot-Product Attention & Transformer Layers; this page will reuse it instead of restarting from zero.

Work hereRepresentation Learning & Embedding Geometry

How models turn inputs into vectors whose geometry can expose useful factors, contextual meaning, and similarity structure.

Carry outsuperposition

The next edge should feel earned: use the demo prediction here before following superposition.

After The First Pass

Turn the concept into an inspected object.

The lower panels are one second act: keep the object fixed, inspect it visually, check source boundaries, practice transfer, then attach the research question.
ConceptRepresentation Learning & Embedding GeometryRepresentation Learning

Mechanism Storyboard

See the idea move before the page explains it

How models turn inputs into vectors whose geometry can expose useful factors, contextual meaning, and similarity structure.

Demo notes open01 / Intuition
Editorial representation-learning illustration of embedding clusters, geometric neighborhoods, and feature directions.
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

Before reading further, choose the kind of change Representation Learning & Embedding Geometry should make visible.

Visual Inquiry

Make the image answer a mathematical question

How models turn inputs into vectors whose geometry can expose useful factors, contextual meaning, and similarity structure.

4/4 stages readyDemo notes connected
Prediction

Which visible object should carry the first intuition?

Commit first

Pick the cue that should make Representation Learning & Embedding Geometry easier to reason about before the page gives the answer.

Source Grounding

Canonical references for the mechanism on this page.

Object - ConceptRepresentation Learning & Embedding GeometryQuestion

What is the smallest example that makes Representation Learning & Embedding Geometry click without losing the math?

concept:representation-learning/representations
Boundary

sources: bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpc

Check

Open the closest source note before trusting the local explanation.

Evidence

3 selected-object sources shown first; 3 references total.

Next move

Audit the claim boundary, then ask from the same selected object.

selected object source · paper · 2013Representation Learning: A Review and New PerspectivesBengio, Courville, and Vincent
Located CF editorial boundary

Grounds representation learning as learning useful explanatory factors and feature geometry.

Used here as

Bengio et al. frame representation learning as learning transformations that expose useful explanatory factors and make useful information easier to extract. Peters et al. introduce ELMo...

Caveat

Checks only useful-factor extraction and ELMo-style contextual token dependence. It does not certify InfoNCE, retrieval quality, task vectors, anisotropy fixes, equivariance, parallel tra...

Open source
selected object source · paper · 2018Deep contextualized word representationsPeters et al.
Located CF editorial boundary

Grounds contextual embeddings as representations whose meaning changes with surrounding context.

Used here as

Bengio et al. frame representation learning as learning transformations that expose useful explanatory factors and make useful information easier to extract. Peters et al. introduce ELMo...

Caveat

Checks only useful-factor extraction and ELMo-style contextual token dependence. It does not certify InfoNCE, retrieval quality, task vectors, anisotropy fixes, equivariance, parallel tra...

Open source
selected object source · paper · 2018Representation Learning with Contrastive Predictive Codingvan den Oord, Li, and Vinyals
Located CF editorial boundary

Grounds contrastive predictive coding and InfoNCE-style losses that score positive pairs against negative samples.

Used here as

The selected object cites this source; inspect the exact claim before treating it as support.

Caveat

Attached source metadata is a review boundary, not proof of the local explanation.

Open source

Claim Review

How models turn inputs into vectors whose geometry can expose useful factors, contextual meaning, and similarity structure.

Object - ConceptRepresentation Learning & Embedding GeometryQuestion

What is the smallest example that makes Representation Learning & Embedding Geometry click without losing the math?

concept:representation-learning/representations
Boundary

sources: bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpc

Check

Treat every claim as provisional until source support and a local witness agree.

Evidence

1 structured claim check on this concept.

Next move

Run the prediction or practice transfer before asking for a grounded review.

1 CF editorial source-scope review recorded

Publisher-side editorial review is not independent replication. Claims without it still need exact source-support review. 3 references and 3 local witnesses are available for inspection.

Representation learning trains encoders to transform raw inputs into internal features that make useful factors easier to extract; ELMo-style contextual embeddings make token representations depend on sentence context.
Used here as

Bengio et al. frame representation learning as learning transformations that expose useful explanatory factors and make useful information easier to extract. Peters et al. introduce ELMo contextual word repr...

Local witness
Equation 1
z=fθ(x)Rd,a^=gψ(z),ELMoktask=γtaskj=0Lsjtaskhk,jLM(t1,,tN).\begin{aligned} z &= f_\theta(x)\in\mathbb R^d,\qquad \hat a = g_\psi(z),\\ \operatorname{ELMo}^{\mathrm{task}}_k &= \gamma^{\mathrm{task}}\sum_{j=0}^{L}s^{\mathrm{task}}_j\, h^{\mathrm{LM}}_{k,j}(t_1,\ldots,t_N). \end{aligned}
Caveat

Checks only useful-factor extraction and ELMo-style contextual token dependence. It does not certify InfoNCE, retrieval quality, task vectors, anisotropy fixes, equivariance, parallel transport, or all repre...

Review stateCF editorial source-scope reviewClaim metadata: source checkedPublisher-side editorial review only; not independent replication. Check caveats and exact source scope.

Bengio et al. support representation learning as learned features that make useful information or explanatory factors easier for predictors to extract. Peters et al. support ELMo as sentence-contextual token representations from biLM layer states, including task-specific layer weighting and polysemy disambiguation. Local math and code witness this bounded claim; broader geometry demos stay out of scope.

Reviewer: codex+oracle+codex-5.3; reviewed 2026-05-08

Practice notebook

Use the idea, then test it somewhere new

How models turn inputs into vectors whose geometry can expose useful factors, contextual meaning, and similarity structure.

AttemptNo learning claim inferred
Object - ConceptRepresentation Learning & Embedding GeometryQuestion

What is the smallest example that makes Representation Learning & Embedding Geometry click without losing the math?

concept:representation-learning/representations
Boundary

sources: bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpc

Check

Use one state from Representation Learning & Embedding Geometry to explain what changes, why it changes, and which assumption the explanation needs.

Evidence

No learner move yet; no learning state is inferred.

Next move

Write first, use only the help you need, then try a new case without it.

Explain

Use one state from Representation Learning & Embedding Geometry to explain what changes, why it changes, and which assumption the explanation needs.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Grounded object roomClose
Selected object routeAsk from this object; carry one invariant back.sources: bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpc
  1. ObjectConceptRepresentation Learning & Embedding Geometry
  2. PredictBefore revealRepresentation Learning & Embedding Geometry prediction
  3. WitnessCompare codeRepresentation Learning & Embedding Geometry code witness 1
  4. RoomAsk groundedChecking local snapshot
ConceptRepresentation Learning & Embedding GeometryRepresentation Learning

Research Room

Attach the question to an exact object

Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptRepresentation Learning

Representation Learning & Embedding Geometry

Anchored question

What is the smallest example that makes Representation Learning & Embedding Geometry click without losing the math?

Source boundaryInspect source ids: bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpcStable content-object key attached
Role lenses for this object

These are fixed, deterministic perspectives derived from the selected object. They do not represent people, community contributions, or independent review.

Learner evidence requestAsk what would make "Representation Learning & Embedding Geometry" feel predictable rather than familiar.
Assumption

Source ids bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpc must support the exact object, not just the surrounding topic.

Source-checking summary

Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion.

Proposed experiment

Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo.

Next action

The learner can state the mechanism in their own words

Evidence4 checks
PredictionChecking carried observation
ActionReady for one action
AILearner handoff ready
Open source object
01PredictionChecking browser-local route memory
02EvidenceChecking for a carried observation
03BoundaryInspect source ids: bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpc
04Next moveSave one next action
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
Local action draft

This draft stays locally in this browser for concept:representation-learning/representations.

No local draft saved.
Evidence to inspect
  • Source ids to inspect: bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpc
  • Definition, prerequisite, and contrast concept links
  • The equation or code witness that makes the concept operational
  • One demo state that shows the invariant instead of a slogan
What would resolve this
  • The learner can state the mechanism in their own words
  • The learner can name the prerequisite that would repair confusion
  • The learner can predict how the mechanism changes under one perturbation
Object-attached AI handoff

I am working in Continuous Function's research reading room. Object: concept - Representation Learning & Embedding Geometry Object key: concept:representation-learning/representations Context: Representation Learning Anchor id: concept/concept-notebook/representation-learning/representations Open question: What is the smallest example that makes Representation Learning & Embedding Geometry click without losing the math? Evidence to inspect: - Source ids to inspect: bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpc - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan Deterministic role lenses for this object: - Boundary: fixed perspectives, not people, community contributions, or independent review - Source-checking summary: Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Teach/transfer move: Turn the mechanism into one sentence that predicts a neighboring concept. - Assumptions: - Source ids bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpc must support the exact object, not just the surrounding topic. - The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. - The concept explanation is local atlas prose until checked against its math, code, and source support. - Prerequisite gaps should become a repair route, not a reason to leave the object vague. - Role-lens requests: - Learner: ask for "Ask what would make "Representation Learning & Embedding Geometry" feel predictable rather than familiar." | assumption: Source ids bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpc must support the exact object, not just the surrounding topic. | next action: The learner can state the mechanism in their own words - Researcher: ask for "Source ids to inspect: bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpc" | assumption: The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. | next action: The learner can name the prerequisite that would repair confusion - Experimenter: ask for "Choose one variable or condition to perturb before asking for an explanation." | assumption: The concept explanation is local atlas prose until checked against its math, code, and source support. | next action: The learner can predict how the mechanism changes under one perturbation - Professor: ask for "Find the smallest transferable rule a learner could reuse without the AI." | assumption: Prerequisite gaps should become a repair route, not a reason to leave the object vague. | next action: Teach or transfer: Turn the mechanism into one sentence that predicts a neighboring concept. What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action. Current deterministic role lens for this object: - Role lens: Learner - Evidence request: Ask what would make "Representation Learning & Embedding Geometry" feel predictable rather than familiar. - Assumption to keep visible: Source ids bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpc must support the exact object, not just the surrounding topic. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Next action: The learner can state the mechanism in their own words

concept/concept-notebook/representation-learning/representations concept:representation-learning/representations