liveBook · Manning

Qdrant

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

Qdrant is an open-source vector database and similarity-search engine.

Qdrant is a vector database used here to store agent episodes and retrieve those most similar to a new task. QdrantMemoryStore connects it to a BaseMemoryStore interface. section 7.3.2

The store’s workflow is straightforward:

  • Write an episode by deriving searchable text, converting it to a Qdrant point, and upserting it into a collection. section 7.3.2
  • Recall episodes by embedding a query, searching for the most similar points, and limiting results with max_results. section 7.3.2

Recall a related task

Store episodes for Hailstone sequences starting at 6 and 8, then query for a sequence starting at 6. With max_results=1, recall returns the episode 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

See how episodes and a query are represented in embedding space for similarity-based recall. section 7.3.2

Listing 7.7 Implementing QdrantMemoryStore: _search()
# llm_agents_from_scratch/memory_stores/qdrant/store.py
… #A
from llm_agents_from_scratch.memory_stores.qdrant.utils import (
    qdrant_point_to_episode,
)
 
class QdrantMemoryStore(BaseMemoryStore):
    … #B
 
    async def _search(
        self,
        query: str,
        **kwargs: Any,
    ) -> list[Episode]:
        """Return the top ``max_results`` episodes most similar to ``query``.""" #C
        await self._ensure_collection()
        similar_points = (
            await self._client.query_points( #D
                collection_name=self._collection_name,
                query=models.Document( #E
                    text=query,
                    model=self._client.embedding_model_name,
                ),
                using=self._client.get_vector_field_name(),
                limit=self.max_results, #F
                with_payload=True,
                **kwargs,
            )
        ).points
       return [qdrant_point_to_episode(p) for p in similar_points] #G

Inspect the asynchronous search implementation and its result limit. section 7.3.2

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

How deep it goes
Implements collection-backed writes and top-result retrieval, and flags embedding-model choice for benchmarking and dataset evaluation.
Examples
Stores Hailstone episodes for starting values 6 and 8, then retrieves the episode for 6.
What it assumes
Assumes Episode and BaseMemoryStore abstractions, while briefly defining embeddings and similarity search.
What you can do after
Apply Qdrant through QdrantMemoryStore to persist episodes and recall similar ones.
How it connects
Connects episodic memory to embeddings, semantic search, vector databases, and retrieval-augmented generation.

Also explained in

Compare how 3 books explain Qdrant →

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.