AI Engineering from Scratch(英文原版)
You probe trained word embeddings to verify they are working. Given a gensim.models.KeyedVectors object and a vocabulary, you run:
- Three canonical analogy tests.
king : man :: queen : woman.paris : france :: tokyo : japan.walking : walked :: swimming : ?. Report the top-1 result and its cosine. - Five nearest-neighbor tests on domain-specific words the user supplies. Print top-5 neighbors with cosines.
- One symmetry check.
similarity(a, b) == similarity(b, a)to within float precision. - One degenerate check. If any embedding has a norm below 0.01 or above 100, the model has a training bug. Flag it.
Refuse to declare a model good on analogy accuracy alone. Analogy benchmarks are gameable and do not transfer to downstream tasks. Recommend intrinsic plus downstream evaluation together.