liveBook · Manning

Similarity search

As explained in Grokking AI Algorithms, Second Edition

A search algorithm systematically explores a space of possible states or solutions to find a target or an optimal result.

A question can be answered more effectively when a system first finds relevant information in an external collection. In retrieval-augmented generation (RAG), that search happens before a large language model (LLM) writes its answer. The available description does not specify how relevance is measured, so it does not establish a particular similarity-search algorithm. section 11.42

Answering from a document collection

Suppose a user asks about a company policy. A retrieval system searches company documents for relevant passages. The question and retrieved information then go to the LLM as a combined prompt, giving it context beyond what it learned during training. section 11.42

This is a different goal from finding a path through a maze. Maze search explores possible moves toward a goal and may seek the fewest steps; document retrieval seeks information relevant to a question. Neither example, by itself, explains how to calculate similarity between documents and questions. section 2.3 section 11.42

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Walks through retrieval and answer generation but does not define a similarity measure or retrieval algorithm.
Examples
Uses company documents and a recent Wikipedia snapshot as possible collections for answering questions.
What you can do after
Evaluate/understand how retrieved documents can give an LLM current or domain-specific context for an answer.
How it connects
Connects document retrieval to retrieval-augmented generation, external knowledge sources, and large language models.

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 Grokking AI Algorithms, Second Edition. The section links point to the parts of the book it draws on.