liveBook · Manning

Semantic distance

As explained in Natural Language Processing in Action, Second Edition

Semantic distance is a distance between language representations that indicates how dissimilar their meanings or contextual associations are.

Semantic distance measures how dissimilar two language representations are in meaning or contextual association. Nearby words in vector space tend to share surrounding words; distant words tend not to. section 6.4.5

Read distance values with these practical implications:

  • Values near zero indicate high similarity, as with San Francisco and California. section 6.4.5
  • Large distances indicate weakly shared context, as with cars and peanuts. section 6.4.5

Comparing word associations

For the word nurse, Word2Vec reports a smaller distance to woman (0.5586) than to man (0.7453). Such comparisons can reveal associations in training data, but they should not be treated as neutral facts.

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Explains contextual intuition, contrasts Euclidean and cosine calculations, and visualizes high-dimensional vectors with PCA.
Examples
Uses San Francisco–California, cars–peanuts, Illinois–Illini, man–nurse, and projected US city vectors.
What it assumes
Assumes familiarity with word vectors and basic Python arrays while making contextual similarity concrete through examples.
What you can do after
Diagnose word relationships by calculating distances, comparing metrics, and plotting vector representations after PCA.
How it connects
Connects word embeddings, Word2Vec, cosine similarity, Euclidean distance, PCA, and dimensionality reduction.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.