liveBook · Manning

Similarity search

As explained in Machine Learning System Design

The field concerned with finding and ordering relevant information items in response to queries.

A stock-photo customer types a description and expects relevant images, not a tour through millions of categories. Similarity search addresses that problem by finding items that match a query and ordering them by relevance. The business question comes first: will a service handle text-to-image search, or does this particular marketplace need its own solution? section 3.4.2

Relevance and speed pull in different directions. A simple rule, such as matching query words, can identify plausible candidates quickly; a more sophisticated model can then rank a much smaller set. Language or location filters may narrow the pool earlier still. This two-stage design makes expensive ranking practical without applying it to every item. section 3.3

relevancy = f(encode_text(query), encode_image(item)) 

For text-to-image search, the scoring sketch compares an encoded query with an encoded image. It identifies what must be ranked without prescribing a particular encoder or scoring function. section 3.4.2

Check the retrieval stage against its actual job:

  • Keep enough relevant candidates for ranking. In a stock-photo experiment, 97% of clicked photos appeared in the new model’s top 1,000, suggesting room to add a candidate-retrieval stage—not proving that any particular stage will succeed. section 12.4.2
  • Watch for misleading matches in evaluation. A language-model validation procedure retrieves nearest training chunks for each validation chunk and measures token overlap, so near-duplicates can be filtered rather than rewarded as useful retrieval. section 7.3.3

A better match score is not the whole outcome. For photo search, also watch search time, result relevance, and whether sessions end in purchases. Those measures connect retrieval decisions to the customer experience and marketplace results. section 12.4.2

How Machine Learning System Design covers it

How deep it goes
Explains staged search design and sketches text-to-image scoring, but does not specify an encoder or scoring-function implementation.
Examples
Uses stock-photo text-to-image search and a nearest-neighbor check for overlapping language-model training and validation chunks.
What you can do after
Evaluate/understand it through candidate coverage, search time, result relevance, and purchase outcomes before adding a retrieval stage.
How it connects
Connects candidate retrieval to ranking, embeddings, nearest-neighbor search, dataset leakage, and holdout validation.

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 Machine Learning System Design. The section links point to the parts of the book it draws on.