liveBook · Manning

Similarity matrix

As explained in Natural Language Processing in Action, Second Edition

A similarity matrix is a square matrix whose entries quantify pairwise similarity between objects.

A similarity matrix records how closely every object resembles every other object. For normalized sentence embeddings, a dot product produces an N-by-N matrix with one row and column per sentence. section 6.4.6

Key properties:

  • Normalization places 300-dimensional sentence vectors on a common scale while retaining their distinguishing information. section 6.4.6
  • The matrix is symmetric because each pairwise similarity is unchanged when the multiplication order is reversed. section 6.4.6
  • Dense similarity values can become weighted edges in an undirected graph, while sparsification avoids connecting every sentence to every other sentence. section 6.4.6

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Defines dimensions, normalization, dot-product computation, symmetry, and graph conversion without developing matrix internals.
Examples
Uses chapter sentences, 300-dimensional embeddings, NumPy arrays, and a thresholded NetworkX graph.
What it assumes
Assumes vector normalization and dot products, while demonstrating both concepts with NumPy examples.
What you can do after
Apply it via NumPy to calculate pairwise sentence similarity and derive weighted graph edges.
How it connects
Links sentence embeddings, cosine similarity, normalization, undirected graphs, graph edges, and sparse data structures.

Also explained in

Compare how 3 books explain similarity matrix →

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.