Current

Retrieval plans and context envelopes

Benchmark first

Corpora: BEIR (SciFact, ArguAna, HotpotQA) · LoTTE · KILT

Protocol: Build from corpus documents only; issue the published test queries; preserve ranked IDs and component scores. Report nDCG@10, Recall@100, MRR, p50/p95 query latency, index bytes, and results with ACL pre-filtering. Ablate candidate generation, reranking, fusion, graph expansion, and packing independently.

Mari packs already-ranked retrieval candidates into a bounded, revision-bearing context envelope. Its trace explains every inclusion and exclusion.

How it works

Run semantic, lexical, graph, and recency arms over authorized IDs. Convert arm scores to ranks and combine them with reciprocal-rank fusion, then discard stale dependencies, rerank survivors, diversify near-duplicates, and greedily pack whole evidence excerpts under token/document limits. The envelope contains rendered context plus source revisions and per-candidate include/exclude reasons, allowing the caller to reproduce what the model saw.

Research basisRAG motivates explicit, updateable non-parametric memory and provenance; RAG-Fusion and MMR back fusion and diversity; Lost in the Middle makes budget and evidence order evaluation requirements. ContextEnvelope is Mari’s carrier for those observable decisions.

semanticlexicalgraphrecent

RRF

authorizefreshnessrerank

budget

ContextEnvelopeexcerpts · evidence · revisions · trace

context.py
from mari_components.retrieval import ContextBudget, ContextCandidate, assemble_context

context = assemble_context([
    ContextCandidate(document_id=hit.document_id, revision=revisions[hit.document_id],
        text=passages[hit.document_id], token_count=token_count(hit.document_id),
        score=hit.score, authorized=can_read(hit.document_id),
        fresh=is_fresh(hit.document_id))
    for hit in fused_hits
], budget=ContextBudget(tokens=6000, documents=12))

model(context.text)
audit(context.trace)