Bring the mental model from Scaled Dot-Product Attention & Transformer Layers; this page will reuse it instead of restarting from zero.
Representation Learning
Representation Learning & Embedding Geometry
How models turn inputs into vectors whose geometry can expose useful factors, contextual meaning, and similarity structure.

Concept Structure
Representation Learning & Embedding Geometry
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learning map
Representation Learning & Embedding GeometryConceptual Bridge
What should feel connected as you move through this page.
How models turn inputs into vectors whose geometry can expose useful factors, contextual meaning, and similarity structure.
The next edge should feel earned: use the demo prediction here before following superposition.
01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
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.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
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:
Here is a useful factor or label we hope is easy to read from , is a simple extractor such as a classifier or probe, and is the bidirectional language-model state for token position at layer . Peters et al. use task-specific softmax weights and scale 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:
Normalization matters because it makes similarity depend on direction instead of length.
Contrastive learning (InfoNCE)
Suppose we have "positive pairs" (two views of the same thing: two crops of an image, two versions of a sentence, etc.). Encode them:
InfoNCE treats as the correct match among a batch of candidates:
- is the temperature: smaller 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:
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.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
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
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
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.
Live Concept Demo
Explore Representation Learning & Embedding Geometry
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Commit to what Representation Learning & Embedding Geometry should make visible before reading the result.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
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.

Start with the picture, metaphor, or geometric mechanism.
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.
Which visible object should carry the first intuition?
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.
Grounds representation learning as learning useful explanatory factors and feature geometry.
Open sourceGrounds contextual embeddings as representations whose meaning changes with surrounding context.
Open sourceGrounds contrastive predictive coding and InfoNCE-style losses that score positive pairs against negative samples.
Open sourceClaim Review
How models turn inputs into vectors whose geometry can expose useful factors, contextual meaning, and similarity structure.
Claims without a substantive review badge still need exact source-support review.
bengio-2013-representation-learning, peters-2018-elmo, oord-2018-cpc
Use equation, code, and demo objects to check whether the source support is operational.
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 representations from biLM states that model word use and how it varies across linguistic context. Local math/code witness the extractor and contextual-token clauses.
Sources: Representation Learning: A Review and New Perspectives, Deep contextualized word representationsChecks 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 representation-learning subfields.A bounded review summary is present; still 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-08Source support candidates
paper 2013Representation Learning: A Review and New PerspectivesGrounds representation learning as learning useful explanatory factors and feature geometry.
paper 2018Deep contextualized word representationsGrounds contextual embeddings as representations whose meaning changes with surrounding context.
paper 2018Representation Learning with Contrastive Predictive CodingGrounds contrastive predictive coding and InfoNCE-style losses that score positive pairs against negative samples.
Practice Loop
Try the idea before it explains itself
How models turn inputs into vectors whose geometry can expose useful factors, contextual meaning, and similarity structure.
Before touching the demo, predict one visible change that should happen in Representation Learning & Embedding Geometry.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
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.Open the draft below to save one note and next action in this browser.
Representation Learning & Embedding Geometry
What is the smallest example that makes Representation Learning & Embedding Geometry click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays locally in this browser for concept:representation-learning/representations.
- 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
- 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
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 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.
concept/concept-notebook/representation-learning/representations
concept:representation-learning/representations