Skip to content
AI.info

Neural networks

Embeddings and Learned Representation Spaces

Understand embedding tables, dense learned representations, similarity geometry, training objectives, collapse risks, and responsible interpretation.

By the end you can

A table that learns coordinates for discrete symbols

An embedding layer stores one trainable vector per item, token, category, or entity, and an integer index selects the corresponding row during the forward pass.

Only the rows that a batch actually uses may receive gradients in that step. That is why large vocabularies create sparse access patterns and optimization concerns all of their own.

In production recommendation systems the table stops being an implementation detail and becomes the model. Facebook said as much when it published its Deep Learning Recommendation Model in 2019: “Embeddings contribute the majority of the parameters, with several tables each requiring in excess of multiple GBs of memory” — enough that the tables must be split across devices under model parallelism.

Desai and Shrivastava attached a public number to the same shape at NeurIPS 2022. The MLPerf recommendation benchmark of that period — DLRM trained on the Criteo terabyte click logs, 24 days of data with 13 continuous and 26 categorical features — “contains 100GB of embedding memory (25+Billion parameters)”. Their abstract states the general case: “Embedding tables dominate industrial-scale recommendation model sizes, using up to terabytes of memory.”

The neural network sitting on top of that table is the small part of the system. Everything about how a lookup is sharded, updated, and served follows from one fact: 100GB of it is being indexed one sparse row at a time.

An embedding lookup is parameter selection, not a one-hot matrix multiply performed explicitly.

Comparison

Two ways an embedding can be produced

The word “embedding” describes the vector role, not one generation method.

FigureComparison · 2 columns

Lookup embedding

A stored row represents a discrete identity.

  • One vector per indexed item
  • Context-independent unless combined later
  • Memory grows with vocabulary
  • Example: product ID table

Encoder embedding

A network computes a vector from input content.

  • Can represent unseen combinations
  • May depend on context
  • Compute required for each input
  • Example: sentence encoder output

Visual

The objective creates the useful geometry

Embedding space does not begin with universal semantic axes. Training pressure is what determines which distinctions become useful.

The last step of that loop — validate downstream — is the one most often skipped, and it has a purpose-built instrument. The Massive Text Embedding Benchmark was built in 2023 precisely because embeddings were being validated on one task at a time. MTEB spans 8 tasks, 58 datasets and 112 languages. Its authors ran 33 models across all of it, and the abstract records the result: “We find that no particular text embedding method dominates across all tasks.” A community expansion by 85 authors, MMTEB, published in 2025, has grown the same benchmark to over 500 quality-controlled tasks across more than 250 languages. The finding survived the scale-up.

That verdict is the empirical form of this section's claim. If no method wins everywhere across 8 tasks and 58 datasets, quality is not a property the vectors carry with them. It is a property of the match between the objective a space was trained under and the task it is asked to serve. That is why the loop ends in downstream measurement rather than in a plot.

FigureProcess · 5 steps
  1. 1

    Choose pairs or targets

    Define which examples should agree, differ, predict, or rank.

  2. 2

    Encode examples

    Produce vectors through lookup or a neural encoder.

  3. 3

    Measure relation

    Use dot product, cosine, distance, classifier, or decoder.

  4. 4

    Apply loss

    Reward task-relevant geometry and penalize mismatches.

  5. 5

    Validate downstream

    Test retrieval, transfer, clustering, or prediction on held-out data.

Cosine similarity and dot product answer different questions

Dot product reflects both direction and vector magnitude. Cosine similarity normalizes magnitude and compares angle.

Euclidean distance introduces another geometry. The appropriate measure depends on training objective, normalization, indexing system, and downstream decision.

The space inside a trained language model is not directionally uniform, and in 2019 Ethayarajh measured what that costs an angle. He sampled words uniformly at random and compared their contextual vectors layer by layer. In GPT-2 the average cosine similarity between two random words is roughly 0.6 through layers 2 to 8. Then it climbs sharply, until “word representations in GPT-2’s last layer are so anisotropic that any two words have on average an almost perfect cosine similarity”. In a space like that, a similarity of 0.95 is not evidence of relatedness. It is near the floor. Every cosine reading has to be compared against a random-pair baseline from the same layer before it says anything.

The same crowding had already been diagnosed from the other end, as a defect of the training objective rather than a curiosity of the geometry. Six authors showed at ICLR 2019 that likelihood training with weight tying pushes most learnt word embeddings “into a narrow cone”. Their §3 is blunt about what that looks like when you measure it: “we find the cosine similarities between word embeddings are positive for almost all cases. That is, the words huddle together and are not well separated in the embedding space.” They then priced the repair. Regularising the cone wider bought 2.0 perplexity on WikiText-2, and 1.08 and 0.93 BLEU on WMT 2014 En–De and De–En. Ethayarajh measured the same non-isotropy from his side: in all layers of ELMo, BERT and GPT-2, less than 5% of the variance in a word's contextualised representations is explained by a static embedding. Two independent measurements, one pathology. The raw number a similarity function returns is not on a scale you can read without calibration.

A representation and its similarity function form one interface.

Example

What embeddings make practical

Compact vectors support several reusable system components.

  • Semantic retrieval: find documents whose vectors are near a query under the chosen metric.
  • Recommendation: represent users and items in compatible spaces for candidate scoring.
  • Categorical modeling: replace huge sparse one-hot inputs with learned dense coordinates.
  • Transfer learning: reuse an encoder representation for a new task with limited labels.
  • Clustering and exploration: inspect structure while validating that discovered groups are stable and useful.
  • Multimodal alignment: train image and text representations that can be compared across modalities.

Key idea

Collapse, hubs, and shortcut geometry

Embeddings can collapse so that many examples receive nearly identical vectors. High-dimensional spaces then add a failure of their own, and it is measured rather than anecdotal.

In high dimensions a few points become everybody's neighbour. A 2010 study of 50 real data sets, in the Journal of Machine Learning Research, put it this way: “this distribution becomes considerably skewed as dimensionality increases, causing the emergence of hubs, that is, points with very high k-occurrences which effectively represent "popular" nearest neighbors”. Across those 50 data sets the Spearman correlation between dimensionality and the skewness of the k-occurrence distribution came out at 0.62. The effect was re-measured inside modern LLM representation spaces in 2025, with the same verdict: comparing those representations by Euclidean distance or cosine carries “a high risk of nuisance hubs”. Fifteen years apart, in different spaces. A handful of points sit near everything, and a retrieval system will keep returning them.

A strong proxy objective may also organize vectors around spurious cues such as source, formatting, identity leakage, or popularity. The size of that effect has been quantified. Writing in Science in April 2017, three researchers took off-the-shelf GloVe vectors trained on the 840-billion-token Common Crawl corpus — 2.2 million case-sensitive tokens, 300 dimensions, a 10-word window — and recovered the flower-vs-insect Implicit Association Test from the geometry at Cohen's d = 1.50, p < 10⁻⁷. Then they pointed the same instrument at the labour market: “By applying a second method that we developed, Word Embedding Factual Association Test, (WEFAT), we find that GloVe word embeddings correlate strongly with the percentage of women in 50 occupations in the USA in 2015.” The correlation was Pearson ρ = 0.90, p < 10⁻¹⁸. A Stanford group reproduced the occupation link independently on Google News word2vec vectors, at p < 10⁻⁹ and r² = .46 against 2015 participation.

Nobody labelled those vectors with an occupation's gender composition. The objective encoded it from co-occurrence alone. That is why downstream slice analysis is essential.

A clean visualization does not prove that the representation captured the intended concept.

Case

Text was reconstructed from its embedding vector 92% of the time

A vector looks like a lossy summary of its input, and therefore a safe one. In 2023 four researchers closed that assumption off. Their method generates candidate text, re-embeds it, and corrects itself against the target vector. Iterated, it “is able to recover 92% of 32-token text inputs exactly” from a black-box encoder, at a BLEU score of 97.3. On embedded clinical notes from MIMIC it recovered 89% of full names. An embedding is not a hash of its input. A vector store inherits every access control that the text it came from required.

European data-protection regulators reached the same conclusion from the legal side. The vector a system derives from a face is itself regulated personal data. The Italian Garante fined Clearview AI €20 million over a database of more than 10 billion facial images — an injunction of 10 February 2022, announced on 9 March 2022 — holding that it “consente la creazione di profili basati sui dati biometrici estratti dalle immagini”. The Dutch supervisory authority fined the same company €30,500,000 in a decision of 16 May 2024, announced on 3 September 2024, attaching four orders subject to a penalty for non-compliance.

Between the inversion result and the two fines the position is consistent. A table of vectors derived from people is a table about those people. It is governed as such, whether or not anyone can read a row by eye.

Analogy

A city map drawn for one kind of travel

A city map can be designed for cyclists. Nearby points reflect bike travel, dedicated paths, and elevation rather than straight-line distance.

A city map is surveyed from a relatively stable world. Embedding geometry is learned from data and an objective. Changing the task can redraw every relationship.

Embedding distance is meaningful only relative to how the space was trained and used.

Steps

Audit an embedding before trusting nearest neighbors

Nearest examples are persuasive, so they require disciplined checks.

Much of a persuasive neighborhood can be structure the model never learned. Linzen showed that in 2016. He re-ran the standard word-analogy evaluation against baselines that discard the analogy itself. ONLY-B “ignores both a and a∗ and simply returns the nearest neighbor of b”. IGNORE-A drops one term. The offset method did win overall, with ADD scoring .53, .60 and .58 across three word2vec spaces trained with different context windows. But the margin varied enormously by category. On plurals the accuracy of ONLY-B “reached .70”.

Those numbers need their denominator, and the benchmark supplies one because it is a fixed, countable object. Mikolov and three colleagues built it in 2013 from five semantic and nine syntactic categories: “Overall, there are 8869 semantic and 10675 syntactic questions.” The GloVe paper restates the total the following year — “The dataset contains 19,544 such questions, divided into a semantic subset and a syntactic subset.” — and reports 300-dimensional vectors trained on 42 billion tokens scoring 75.0% overall on it, 81.9% semantic and 69.3% syntactic.

Set the two readings side by side. A published system scores 75.0% on those 19,544 questions. A baseline that has thrown the analogy away reaches .70 on the plurals category. Before a nearest-neighbor list is evidence that a relationship was learned, it has to beat a baseline that knows nothing about the relationship.

FigureProcess · 5 steps
  1. 1. Document the objective

    State what relationships training rewarded.

  2. 2. Confirm normalization

    Record vector scaling and the exact similarity metric.

  3. 3. Test held-out queries

    Inspect successes, near misses, and adversarial shortcuts.

  4. 4. Evaluate slices

    Check languages, sources, popularity, time, and rare entities.

  5. 5. Compare downstream value

    Measure retrieval or prediction outcomes, not only plots.

Key takeaways