Multi-Vector Retrieval

Index summaries and hypothetical questions for each chunk, then return the original chunk.

Last Updated: 27, Nov 2026

Search Tutorials

--Ads--

Module 8 · Lesson 5 of 7 · Intermediate

Multi-Vector Retrieval

Index summaries and hypothetical questions for each chunk, then return the original chunk.

The text that is best for finding a chunk is not always the text that is best for answering from it. A dense table, a code snippet or a legal clause may be hard to match against a casual question, even though it contains the answer. Multi-vector retrieval indexes several representations of each chunk, such as a summary and a few hypothetical questions, all pointing back to the original chunk, which is what the LLM receives.

Not to be confused with

This lesson is about storing several separate embeddings per chunk. ColBERT-style token-level "multi-vector" models are covered in Dense, Sparse and Multi-Vector Embeddings.

Common representations

RepresentationHelps when
The chunk itselfAlways index it; it is the baseline
A short summaryChunks are long, noisy or full of detail
Hypothetical questions the chunk answersUser questions are phrased very differently from the text
A description of a table or imageThe content is not prose (see Module 11)
Keywords or entitiesUsers search by names, codes or product terms

Generate the representations

Generate them once at indexing time with one LLM call per chunk and a structured output:

multi_vector.py
from pydantic import BaseModel
import numpy as np
import anthropic
from rag_helpers import embed

client = anthropic.Anthropic()

class Views(BaseModel):
    summary: str
    questions: list[str]

def make_views(chunk: str) -> Views:
    response = client.messages.parse(
        model="claude-opus-5-5",
        max_tokens=1500,
        output_config={"effort": "low"},
        messages=[{"role": "user", "content":
            "For the passage below, write a one-sentence summary and 3 questions "
            "that a user might ask which this passage answers. Use plain everyday wording.\n\n"
            f"<passage>\n{chunk}\n</passage>"}],
        output_format=Views,
    )
    return response.parsed_output

Index every view, return the original

Each view becomes its own entry in the vector index with a pointer (chunk_id) to the original chunk. At query time, search all views, map hits back to chunk IDs, keep the best score per chunk and return the original chunk text.

class MultiVectorIndex:
    def __init__(self, chunks: dict[str, str]):
        self.chunks = chunks                       # chunk_id -> original text
        self.view_texts, self.view_owner = [], []
        for chunk_id, text in chunks.items():
            views = make_views(text)
            for view in [text, views.summary, *views.questions]:
                self.view_texts.append(view)
                self.view_owner.append(chunk_id)
        self.vectors = embed(self.view_texts)

    def search(self, query: str, k: int = 4) -> list[tuple[str, float, str]]:
        scores = self.vectors @ embed(query, query=True)[0]
        best: dict[str, tuple[float, str]] = {}
        for i in np.argsort(-scores):
            owner = self.view_owner[i]
            if owner not in best:
                best[owner] = (float(scores[i]), self.view_texts[i])   # best-matching view
            if len(best) == k:
                break
        return [(cid, score, matched) for cid, (score, matched) in best.items()]

index = MultiVectorIndex({
    "exp-3": "| Grade | Metro | Non-metro |\n| L1-L3 | 6,000 | 4,000 |\n| L4+ | 9,000 | 6,000 |",
    "exp-4": "Claims above 25,000 rupees need approval from a department head.",
})
for chunk_id, score, matched_view in index.search("how much can I spend on a hotel in Mumbai?"):
    print(chunk_id, round(score, 3), "matched via:", matched_view[:60])
    print("   send to LLM:", index.chunks[chunk_id][:60])

The bare table has no words like "hotel" or "spend", so the raw chunk is hard to find. A generated question such as "What is the hotel allowance in metro cities?" matches the user's question easily, and the LLM still receives the precise table.

Costs and trade-offs

  • Indexing cost: one LLM call per chunk plus several embeddings per chunk. Cache the generated views by chunk hash.
  • Index size: grows by the number of views (often four to six times).
  • Quality risk: generated questions can drift from the content. Spot-check a sample.

LangChain's MultiVectorRetriever implements this pattern with a vector store for the views and a docstore for the originals.

Key takeaways

  • Index several representations of each chunk: the text, a summary and hypothetical questions.
  • All representations point to the original chunk, which is what the LLM receives.
  • It helps most for tables, code, dense or jargon-heavy text, and casual user questions.
  • It increases indexing cost and index size, so measure the gain.