Embedding Evaluation

P5.evaluation.02 · Audience: guest, it-ml, language-pro · Prerequisites: Evaluation Metrics for NLP

An embedding is just a list of coordinates, and no coordinate is right or wrong on its own — so the metrics of the previous module, which compare predictions against a ground truth, have nothing to grab onto here. The only way to judge an embedding space is indirectly, and there are two honest ways to do it: ask whether its geometry matches human judgements of word meaning, or ask whether the vectors actually help on a real task downstream — and the two verdicts often disagree. In this module you work through both modes, including a full cosine-similarity matrix computed over the eight demo sentences, and meet the standard benchmarks that score sentence embeddings at scale. The embeddings on trial are the very ones the P10 Transformers pillar builds.

Step 1 / 4 — Intrinsic Evaluation — Similarity Benchmarks and Analogies

Intrinsic evaluation measures embedding quality directly — without a downstream task. The two canonical methods are word-similarity benchmarks and analogy tasks.

Word-similarity benchmarks. A human-annotated dataset provides pairs of words and a similarity score:

DatasetPairsScore rangeWhat is rated
WordSim-3533530–10relatedness (cat ↔ pet)
SimLex-9999990–10similarity (cat ↔ feline, not cat ↔ fur)
MEN3,0000–50association

Evaluation: compute cosine similarity between the model's word embeddings for each pair, then measure Spearman rank correlation (ρ) between model scores and human scores. Higher ρ is better.

Intrinsic check on the demo-corpus vocabulary. The demo corpus shares words across sentences. Four pairs to inspect:

Word AWord BExpected relatedness
lionsanimalshighly related (both wild-life words)
populationcommunitymoderately related (both group/society words)
algorithmtokenizationweakly related (both CS terms)
kingfoodunrelated

A good embedding model should assign higher cosine similarity to the first pair than the last. WordSim-353 provides the authoritative human scores to compare against.

Analogy tasks. The classic analogy test: king − man + woman ≈ queen. In embedding space, the direction from man → woman should be the same as the direction from king → queen:

v⃗(king)−v⃗(man)+v⃗(woman)≈v⃗(queen)\vec{v}(\text{king}) - \vec{v}(\text{man}) + \vec{v}(\text{woman}) \approx \vec{v}(\text{queen})

Evaluation: for each analogy (a is to b as c is to ?), compute the result vector v(b) − v(a) + v(c) and find the nearest vocabulary word (excluding a, b, c). Score = fraction of analogies answered correctly. The Google Analogy Dataset contains 19,544 analogies across semantic categories (capitals, currencies, family relations) and syntactic categories (adjective ↔ adverb, verb tenses).

A demo-corpus analogy. From the demo corpus, one possible analogy direction: lions is to dangerous as algorithm is to ? A model trained on the demo corpus is too small to answer this reliably, but it illustrates the test format. The P10 Transformers pillar's embedding modules — Embeddings and Learned Embeddings — run vector arithmetic of exactly this kind over the demo-corpus embedding space.

Limitations of intrinsic evaluation:

  1. Low correlation with downstream tasks — a high WordSim-353 score does not guarantee good classification accuracy.
  2. Benchmark saturation — models now score higher than human inter-annotator agreement on WordSim-353; the benchmark is no longer discriminative.
  3. Context insensitivity — word-level intrinsic metrics miss polysemy ('bank' has very different embeddings depending on context in BERT).
  4. Annotation bias — human scores encode cultural and linguistic biases that propagate into models trained to match them.
📚 Go Further

The benchmarks and papers this module draws on.

TypeResource
PaperCer et al. 2017 — SemEval-2017 Task 1: Semantic Textual Similarity (the STS-Benchmark)
PaperMuennighoff et al. 2022 — MTEB: Massive Text Embedding Benchmark
PaperFaruqui et al. 2016 — Problems With Evaluation of Word Embeddings Using Word Similarity Tasks (the intrinsic/extrinsic gap)
In-appP10 — Embeddings and Learned Embeddings, for the embedding spaces being evaluated
In-appP10 — Sentence Embeddings, for the sentence encoders that STS-B and MTEB rank
Ask the mentor about this module

Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.

Images, PDF or text. Kept on this device only.
Keeping your files on this device

Off by default. The mentor always gets your file; this only decides whether your own copy stays here. Copies live in this browser only - they do not follow you to another device, and clearing site data removes them.

Ctrl/Cmd + Enter to send

Try it yourself

A scratch console for this page's ideas — ungraded, nothing you run here is recorded.

Scratch console

A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.

Output appears here.

My notes on this module

Loading your notes...

Embedding Evaluation — TransformerLab