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.
spectral clusteringused by · Spectral clustering is a clustering method that partitions data using eigenvectors of a graph-based affinity representation rather than only geometric location.
cosine similarityuses · Cosine similarity measures the directional alignment of two nonzero vectors as the cosine of the angle between them, equivalently their dot product divided by the product of their magnitudes.
user-item interaction matrixused by · A user-item interaction matrix is a matrix whose rows represent users, columns represent items, and entries encode their interactions, preferences, or ratings.
adjacency matrixalternative to · An adjacency matrix is a square matrix whose rows and columns represent graph vertices and whose entries indicate edges or encode edge weights between vertex pairs.
embeddingproduced by · A numerical vector representation of an item or input that encodes features or relationships useful for computational tasks.
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.