liveBook · Manning

Similarity search

As explained in Build a Multi-Agent System (from Scratch)

Similarity search retrieves items according to their similarity to a query, often using vector representations.

Similarity search retrieves items relevant to a query by representing both as embeddings in the same vector space and ranking them by distance. Smaller distances indicate greater similarity; cosine similarity is one common measure. section 7.3.2

For episodic agent memory, QdrantMemoryStore embeds and indexes Episode objects, then returns the episodes most similar to a query. It uses Qdrant’s default embedding models to avoid managing a separate embedding service. section 7.3.2

Recalling a similar task

A query about the Hailstone sequence starting from 6 retrieves a stored episode that computed the sequence for 6. section 7.3.2

Figure 7.5 Recording an Episode as a point in the embedding space and recalling the most similar Episode objects to a given query

Shows how stored episodes and a query map into the same embedding space for similarity-based retrieval. section 7.3.2

How Build a Multi-Agent System (from Scratch) covers it

How deep it goes
Defines embeddings, vector distance, and cosine similarity, then connects them to Qdrant-backed indexing and retrieval.
Examples
Demonstrates retrieving a stored Hailstone-sequence episode with a similar natural-language query.
What you can do after
Apply it via QdrantMemoryStore to index episodes and retrieve the most similar ones for a query.
How it connects
Connects semantic search with embeddings, episodic memory, vector databases, and retrieval-augmented generation.

Also explained in

Compare how 37 books explain similarity search →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Multi-Agent System (from Scratch). The section links point to the parts of the book it draws on.