Reference
Hypothetical and hierarchical retrieval¶
Behavior¶
Mechanism |
Corpus observation |
What to infer |
|---|---|---|
HyDE vector composition |
QASPER evidence Recall@10 rose from |
The vector operation works. This is an oracle upper bound for generator quality |
RAPTOR tree retrieval |
QASPER evidence recall |
Extractive summaries lose evidence. Summary quality must be evaluated |
MemWalker traversal |
QASPER evidence recall |
The measured walk budget traded fewer reads for missed leaves |
RECOMP selection |
Evidence recall |
Use the compression level when its evidence loss fits the task |
Example structural differences
Input structure |
Transformation |
Observable output |
|---|---|---|
Several hypothetical-answer vectors |
Weighted mean, then L2 normalization |
One query vector. Generated text serves as query input |
Eight leaf sections |
Repeated reducing partitions |
Tree whose root transitively covers all eight leaves |
Scored sentences over budget |
Density selection, then source-order restoration |
Selected sentences in original document order |
The functions construct query representations and bounded navigation structures. Generation, encoding, clustering, summarization, and relevance models are injected. Mari owns shape validation, deterministic IDs, budgets, and traces.
How it works¶
hypothetical_document_embedding weights caller-encoded hypothetical answers
and averages their vectors. L2 normalization produces the retrieval vector.
Generated text remains a query aid. build_summary_tree validates a
caller-proposed partition of every current root. Each accepted round creates
stable parent nodes. Tree building ends when a round keeps the same root count.
walk_summary_tree expands the highest-scoring children under explicit branch
and visit budgets. It returns visited paths with the exhaustion state.
Papers
HyDE: hypothetical document embeddingsRAPTOR: recursive summary treesMemWalker: bounded memory-tree navigation
Generatehypothetical answer
→
Encodenormalized query vector
→
Retrievecandidate sections
→
Organizerecursive clusters
→
Walkbranch + visit budget
Paper-derived retrieval construction¶
from mari_kit.retrieval import (
build_summary_tree, hypothetical_document_embedding, walk_summary_tree,
)
hyde_vector = hypothetical_document_embedding([
document_encoder(text) for text in generate_hypotheses(query)
])
tree = build_summary_tree(section_text_by_id,
cluster=lambda nodes, level: cluster_embeddings(nodes, level),
summarize=lambda children, level: summarize(children, level))
walk = walk_summary_tree(tree, lambda node: similarity(query, node.text),
branch_factor=2, max_visits=24)
sections = document_store.get_many(walk.leaf_ids)