advanced rag-information-theory 34 min read

Capstone: The Mathematics of a Production Multimodal Financial RAG System

The retrieval stack arrived as a dozen separate topics — lexical scoring, dense MIPS, IVF and PQ and HNSW, late interaction served by PLAID, reciprocal-rank fusion; this capstone composes the published stack into one finance pipeline and proves the three laws that govern it end to end — cascade recall multiplies across stages, hybrid fusion gains exactly when its legs de-correlate, and a fixed compute budget is allocated across heterogeneous per-modality legs by water-filling — with the single exact statement that a full-budget pipeline recovers brute-force retrieval, and everything above it a heuristic speed-for-recall trade measured honestly on a finance frontier

Overview & motivation

Every prior topic in this series built one organ of a retriever. The probabilistic-IR track built the lexical leg; the dense dual encoder and late interaction built the neural legs; IVF, product quantization, and HNSW built the index; PLAID served late interaction at scale; reciprocal-rank fusion combined heterogeneous rankings; the over-fetch laws priced the cost of recall. A production multimodal financial RAG system is what you get when these organs are wired into one body, and the wiring has mathematics of its own — not a new primitive, but the composition of the ones already built.

This capstone proves the three laws that govern the composed pipeline. They are deliberately honest about their status: one is an exact theorem, the rest are measured propositions, and the difference is the whole point. We have built the retrieval half of the stack; the generation, grounding, and evaluation layer above it — pointwise mutual information between query and answer, conformal factuality, determinantal context selection, GraphRAG, retrieval distillation — is the unbuilt upper curriculum, named here but not yet derived. What we can compose now is everything from ingest through rerank, and that is enough to see the system as a single object.

candidate genrᵢ = 1.000fuse / prunerᵢ = 0.922rerankrᵢ = 0.9220.10.20.30.40.5-0.6-0.30.00.30.60.9dependence ρ across stagesindependent product r₁·r₂ = 0.3
cascade product ∏rᵢ (lower bound)
0.851
measured end-to-end recall
0.922
over-fetch 1/∏rᵢ
1.18×
R_true at ρ=0.3 (gap +0.049)
0.349

End-to-end retention is the product of the per-stage retentions (1.00 · 0.92 · 0.92 = 0.851), and to deliver k survivors the front end over-fetches by 1/∏rᵢ ≈ 1.18×. That product is exact only under independent per-stage survival; under the positive dependence real queries exhibit, FKG/Harris makes it a conservative lower bound — drag ρ above 0 and the true recall lifts above the dashed product line, below 0 it falls under it, with equality at ρ = 0. The measured pipeline (recall 0.9225) sits above its product 0.851, as the bound predicts.

Notation: the served pipeline and one shared truth

A query qq enters a pipeline of stages S1,,SLS_1, \dots, S_L — candidate generation, fusion and pruning, rerank — each a lossy map that keeps some documents and discards others. The exact end-scorer is brute-force MaxSim, S(q,d)=imaxjqi,djS(q, d) = \sum_i \max_j \langle q_i, d_j\rangle, and its top-kk defines the ground truth: the true neighbors of qq are the kk documents that the full, uncompressed scorer would return. This choice matters. Because the truth is the exact scorer and not any one cheap leg, no candidate-generation leg is privileged — the oracle is the act of reranking everything, not any single retriever — which is exactly what lets the legs genuinely complement and lets a full-budget pipeline reach recall 11.

The corpus is one shared multi-view document set. Each document is a bag of unit-norm token vectors (the token view), seen three ways: a lexical leg matches a window of the tokens’ quantized centroid identifiers (BM25 over a centroid vocabulary), a dense leg pools a disjoint window into a single vector (cosine MIPS), and a late-interaction leg scores a third window by cheap centroid-MaxSim. Three partial views of one document — the systems-level shape of multimodality, where a text leg, a transcript leg, and a chart leg each observe part of a filing and fusion recombines them. The cross-modal alignment that would map them into one joint embedding is a separate, future topic; here the legs are independent retrievers feeding fusion.

Movement 1 — cascade recall composition

Fix a query and one true top-kk neighbor x\*x^\*. Let AiA_i be the event that x\*x^\* survives stage ii given it entered, and ri=Pr[Ai](0,1]r_i = \Pr[A_i] \in (0, 1] the stage’s per-neighbor retention. The neighbor reaches the output exactly when it survives every stage.

Definition 1 (The served cascade and its retentions).

The pipeline is the composition SLS1S_L \circ \dots \circ S_1 of LL filters. Stage S1S_1 generates candidates (a token-IVF probe), S2S_2 fuses the legs and prunes to a survivor set, and S3S_3 reranks the survivors by exact MaxSim. A true neighbor is recalled iff it lies in the final top-kk; its end-to-end retention is Pr ⁣[i=1LAi]\Pr\!\big[\bigcap_{i=1}^{L} A_i\big], and the per-stage retentions rir_i are measured against the shared MaxSim truth.

The first law is the one every engineer half-knows and half-misstates.

Theorem 1 (The product law and its over-fetch (exact under independence)).

If the survival events {Ai}\{A_i\} are mutually independent, then end-to-end retention is the product

R  =  i=1Lri,R \;=\; \prod_{i=1}^{L} r_i,

exactly, and to leave kk surviving true neighbors the front end must inject k/irik / \prod_i r_i of them in expectation. This over-fetch is a single negative-binomial law (the imported k/rk/r scan law of the filtered-ANN topic) applied to the composite retention iri\prod_i r_i; the equality i(1/ri)=1/iri\prod_i (1/r_i) = 1/\prod_i r_i is algebraic, not a multiplication of LL separate physical scan counts, because the intermediate stages are not independently re-ranked streams.

On the measured pipeline the three retentions are 1.0001.000, 0.9220.922, 0.9220.922 — candidate generation loses nothing at this breadth, fusion and rerank each drop a little — so the product is 0.8510.851 and the over-fetch a modest 1.18×1.18\times. But the product law is exact only under an idealization, the same positional-independence assumption the over-fetch topic flagged for a single stage, now lifted to the whole pipeline. Real queries violate it, and the direction in which they violate it is the load-bearing claim.

Proposition 1 (Positive dependence makes the product a lower bound (FKG/Harris)).

If the survival events are positively associated — each AiA_i an increasing event in a shared query-easiness latent, so that a query easy for one stage is easy for all — then

Rtrue  =  Pr ⁣[iAi]    iri,R_{\text{true}} \;=\; \Pr\!\Big[\textstyle\bigcap_i A_i\Big] \;\ge\; \prod_i r_i,

with equality at independence; negative association reverses the inequality. Under the positive dependence real pipelines exhibit, the independent product under-states true recall — it is a conservative lower bound — and provisioning the front end at k/irik / \prod_i r_i over-provisions, which is the safe direction.

The temptation is to guess the wrong sign: surely correlated failures lose more? They do not. Positive correlation piles the failures onto the same hard queries, which fail anyway, so fewer distinct documents are lost than independence predicts and true recall sits above the product. The argument is FKG/Harris — increasing events on a positively-associated law have Pr[]Pr\Pr[\bigcap] \ge \prod \Pr — but because the intuition is so easy to invert, the notebook does not trust it: it generates dependence with a bivariate-normal survival copula and sweeps the correlation across both signs. The gap RtrueriR_{\text{true}} - \prod r_i runs from 0.102-0.102 at strong negative dependence through 0.002-0.002 at independence to +0.167+0.167 at strong positive dependence, monotone, with equality pinned at ρ=0\rho = 0 — the first panel makes the slider live. The measured pipeline obliges: its realized recall, 0.9220.922, sits above its own product, 0.8510.851, exactly as a lower bound should.

Movement 2 — hybrid fusion gain

The pipeline’s middle stage fuses heterogeneous legs. Fix a query with true-relevant set R\mathcal{R} at depth kk, let AL=Rtopk(L)A_L = \mathcal{R} \cap \mathrm{top}_k(L) be the relevant documents leg LL surfaces, and ρL=AL/R\rho_L = |A_L| / |\mathcal{R}| its recall. The fused ranking is RRF(d)=L1/(c+rL(d))\mathrm{RRF}(d) = \sum_L 1/(c + r_L(d)) with c=60c = 60, reciprocal-rank fusion imported verbatim. The question is when fusing helps, and the honest answer is a condition, not a guarantee.

Proposition 2 (The coverage ceiling (exact upper bound)).

For any fusion rule emitting a list of depth at least LAL|\bigcup_L A_L|,

ρfused    LALR,\rho_{\text{fused}} \;\le\; \frac{|\bigcup_L A_L|}{|\mathcal{R}|},

since a relevant document no leg places in range cannot be retrieved. Disjoint coverage maximizes the ceiling. But the ceiling is vacuous — equal to 11 — whenever a single leg already covers R\mathcal{R}, so it bounds the gain from above and does not explain the failure below.

Proposition 3 (Fused ≥ best leg is false; the flip needs co-endorsement).

There exist legs for which ρfused<maxLρL\rho_{\text{fused}} < \max_L \rho_L. Under c=60c = 60 a single top-rank vote contributes 1/610.01641/61 \approx 0.0164, weaker than two mid-rank votes at 1/63+1/650.0313\approx 1/63 + 1/65 \approx 0.0313, so a false positive overtakes a true neighbor only when it is co-endorsed by both legs. Concretely, a strong leg ranking r1,r2,r3r_1, r_2, r_3 first but also placing a false positive x1x_1 at rank 44, fused with a noisy leg ranking x1,x2x_1, x_2 on top and burying r3r_3, yields a fused top-33 of {r1,x1,r2}\{r_1, x_1, r_2\}: recall 2/3<12/3 < 1. Remove x1x_1 from the strong leg — no co-endorsement — and r3r_3 survives, recall back to 11.

This is the topic’s headline-flip discipline made literal. The naive expectation — a noisy leg drowns out a good one — is right in spirit and wrong in mechanism, and the notebook builds and runs the counterexample before the prose is allowed to claim anything. A lone loud vote is not enough under RRF’s near-uniform weights; it takes a conspiracy of two. The second panel reconstructs the RRF scores live and shows r3r_3 falling past the top-33 cut.

What survives the scrutiny is the conditional gain.

Proposition 4 (The fusion gain under complementarity (demonstrated)).

On the multimodal finance corpus, where each leg observes a different partial view and so recalls true neighbors the others miss, the fused recall strictly exceeds the best single leg, 0.5470.5800.547 \to 0.580 (a gain of +0.032+0.032), and the gain grows with leg de-correlation: from 00 at a cloned, redundant leg to +0.03+0.03 at disjoint coverage. Inter-leg Kendall-τ\tau is a proxy for that coverage disjointness — neither necessary nor sufficient on its own — and the gain is one cloud’s number, not a universal ranking.

The complementarity is not incidental; it is engineered and it is the real multimodal story. When the three legs were three approximations of one scalar truth, they formed a quality ladder — each strictly better than the last — and no fusion could beat the best, because the worse legs added only noise. Making each leg a partial view of the document, blind to what the others see, is what gives fusion something to recombine. That is precisely the value a lexical leg adds over a dense one in a real financial retriever: it surfaces the exact tokens — tickers, line-item names, dollar figures — that a paraphrase-trained embedding smears, documents the dense leg never had.

Movement 3 — end-to-end budget allocation

The whole pipeline runs on a budget. Each stage ii buys retention gi(ci)g_i(c_i) by spending compute cic_i, and the costs must share a unit — distance-computations per query — or a single budget is meaningless. A sparse lexical match touches a few centroid-id terms; a dense leg is one pooled dot product; late-interaction MaxSim scores every query token against every document token, an order of magnitude more per document. The system-design question is how to spend a fixed budget BB across these unequal stages.

Theorem 2 (Water-filling: equalize the marginal log-recall).

Model end-to-end recall by the separable product R(c)=igi(ci)R(c) = \prod_i g_i(c_i) and maximize it subject to iciB\sum_i c_i \le B. Because R>0R > 0 and monotone, argmaxR=argmaxiloggi(ci)\arg\max R = \arg\max \sum_i \log g_i(c_i), a separable objective; if each loggi\log g_i is concave the Lagrangian iloggi(ci)λici\sum_i \log g_i(c_i) - \lambda \sum_i c_i is concave, so any stationary point is the global maximum, and at every active stage

gi(ci)gi(ci)  =  λ,\frac{g_i'(c_i)}{g_i(c_i)} \;=\; \lambda,

the marginal log-recall equalized across stages — water-filling — with gi(0)/gi(0)λg_i'(0)/g_i(0) \le \lambda on inactive stages and λ\lambda fixed by the active-budget identity.

Two honesties belong with this theorem. First, the equal-marginal condition is not bought by the logarithm. The un-logged product has R/ci=gijigj=gi(R/gi)\partial R / \partial c_i = g_i' \prod_{j \ne i} g_j = g_i' \,(R / g_i), and the common scalar RR cancels, so gi/gi=λg_i' / g_i = \lambda falls out of the product directly; what the log buys is separability — decoupling the stationarity equations — and, with concavity, a global optimum. Second, the separable model igi\prod_i g_i is the Movement-1 object: measured stage-by-stage against the global truth and multiplied, it is a conservative lower bound on the true coupled-pipeline recall, which unions the legs and does at least as well. We optimize the bound, honestly labeled.

Proposition 5 (Water-filling beats uniform and all-in-one (demonstrated); the anchor).

On the finance curves at the demo budget, water-filling reaches R=0.268R = 0.268 — scanning the cheap lexical and dense legs deep and the expensive late-interaction leg shallow, with the marginal log-recall leveled across stages — against 0.1540.154 for naive uniform splitting and a mere 0.0310.031 for pouring the budget into any single leg, where a starved factor tanks the product. Concavity holds on the measured operating grid (verified, not assumed), and at full budget every gi1g_i \to 1, so R1R \to 1: the collapse anchor.

That anchor is the one exact statement of the entire capstone. Probe every cell, prune nothing, rerank by exact MaxSim, and the pipeline is brute-force retrieval — recall 1.01.0, the same probe-all/prune-nothing collapse the PLAID topic proved for its cascade, here for the whole stack. Everything above it — the product law, the fusion gain, the water-filling allocation — is a heuristic speed-for-recall trade we measure rather than guarantee.

Finance case study

Honest accounting

Connections

  • the served late-interaction leg and the collapse-anchor pattern this capstone generalizes: PLAID's probe-all/prune-nothing/exact-rerank recovers brute MaxSim, and the capstone's full-budget pipeline recovers brute-force retrieval the same way; the exact MaxSim of that topic is the neutral end-scorer the whole pipeline approximates and reranks toward multi-vector-ann-retrieval
  • the fusion engine, lifted from two legs to the multimodal multi-leg case: RRF's rank-only scale-invariant score is imported verbatim, and that topic's Kendall-tau geometry is the de-correlation axis along which the fusion gain is measured; the capstone adds the multimodal complementarity story and the co-endorsed dominated-leg flip rank-fusion-rrf
  • the over-fetch k/r negative-binomial law is the per-stage spine the cascade composes: end-to-end the front-end over-fetch is 1/∏rᵢ, one negative-binomial law on the composite retention, and that topic's positional-independence caveat is lifted from one stage to the whole pipeline filtered-incremental-ann
  • the graph ANN leg, the other answer to the candidate-generation problem the cascade's first stage solves; its navigability and the recall-versus-distance-computations cost model feed the same budget the water-filling allocates hnsw
  • the compression/storage accounting behind the served index's footprint: the centroid-id-plus-residual representation collapses the raw multi-vector store, the storage panel's 32x-to-1x story, and prices the per-leg index the budget movement allocates over optimized-product-quantization

References & Further Reading