liveBook · Manning

Similarity search

As explained in Math and Architectures of Deep Learning

The task of finding documents relevant or similar to a query or another document using feature representations.

Conceptual search finds documents relevant or similar to a query or another document by comparing feature representations. A document becomes a point in a vocabulary-sized space, and similarity becomes a geometric comparison: aligned vectors produce larger dot products, while perpendicular or unrelated vectors produce values near zero. section 2.5.6 section 4.1

A basic retrieval pipeline proceeds as follows:

  • Represent each document with a bag-of-words vector whose coordinates correspond to vocabulary terms. section 4.1 section 4.6
  • Store only present terms as a sparse representation rather than materializing every zero-valued coordinate. section 4.1 section 4.6.1
  • Weight terms with TF-IDF so repeated terms matter while words appearing across many documents contribute less. section 4.6.1
  • Compare query and document vectors with dot products or cosine similarity, then rank the archive by similarity. section 2.5.6 section 4.6.1

Toy document archive

For documents d0–d6, a query about gun violence favors documents sharing those terms. Documents d3 and d4 receive strong direct-similarity signals because their vectors overlap heavily; d5 and d6 are less similar because they share fewer terms. The bag-of-words model ignores word order and focuses on term counts. section 2.5.6 section 4.6

Figure 4.1 Document descriptor space. Each word in the vocabulary corresponds to a separate dimension. Dots show projections of document feature vectors on the plane formed by the axes corresponding to the terms gun and violence.

Explore the document descriptor space, where vocabulary terms define dimensions and documents appear as points whose projections reveal relationships between terms such as gun and violence. section 4.1

How Math and Architectures of Deep Learning covers it

How deep it goes
Explains vocabulary vectors, sparsity, TF-IDF, dot products, and cosine similarity, then connects them to retrieval.
Examples
Uses documents d0–d6, vocabulary coordinates, gun-and-violence projections, and term-frequency comparisons as concrete retrieval examples.
What it assumes
Builds from vocabulary indexing, term counts, vectors, dot products, and geometric direction before introducing retrieval weighting.
What you can do after
Apply TF-IDF and cosine similarity to represent, compare, and rank documents for retrieval.
How it connects
Connects document retrieval with bag-of-words, feature vectors, dot products, cosine similarity, TF-IDF, PCA, and latent semantic analysis.

Also explained in

Compare how 22 books explain similarity search →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math and Architectures of Deep Learning. The section links point to the parts of the book it draws on.