Embedding Evaluation
P5.evaluation.02 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Evaluation Metrics for NLP
Where next?
Later in Evaluation
Go up a level
P5.evaluation.02 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Evaluation Metrics for NLP
Later in Evaluation
Go up a level
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.
Why it matters to you. A translator or interpreter knows that the same meaning can be said in different words, and that sharing words does not make two sentences mean the same. A good embedding space should agree with that judgement; this module tests whether it does.
Worked example. Take "the meeting was postponed" (A), "the meeting has been put off" (B) and "the meeting was cancelled" (C). A reviser accepts B as a faithful rewording of A and rejects C. Counting shared words says the opposite: B shares 2 of its 6 words with A, while C shares 3 of its 4. A useful embedding places B nearer to A than C is. That is exactly what the similarity benchmarks of this module, built on human ratings of sentence pairs, check.
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:
| Dataset | Pairs | Score range | What is rated |
|---|---|---|---|
| WordSim-353 | 353 | 0–10 | relatedness (cat ↔ pet) |
| SimLex-999 | 999 | 0–10 | similarity (cat ↔ feline, not cat ↔ fur) |
| MEN | 3,000 | 0–50 | association |
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 A | Word B | Expected relatedness |
|---|---|---|
| lions | animals | highly related (both wild-life words) |
| population | community | moderately related (both group/society words) |
| algorithm | tokenization | weakly related (both CS terms) |
| king | food | unrelated |
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:
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:
The benchmarks and papers this module draws on.
| Type | Resource |
|---|---|
| Paper | Cer et al. 2017 — SemEval-2017 Task 1: Semantic Textual Similarity (the STS-Benchmark) |
| Paper | Muennighoff et al. 2022 — MTEB: Massive Text Embedding Benchmark |
| Paper | Faruqui et al. 2016 — Problems With Evaluation of Word Embeddings Using Word Similarity Tasks (the intrinsic/extrinsic gap) |
| In-app | P10 — Embeddings and Learned Embeddings, for the embedding spaces being evaluated |
| In-app | P10 — Sentence Embeddings, for the sentence encoders that STS-B and MTEB rank |
Practise this lesson's 8 self-checks
One per screen: 4 checked on this page, 4 you reveal and mark yourself. Nothing is recorded.
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.
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.
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.
Loading your notes...