Representations and the distinctions they preserve
An embedding is a vector representation of an input. An encoder is the function producing it. Representation learning fits that function so information becomes useful to a subsequent comparison or predictor. Information can remain recoverable without being accessible through the particular score an application uses.
Refund approved, refund granted and refund denied share a topic. Only the first two express the same settled outcome. Association, interchangeable meaning and agreement therefore define different matching tasks. The distinction resembles cup–coffee association versus cup–mug similarity: choosing the relationship changes what a useful representation should expose.
Distinct objects along the encoding path
Token identity persists while new representations appear.
An ID selects its vector.
Read the diagram as text
- Token occurrence.
- Vocabulary ID.
- Lookup vector.
- Surrounding input.
- Occurrence's contextual state.
- Other token states.
- Pooling.
- Sentence vector.
- Token occurrence → Vocabulary ID: identifies.
- Vocabulary ID → Lookup vector: selects.
- Lookup vector → Occurrence's contextual state: transformed.
- Surrounding input → Occurrence's contextual state: conditions.
- Surrounding input → Other token states: encoded.
- Occurrence's contextual state → Pooling: input.
- Other token states → Pooling: inputs.
- Pooling → Sentence vector: produces.
- Lookup. An ID selects its vector. Active: Token occurrence, Vocabulary ID, Lookup vector. New: Token occurrence, Vocabulary ID, Lookup vector.
- Contextualization. Context adds distinct states. Active: Token occurrence, Vocabulary ID, Lookup vector, Surrounding input, Occurrence's contextual state, Other token states. New: Surrounding input, Occurrence's contextual state, Other token states.
- Aggregation. Pooling adds a new aggregate. Active: Token occurrence, Vocabulary ID, Lookup vector, Surrounding input, Occurrence's contextual state, Other token states, Pooling, Sentence vector. New: Pooling, Sentence vector.
- Distributed information — A distributed representation expresses properties through combinations of coordinates; individual coordinates need not name human concepts.
- Dimension is not compression — An overcomplete representation has more coordinates than its input. Regularization, rather than width alone, can constrain what it learns.
- Retrieval as one use — Retrieval selects relevant items from a collection. Comparing query and document vectors supplies one selection signal; Search and Retrieval owns the surrounding system.
A token ID identifies a vocabulary entry. Embedding lookup selects that entry's row from a learned matrix. The ID is an address, not a semantic measurement; nearby integer IDs need not describe related tokens. Ordinary inference reads these learned values rather than fitting them again.
A contextual representation depends on surrounding input, so occurrences of the same token can acquire different states. These states differ from the fixed lookup vector. Transformers and Attention explains the interactions that produce them.
- Pooling — Pooling combines token states into one vector. Mean pooling averages each coordinate across included states. Pooling alone does not establish useful similarity geometry; evaluate the pooled vectors for the intended task.
- Input truncation — Text removed before encoding cannot influence its vector. Input-length limits and output-vector width constrain different things.
Direction, magnitude and comparison scores
A vector has coordinates. Its L2 norm measures length; the dot product sums coordinate products. Cosine compares directions; Euclidean distance measures separation. Larger dot products or cosines rank higher, while smaller distances rank closer.
Magnitude changes the winner
ExampleDot product favors a; cosine favors b.
Original
Compare a's length with b's alignment to q.
Scroll sideways if the figure extends beyond the screen.
- 1. q
- 2. a
- 3. b
Read coordinates and regions as data
X: -0.25–2.5 dimensionless; Y: -0.25–2.5 dimensionless, increasing up. Equal scale on both axes.
(0, 0); (1, 0)
(0, 0); (2, 2)
(1, 0)
q=b: (1.08, 0.15)
a: (2.1, 2.1)
Unit-normalized
Compare directions after both candidates have unit length.
Scroll sideways if the figure extends beyond the screen.
- 1. q
- 2. a
- 3. b
Read coordinates and regions as data
X: -0.25–2.5 dimensionless; Y: -0.25–2.5 dimensionless, increasing up. Equal scale on both axes.
(0, 0); (1, 0)
(0, 0); (0.70711, 0.70711)
(1, 0)
q=b: (1.08, 0.15)
a: (0.8, 0.82)
- Magnitude is a modeling choice — Normalization removes length information. Whether that removes nuisance variation or useful signal depends on the learned objective; prediction quality alone does not validate the resulting cosine geometry.
- Zero vectors — Reject zero-vector cosine comparisons rather than assigning a semantic score.
- Similarity is not necessarily a metric — A mathematical metric satisfies the triangle inequality. For directions 0°, 45°, 90°, one-minus-cosine violates it: .
- Symmetric arithmetic, asymmetric roles — A query seeks supporting information; a passage supplies it. Symmetry of a dot product does not make those roles interchangeable. Separately trained question and passage encoders can express this distinction.
A high cosine is not a relevance probability or a portable cutoff. E5-base-v2's authors report scores commonly around 0.7–1.0, attributing this range to its training temperature. A threshold must be checked against labeled decisions for the actual model, task and population.
Reconstruction and prediction objectives
A loss specifies what training rewards; Supervision, baselines, and loss supplies that prerequisite. For representations, the crucial consequence is which distinctions the objective needs—and which it can ignore.
| Objective | Training signal | Favored structure | Potential omission |
|---|---|---|---|
| PCA reconstruction | Squared reconstruction error with restricted dimension | Directions carrying leading variance | Low-variance distinctions important to another task |
| Autoencoder reconstruction | Compare decoded output with input | Information recoverable through the decoder | Distinctions weakly penalized by the reconstruction loss |
| Context prediction | CBOW predicts a word from context; skip-gram predicts context from a word | Patterns of linguistic co-occurrence | Relations not required by context prediction |
| Supervised prediction | Recorded target labels | Features useful to the final predictor | Within-label differences unnecessary for prediction |
Reconstruction through a restriction
The code must support what the reconstruction loss rewards.
Read the diagram as text
- Input x.
- Encoder f.
- Restricted code h.
- Decoder g.
- Reconstruction.
- Reconstruction loss.
- Input x → Encoder f: input.
- Encoder f → Restricted code h: encodes.
- Restricted code h → Decoder g: code.
- Decoder g → Reconstruction: decodes.
- Reconstruction → Reconstruction loss: prediction.
- Input x → Reconstruction loss: target.
Principal component analysis, or PCA, keeps perpendicular directions capturing leading variation. With squared reconstruction error, this provides a restricted linear representation. Suppose one feature varies greatly with background brightness while a small independent feature determines the label. Retaining only the largest-variance direction can discard the label signal. Feature scaling changes which variation dominates.
An autoencoder learns an encoder and reconstruction decoder. A small code or regularization forces prioritization. Without suitable restrictions, copying or memorizing inputs can satisfy reconstruction without producing transferable features.
- Distributional learning — The distributional hypothesis connects similar linguistic contexts with related meanings. Word2vec's prediction directions turn observed neighboring words into targets, rather than assigning semantic coordinates manually.
- Related does not mean agreeing — Antonyms can occupy similar contexts. Explicit synonym and antonym supervision can reward a distinction that distributional training alone does not reliably expose.
- Prediction is not geometric validation — In studied linear factorization models, different factors can preserve predictions while changing cosine scores. A successful predictor therefore does not automatically validate a chosen similarity readout.
Representational structure also matters outside text. Image autoencoders can retain a coarse spatial grid for a generative network, reducing its input size while sacrificing detail. This is a different design goal from producing one vector whose cosine captures sentence equivalence.
Training relationships and valid negatives
A positive pair contains examples training should associate. A negative pair contains examples it should distinguish. The intended relationship determines those assignments.
An augmentation transforms an input. Invariance means treating that change as irrelevant to the target. A paraphrase may preserve a refund outcome; inserting not may change it. Likewise, mirroring an image can preserve a scene category but change a character. A transformation is valid only relative to the task.
Task choice changes pair labels
ExampleA denial shares the topic but changes the outcome.
Read the diagram as text
- Refund approved.
- Topic matching.
- Outcome matching.
- Refund granted.
- Refund denied.
- Refund approved → Topic matching: If topic matters.
- Refund approved → Outcome matching: If outcome matters.
- Topic matching → Refund granted: Positive.
- Topic matching → Refund denied: Positive.
- Outcome matching → Refund granted: Positive.
- Outcome matching → Refund denied: Negative.
- Hard negative — A high-scoring alternative that genuinely fails the intended relationship; difficulty alone does not make its label correct.
- False negative — An associated example incorrectly treated as a negative. Training then pushes apart examples the application should connect. Sampling arbitrary examples can create this contradiction.
- Semantic duplicates — Different strings can express the same relationship. Removing exact duplicates prevents some conflicts, but does not remove every false negative.
- Coverage — Frequently sampled alternatives shape what the learner must distinguish. Missing populations and mislabeled relationships cannot be repaired merely by optimizing the supplied pairs more aggressively.
Question–answer relevance is not paraphrase equivalence: an answer supplies information rather than restating the question. Matching conventions must reflect that distinction. Label meaning and sampling coverage explain how the underlying supervision is established.
Contrastive learning and relative discrimination
Contrastive learning learns representations by favoring associated examples over competing alternatives.
| Candidate | Score | Weight | Derivative |
|---|---|---|---|
| Positive | ln 2 | 0.4 | −0.6 |
| Confusing negative | ln 2 | 0.4 | +0.4 |
| Easier negative | 0 | 0.2 | +0.2 |
Descending the gradient favors the positive and suppresses negatives, especially confusing ones. Lower temperature sharpens weights; these are relative discrimination probabilities, not calibrated relevance.
In-batch negatives reuse other pairs' positives as alternatives. Changing batch composition changes the discrimination problem, even for an unchanged positive pair.
- Features versus loss vectors — SimCLR applies a projection head to encoder features for training, then discards that head downstream. Its compared vectors and retained features are distinct representations.
- Identical outputs — With identical nonzero vectors, SimCLR assigns equal weights and loss for image pairs. No positive is distinguished; optimization success remains unguaranteed.
- Learning without negatives — Agreement alone permits constant outputs. VICReg combines paired-view agreement with coordinate variance and covariance constraints: examples should vary, and coordinates should avoid repeating the same information. These constraints offer another approach to preventing collapse.
Coordinate compatibility and local neighborhoods
A shared rotation changes coordinates without changing cosine. For an orthogonal matrix , , so ; lengths and Euclidean separations also remain unchanged. Arbitrary affine mappings lack this guarantee. Coordinate meanings and compatibility between independently trained spaces require evidence, even when dimensions match.
Dual encoders use separate functions for the two sides of a comparison. Joint training can make their outputs compatible: Dense Passage Retrieval trains question and passage encoders against relevant and negative passages. Different functions can share a scoring space; equal-sized arrays alone do not establish one.
New candidates change the nearest neighbor
ExampleThe query stays fixed; membership changes.
Initial collection
Follow the dashed link from q to A.
Scroll sideways if the figure extends beyond the screen.
- 1. q
- 2. A
- 3. B
- 4. Nearest link
Read coordinates and regions as data
X: -1–4 dimensionless; Y: -1–4 dimensionless, increasing up. Equal scale on both axes.
(0, 0)
(2, 0)
(0, 3)
(0, 0); (2, 0)
q: (-0.15, -0.25)
A: (2.15, 0.2)
B: (0.15, 3.2)
C added
Follow the replacement link from q to C.
Scroll sideways if the figure extends beyond the screen.
- 1. q
- 2. A
- 3. B
- 4. C
- 5. Nearest link
Read coordinates and regions as data
X: -1–4 dimensionless; Y: -1–4 dimensionless, increasing up. Equal scale on both axes.
(0, 0)
(2, 0)
(0, 3)
(0.5, 0)
(0, 0); (0.5, 0)
q: (-0.15, -0.25)
A: (2.15, 0.2)
B: (0.15, 3.2)
C: new: (0.6, 0.35)
- Role conventions — An encoder may require different query and passage prefixes. These conventions are part of the trained comparison, not optional presentation text.
- Across modalities — CLIP learns image–text compatibility by favoring matched pairs over mismatches. Shared comparisons come from paired training, not from images and text naturally having identical coordinates. Broader alignment belongs to Multimodal Models and Applications.
A nearest-neighbor set contains the closest candidates under a specified distance and collection. A k-neighbor query fixes the count; a radius query fixes a boundary. Density and sampling affect membership. Ties at the cutoff also require a policy, since input ordering can decide them.
The nearest available item can still be irrelevant. If a collection contains only bird articles and none answers a fish query, returning its nearest five items supplies no answer. Local similarity also does not establish semantic equivalence through a chain of neighbors.
- Clusters need an interpretation — Geometric groups do not supply authoritative semantic labels. Structure learning explains this distinction.
- Separate index errors — An approximate search can miss exact neighbors even when the representation is useful. Search and Retrieval covers index behavior; semantic fit and approximation accuracy are separate tests.
Geometric failure modes and projection limits
Unhelpful geometry has several distinct causes. Nonzero vectors can still be identical; varying coordinates can still duplicate information. A two-dimensional scatterplot cannot establish the high-dimensional diagnosis.
| Phenomenon | Meaning | Diagnostic | Interpretation limit |
|---|---|---|---|
| Constant-output collapse | Different inputs receive the same vector | Across-example coordinate variance | Nonzero variance does not establish useful distinctions |
| Coordinate redundancy | Coordinates repeat information, as in (t, t) | Covariance between coordinates | Variation alone does not establish independent information |
| Anisotropy | Directions are unevenly distributed | Random-pair cosine and dominant directions | High background cosine changes the interpretation of individual scores |
| Hubness | Some items repeatedly appear in neighbor sets | Each item's k-neighbor occurrence count | Frequent appearance and usefulness are different properties |
| Distance concentration | Distance spread is small relative to distance magnitude | Relative spread under a specified distance | Dimension alone does not establish concentration or hubness |
Record the sampled population and scoring rule with these diagnostics. Hubness studies show that its occurrence depends on the distribution and distance, including counterexamples under cosine. Vector-norm distributions add context, but no particular norm pattern by itself establishes a semantic defect.
Centering subtracts the population mean. Removing dominant directions then suppresses selected high-variance components; ordinary PCA compression instead retains leading components. All-but-the-Top tested the former on particular word representations. Neither transformation is a universal repair: altered geometry must improve the intended task, and the number of removed directions is application-dependent.
- t-SNE — This neighborhood-oriented dimensionality-reduction method creates a low-dimensional display. Its parameters and optimization can change apparent islands, cluster sizes and inter-cluster distances; density adaptation can make differently spread groups look similarly sized.
- UMAP — This neighborhood-oriented projection can distort density and introduce false tears. Neighborhood settings change local emphasis, while minimum-distance settings affect packing. Cleaner visible gaps do not establish genuine separation in the original space.
- Original-space confirmation — Use a plot to propose a pattern, then check neighbors and separation using the original vectors and intended score. Agreement across attractive displays is still weaker than task evidence.
Evidence of task fit
A readout is the computation consuming a representation. Training a classifier, comparing pairs and selecting neighbors test different readouts.
A frozen encoder keeps its parameters unchanged. A linear probe trains only a linear predictor on its outputs. Held-out success supports accessibility to that restricted predictor. Failure does not establish that the information is absent, and success does not show that cosine exposes it or that the original model uses it.
Shared vectors, different evidence
Each readout supports its own conclusion.
Read the diagram as text
- Frozen vectors.
- Linear predictor.
- Pair-score rule.
- Neighbor task.
- Linear accessibility.
- Pair discrimination.
- Task usefulness.
- Frozen vectors → Linear predictor: train readout.
- Frozen vectors → Pair-score rule: score pairs.
- Frozen vectors → Neighbor task: rank collection.
- Linear predictor → Linear accessibility: held-out labels.
- Pair-score rule → Pair discrimination: labeled pairs.
- Neighbor task → Task usefulness: task outcomes.
- False match — A pair accepted despite failing the required relationship.
- Missed match — A valid pair rejected. Raising a fixed similarity cutoff reduces acceptances, potentially trading fewer false matches for more misses.
- Independent assessment — Fit the probe on training examples, choose settings separately, and evaluate on held-out cases. Generalization explains why training accuracy cannot establish transfer.
MTEB, the Massive Text Embedding Benchmark, spans multiple tasks and languages. Its original results show task-dependent rankings, so a strong semantic-similarity result cannot substitute for retrieval evidence.
Generated evaluation queries can be misleadingly easy when they mirror source wording. In a reported chatbot study, generated and logged queries were compared for both score proximity and preservation of model ordering. That checks whether generated data supports the same selection decision; it does not make every synthetic query set representative.
- Controlled comparison — Compare candidates on the same cases and task labels, documenting preprocessing differences. Keep representative real queries as a reference. Controlled offline comparisons covers the broader design.
- Useful baselines — A lexical matcher is a meaningful retrieval comparator because it preserves matching terms directly. A learned vector method must justify its additional behavior against the actual task, not merely another encoder.
Decisive semantic distinctions and failure diagnosis
Minimal pairs isolate controlled edits. For outcome, amount and record matching, use Refund R104 for $25 approved on June 5 as a constructed baseline; the following labels specify requirements, not measured encoder behavior.
| Edit | Required distinction | Test |
|---|---|---|
| approved → granted | Same settled outcome | Paraphrase preservation |
| approved → not approved | Different outcome | Negation sensitivity |
| $25 → $250 | Different amount | Exact numeric agreement |
| June 5 → June 15 | Different date | Structured date comparison |
| R104 → R140 | Different record | Exact identifier comparison |
| approved → may be approved | Unresolved outcome | Uncertainty-aware labels |
Negation-focused adaptation improved tested negation and antonym sensitivity, while many other edits—including number replacement—remained difficult. Some broader tasks improved and others declined. Repairing one distinction therefore does not establish general semantic fidelity.
- Inspect what reached the encoder — Confirm that decisive text survived preprocessing and input truncation. More output coordinates cannot recover text that never entered the model.
- Inspect aggregation — Compare token-level evidence with the pooled representation; aggregation and task training require separate checks.
- Inspect supervision — Audit positive and negative assignments. Contradictory supervision may punish the very matches the application needs, especially among semantically duplicated examples.
- Inspect population fit — Generic similarity can obscure distinctions within a niche corpus. Test the domain and language actually used, including close competing entities. Distribution shift explains why earlier coverage may not transfer.
- Inspect the readout — If a held-out probe distinguishes outcomes but cosine does not, the evidence implicates the tested similarity readout, not necessarily information absence. A cutoff cannot independently recover a distinction that its scores fail to separate.
Bias also needs a defined consuming task. A study of ELMo tested gender-swapped sentences and a coreference system, which decides which mentions refer to the same entity. Performance differed when occupation stereotypes agreed or conflicted with pronouns. This connects representational associations to task behavior without claiming that every encoder or demographic setting behaves identically.
A missing time filter or unextracted document field can resemble a model failure. When correctness requires exact amounts, identifiers or dates, retain and compare those fields explicitly rather than asking broad similarity to certify them. Segment-level investigation helps distinguish missing infrastructure from an encoder limitation.
Information retained beyond the intended task
Attribute inference predicts sensitive properties from a representation. In studied text encoders, separate attackers recovered demographic labels from encoded examples, including after the original adversary performed near chance. One unsuccessful attacker therefore did not establish removal. Minimization and identification risk addresses the resulting data decisions.
Embedding inversion attempts source reconstruction. Vec2Text demonstrated recovery under access to embeddings and text–embedding pairs from the relevant encoder, including names in clinical-note experiments. Recovery depends on access, training and input conditions. Unreadable vectors are not automatically anonymous; derived-data handling includes these artifacts.
One representation permits multiple readouts
Task usefulness does not establish information minimization.
Read the diagram as text
- Stored representation.
- Intended task predictor.
- Sensitive-attribute predictor.
- Reconstruction decoder.
- Stored representation → Intended task predictor: vector input.
- Stored representation → Sensitive-attribute predictor: attacker vector access.
- Stored representation → Reconstruction decoder: attacker vector access.
- Recoverability is readout-dependent — A custom decoder with a trained adapter recovered some names, topic and structure from another model's embeddings. This demonstrates a possible readout, not lossless decoding from arbitrary embedding APIs.
- Closeness is not factual preservation — Nearby perturbations in a text-decoding prototype retained semantic material while changing a book title and identity. A useful neighborhood can coexist with lost exact details.
Selection and the embedding contract
An embedding contract specifies the encoder and conventions that make a comparison meaningful. It binds produced vectors to their intended scoring space; matching shapes establish only structural compatibility.
| Contract element | Record explicitly |
|---|---|
| Encoder identity | Exact model revision and compatible query/candidate functions |
| Input | Represented unit, language/domain, role prompt, input limit and truncation |
| Aggregation | Token states versus sentence output, pooling and included positions |
| Output | Normalization, dimension and numerical precision |
| Comparison | Scoring convention and compatible candidate-vector generation |
E5-base-v2 provides a concrete example: English input, 768-dimensional output, a 512-token limit, role prefixes, average pooling over unmasked states and normalization in its documented example. Those details describe that model's interface; they are not universal embedding defaults.
Matryoshka Representation Learning explicitly trains selected vector prefixes with their own task losses. Shorter prefixes are consequently trained representations, unlike arbitrary coordinate deletion. Reducing stored width can lower downstream storage and comparison work, but need not proportionally reduce encoder computation. Measure retained task quality at each supported width.
- Changed encoder or role convention — Recompute affected vectors or establish validated compatibility before mixing generations. A query-only change can reuse candidate vectors only when that compatibility is demonstrated.
- Changed precision or output width — Recheck the deployed readout on the same task cases. An API option establishes availability, not acceptable accuracy. Numerical representation belongs to Quantization.
- Changed domain conditioning — Corpus-conditioned encoders can use surrounding documents to emphasize local distinctions, as in a reported Visa/Mastercard example. Their additional context mechanism requires its own task comparison; broader gains cannot be assumed.
- Practical acceptance — Measure actual encoding latency, stored vector size and comparison cost alongside task quality. Smaller outputs and faster encoding are separate benefits to verify.
- System boundary — Keep compatible query and candidate artifacts together. Index replacement and serving operations belong to Search and Retrieval; representation compatibility remains a prerequisite.
Open questions
Relation-specific supervision must preserve desired paraphrases while separating opposition. Shared contexts make these goals difficult to disentangle. Progress would demonstrate improved antonym discrimination on held-out pairs without degrading the application's valid similarity relationships.
Cross-model alignment could reduce recomputation, but fitting a mapping does not establish preserved rankings or decisions. A useful result would retain held-out neighborhood membership and task thresholds across relevant populations, rather than merely minimizing coordinate reconstruction error.
Corpus-conditioned representations may expose niche distinctions, but neighboring-document selection adds another dependency. Progress would show stable gains on unseen entities and changing corpus composition, with explicit costs and comparison against improved training data.
Geometric postprocessing needs criteria for distinguishing nuisance directions from useful signal. A more uniform space can still lose task information. Progress would predict which transformations help a specified readout and confirm those gains independently across meaningful task slices.









