liveBook · Manning

MultiVectorRetriever

As explained in AI Agents and Applications

MultiVectorRetriever is a LangChain retriever that indexes multiple vector representations associated with source documents and returns the corresponding original documents.

MultiVectorRetriever links precise retrieval representations to richer source documents. A vector store searches smaller child chunks, while a byte-backed document store returns the larger parent chunk for answer synthesis. section 8.4 section 8.4.2

Build the pattern by separating what is embedded from what is returned:

  • Split source content into coarse parent chunks and smaller child chunks. section 8.4.2
  • Assign each child chunk its parent identifier, embed the children in Chroma, and store parents in InMemoryByteStore. section 8.4.2
  • Invoke the retriever with a query; it searches granular vectors but returns richer parent documents. section 8.4.2
  • Experiment with summaries, hypothetical questions, or expanded neighboring chunks when ordinary embeddings miss useful matches or context. section 8.4.4 section 8.5

Cornwall Ranger query

A direct child-chunk search returns the concise ticket passage. MultiVectorRetriever returns a broader South Cornwall document containing transport details, the ticket information, and nearby attractions, giving synthesis more context. section 8.4.2 section 8.5

Listing 8.4 Parent and child splitters for MultiVectorRetriever
parent_splitter = RecursiveCharacterTextSplitter(
    chunk_size=3000)  #1
child_splitter = RecursiveCharacterTextSplitter(
    chunk_size=500)  #2

child_chunks_collection = Chroma(  #3
    collection_name="uk_child_chunks",
    embedding_function=OpenAIEmbeddings(
        openai_api_key=OPENAI_API_KEY),
)

child_chunks_collection.reset_collection()  #4

doc_byte_store = InMemoryByteStore()  #5
doc_key = "doc_id"

multi_vector_retriever = MultiVectorRetriever(  #6
    vectorstore=child_chunks_collection,
    byte_store=doc_byte_store
)

Inspect the minimal configuration connecting child-chunk vectors, an in-memory byte store, and MultiVectorRetriever. section 8.4.2

How AI Agents and Applications covers it

How deep it goes
Explains parent-child setup, ingestion, searching, and alternatives, but defers detailed multimodal RAG treatment.
Examples
Demonstrates child chunks, hypothetical questions, expanded chunks, and Cornwall travel queries.
What it assumes
Assumes document loading, splitting, embeddings, and vector search, while demonstrating their assembly into linked retrieval layers.
What you can do after
Build it from scratch with LangChain, Chroma, OpenAI embeddings, splitters, and InMemoryByteStore.
How it connects
Connects embeddings, vector stores, document stores, chunking, parent-document retrieval, and retrieval-augmented generation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents and Applications. The section links point to the parts of the book it draws on.