Embedding Evaluation

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

How do you know your word or sentence embeddings are any good? This module covers intrinsic evaluation (word-similarity benchmarks and analogy tasks), extrinsic evaluation (downstream classification and retrieval MRR@k), the sentence-embedding benchmarks STS-B and MTEB, and a worked cosine-similarity matrix built from the demo corpus. The embeddings being judged are the ones the P10 Transformers pillar builds — Embeddings and Sentence Embeddings.

Step 1 / 4Intrinsic 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.

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.