liveBook · Manning

Similarity search

Similarity search is a retrieval technique that finds or ranks items by comparing their representations with a query according to a similarity or distance measure.

How 22 Manning books explain it

AI-Powered Search

A search engine is software that indexes information and retrieves or ranks items in response to user queries.

How it is used
Uses domain relationships to interpret queries and improve matching and ranking beyond keywords alone.
How deep it goes
Works through a four-phase query pipeline and a configurable graph traversal; treats embedding-based search and question answering separately.
Examples
Contrasts cooking and devops meanings of “chef” through category-specific terms and a Python semantic-graph traversal.
What you can do after
Build it from scratch as a query pipeline that contextualizes terms, rewrites queries, and searches ranked results.

Read how AI-Powered Search explains similarity search →

Natural Language Processing in Action, Second Edition

Information retrieval, or search, is the process of finding relevant information or documents in a collection in response to a query.

How it is used
Retrieves and ranks relevant documents, FAQ answers, or passages for search, chatbots, and question answering.
How deep it goes
Works through TF–IDF-to-SVD matching, embedding-based ranking, and scaling with approximate-nearest-neighbor indexes and vector stores.
Examples
Uses an SVD-powered FAQ bot, word-embedding neighbors for job titles, and a Haystack retriever–reader pipeline.
What you can do after
Build it from scratch for a small FAQ collection, then apply it via Haystack components for indexed question answering.

Read how Natural Language Processing in Action, Second Edition explains similarity search →

Grokking AI Applications

A search method that finds stored vectors whose representations are most similar to a query vector.

How it is used
Retrieves relevant document chunks for RAG answers and agent tools.
How deep it goes
Explains embeddings, distance ranking, chunking, and top-k tuning without model-internals detail.
Examples
Uses pet embeddings, a pizza PDF assistant, and cookbook recipe retrieval.
What you can do after
Apply it via Langflow to retrieve relevant chunks from a vector database for an LLM.

Read how Grokking AI Applications explains similarity search →

Advanced Algorithms and Data Structures

Similarity search is a query technique for finding objects in large multidimensional spaces based on similarity between pairs of objects.

How it is used
Finds nearest objects or objects within a region in large multidimensional datasets, including warehouse matching and image color reduction.
How deep it goes
Develops pruning-based nearest-neighbor search with pseudocode for k-d and SS-trees, but leaves R-tree nearest-neighbor details at a high level.
Examples
Uses warehouse selection, RGB color reduction, and nearby-particle queries to illustrate different similarity-search tasks.
What you can do after
Build it from scratch using k-d or SS-tree search procedures, then adapt candidate selection to stock and other business rules.

Read how Advanced Algorithms and Data Structures explains similarity search →

AI Agents and Applications

Retrieval is the process of finding relevant stored documents from an indexed collection in response to a query.

How it is used
Finds relevant document chunks for RAG prompts instead of passing an entire knowledge base to an LLM.
How deep it goes
Works through chunk indexing, query embeddings, ranked retrieval, LangChain composition, and tuning; does not derive vector-distance formulas.
Examples
Uses a “feline animals” query, a rewritten Cornwall activities search, and a LangChain retriever chain.
What you can do after
Apply it via LangChain vector-store retrievers or `similarity_search`, then inspect chunks and tune the result count.

Read how AI Agents and Applications explains similarity search →

Build AI-Enhanced Web Apps

Retrieval is the process of locating and obtaining relevant information from a stored collection or data source.

How it is used
Retrieves relevant answers or document chunks for semantic search, recommendations, and context-grounded chat.
How deep it goes
Works through embedding, comparison, storage, and retriever pipelines, including JavaScript examples; does not derive similarity mathematics.
Examples
Uses a restaurant recommendation analogy, an IT support answer lookup, and document-chat vector stores.
What you can do after
Apply it via LangChain.js to retrieve matching documents, or build a small cosine-similarity lookup in JavaScript.

Read how Build AI-Enhanced Web Apps explains similarity search →

The Art of AI Product Development

Search is the process of locating information relevant to a query from one or more sources.

How it is used
Locates relevant company knowledge for standalone search and supplies documents for retrieval-augmented generation.
How deep it goes
Explains embedding-based retrieval and develops evaluation and optimization choices, without a mathematical derivation.
Examples
Uses cross-repository product-document searches, case-study relevance assessments, and ambiguous document chunks.
What you can do after
Practice/perform relevance assessment and choose retrieval adjustments for a standalone search or RAG workflow.

Read how The Art of AI Product Development explains similarity search →

Machine Learning System Design

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

How it is used
Finds and orders relevant items for queries, particularly as candidate retrieval before more expensive ranking.
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.

Read how Machine Learning System Design explains similarity search →

Generative AI in Action

Retrieval is the process of selecting relevant information from a collection in response to an information need.

How it is used
Selects relevant external passages to ground RAG answers about current or private information.
How deep it goes
Explains vector matching, index and metric choices, then demonstrates Redis queries; stops short of a production-ready deployment.
Examples
Uses a Redis K-nearest-neighbors query over embedded blog posts and a chat application that places retrieved chunks in an LLM prompt.
What you can do after
Build it from scratch as an illustrative Redis-backed search and RAG chat flow, while identifying additional production engineering needs.

Read how Generative AI in Action explains similarity search →

AI Agents in Action, Second Edition

Retrieval is the process of finding relevant information from an external source and bringing it into a model's context.

How it is used
Retrieves relevant external documents or memories for an agent’s bounded prompt context.
How deep it goes
Builds from an inspectable cosine-similarity example to an embedded, chunked RAG agent; identifies ranking and accuracy limits.
Examples
Uses an in-memory document search, a movie-script RAG agent, and exact-time questions to probe retrieval.
What you can do after
Build it from scratch with cosine-ranked document vectors, then apply it via Chroma DB in a grounded RAG agent.

Read how AI Agents in Action, Second Edition explains similarity search →

MongoDB 8.0 in Action, Third Edition

Semantic search retrieves information according to meaning and conceptual similarity rather than only exact term matches.

How it is used
Retrieves conceptually related data for semantic search and supplies relevant document chunks to retrieval-augmented generation.
How deep it goes
Explains the embedding-to-query workflow, comparison measures, index setup, and driver queries without deriving similarity algorithms.
Examples
Uses a renewable-energy query, JavaScript vector queries, Python category-and-price prefilters, and chatbot retrieval.
What you can do after
Apply it via Atlas Vector Search by indexing embeddings, querying similar vectors, and optionally narrowing results with prefilters.

Read how MongoDB 8.0 in Action, Third Edition explains similarity search →

Build an AI Agent (From Scratch)

Retrieval is the technique of obtaining relevant information from external data sources for use during task execution.

How it is used
Retrieves semantically related portions of external data for an agent’s context rather than supplying entire large files or document collections.
How deep it goes
Builds a vector-search pipeline through chunking, embeddings, cosine similarity, and ranked results; leaves detailed keyword, graph, and hybrid-search implementations aside.
Examples
Tests semantic ranking on short documents, then extracts quantum-related chunks from web results about 2025 Nobel Prize winners.
What you can do after
Build it from scratch with Python embeddings, chunking, and cosine-similarity ranking to select relevant passages.

Read how Build an AI Agent (From Scratch) explains similarity search →

Machine Learning Platform Engineering

Retrieval is the process of finding and returning relevant information from a collection or information store.

How it is used
Uses semantic search to retrieve relevant documentation for retrieval-augmented generation applications.
How deep it goes
Explains embeddings, contrasts semantic and keyword search, and describes FAISS’s role and scale without detailing search algorithms.
Examples
Uses API authentication versus login security and API credential updates versus key rotation as semantic-match examples.
What you can do after
Apply it via embeddings and FAISS to retrieve semantically similar documents for RAG queries.

Read how Machine Learning Platform Engineering explains similarity search →

Grokking Data Structures

Search is an operation that determines whether a target value occurs in a collection and identifies its position.

How it is used
Locates a target value or key in a collection and can provide the index needed to delete an array value.
How deep it goes
Works through linear scans and tree branching with Python implementations, but does not develop graded similarity or result ranking.
Examples
Uses sorted baseball cards and an unsuccessful array search for 8 that stops at 9.
What you can do after
Build it from scratch in Python for arrays and binary search trees, returning a match or signaling failure.

Read how Grokking Data Structures explains similarity search →

Transformers in Action

Retrieval is the process of finding and returning relevant information from a collection or database in response to a query.

How it is used
Finds query-relevant passages to ground a language model’s response without updating its weights.
How deep it goes
Traces document indexing, query matching, and optional reranking, then shows how to attach a reranker to a retrieval chain.
Examples
Illustrates a document-to-answer pipeline and a Flashrank retrieval chain queried about Amazon’s 2023 net income.
What you can do after
Apply it via Flashrank and LangChain’s ContextualCompressionRetriever to rerank retrieved documents before generation.

Read how Transformers in Action explains similarity search →

Math and Architectures of Deep Learning

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

How it is used
Ranks archive documents against a query by comparing their feature-vector representations.
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 you can do after
Apply TF-IDF and cosine similarity to represent, compare, and rank documents for retrieval.

Read how Math and Architectures of Deep Learning explains similarity search →

LLMs in Production

Semantic search retrieves information according to the meaning represented by queries and documents rather than relying only on exact lexical matches.

How it is used
Retrieves nearby embedded documents or examples to supply context for RAG prompts when exact IDs or keywords are unavailable.
How deep it goes
Works through embedding, indexing, querying, and prompt insertion; identifies comparison measures without deriving them.
Examples
Uses reverse image search, a FAISS tweet index, Wikipedia retrieval, and coding-assistant examples.
What you can do after
Apply it via FAISS, Pinecone, or Milvus to retrieve neighbors and add selected results to a prompt.

Read how LLMs in Production explains similarity search →

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.

How it is used
Finds relevant external documents to supply context for an LLM answering a question.
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.

Read how Grokking AI Algorithms, Second Edition explains similarity search →

Building Reliable AI Systems

A search technique that retrieves content based on meaning or semantic similarity rather than only exact keyword overlap.

How it is used
Retrieves semantically relevant document chunks as context for grounded RAG answers.
How deep it goes
Works through embedding, indexing, filtered querying, and answer assembly; flags scale limits without detailing search algorithms.
Examples
Uses physical-therapy coverage and reimbursement questions alongside a Python health-care policy search function.
What you can do after
Apply it via Pinecone to retrieve policy chunks using vector similarity and optional metadata filters.

Read how Building Reliable AI Systems explains similarity search →

The Design of Web APIs, Second Edition

A search operation is an API operation that retrieves resources matching supplied search criteria.

How it is used
Retrieves matching resources from a collection while giving consumers practical control over filters, ordering, and page size.
How deep it goes
Defines inputs, representations, statuses, empty results, and collection controls, but does not detail implementation internals.
Examples
Uses product catalogs, bank transactions, rental cars, ProductSummary responses, and GET or POST search paths.
What you can do after
Build it from scratch by specifying search paths, parameters, representations, statuses, empty-result behavior, and collection controls.

Read how The Design of Web APIs, Second Edition explains similarity search →

Optimization Algorithms: AI techniques for design, planning, and control problems

A systematic examination of possible states that begins at an initial state and seeks to reach a goal state.

How it is used
Frames optimization as searching feasible states for goal states and useful solutions, while considering whether applying it is worthwhile.
How deep it goes
Defines feasible-state search and explains exploration versus exploitation, but does not detail specific search algorithms here.
Examples
Uses small-pizzeria delivery planning and restaurant choice to illustrate practical scale and exploration followed by focused selection.
What you can do after
Evaluate whether optimization is worthwhile by weighing problem scale, implementation costs, expertise, and expected savings.

Read how Optimization Algorithms: AI techniques for design, planning, and control problems explains similarity search →

Domain-Specific Small Language Models

The process of searching external sources to find information relevant to a query or prompt.

How it is used
Improves LLM responses by supplying relevant external information before generation.
How deep it goes
Explains the retrieval-generation pipeline and demonstrates embedding storage, schema definition, indexing, and querying, without detailing ranking theory.
Examples
Uses LanceDB tables, cosine-similarity ANN indexes, and a blocked KV-cache query returning ranked passages.
What you can do after
Build retrieval-backed applications with LanceDB, embeddings, vector indexes, and an LLM generation step.

Read how Domain-Specific Small Language Models explains similarity search →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.