00-START-HERE · 01-READING-ROUTES · 40_graph_rag · A1_formula_sheet Purpose: Turn seven RAG design prompts into measurable architectures, explicit assumptions and testable trade-offs. Each calculation distinguishes a scoped payload or latency proxy from complete operating cost, measured tail performance and a safety guarantee.
TL;DR
- Separate capacity, traffic, replication and tail latency. Every logical scatter-gather shard sees the system query stream, while replicas can share it. The HNSW and PQ toys are scoped payloads, not all-in footprints.
- Freshness needs detection, invalidation, ingestion, propagation and serving checks. A constant-size flag operation or a logarithm is not an end-to-end time guarantee; stale exclusion may require abstention until replacement evidence is ready.
- Derive an accept/escalate rule from explicit costs, then validate calibration and retained risk. Neither a confidence label nor macro- certifies a accepted-error target.
- Iterative retrieval can use an intermediate fact to form a new query, but one-shot retrieval is not mathematically incapable of finding bridge evidence. The consistent two-round timing toy gives milliseconds and a routed mean of milliseconds.
- Route authorized modality sources when the quality-adjusted savings exceed router overhead. A unified index can retain access controls and provenance; neither one index nor separate indexes guarantees them.
- Debug retrieval, evidence presence, token position, formatting and generation with matched ablations. Unchanged aggregate recall does not rule out retrieval regressions, and a middle-rank pattern is not causal proof.
- Audit the available access surfaces before a credibility retrofit. The stipulated API blocks CrAM; CAG needs suitable fine-tuning access and data. A source-aware selector is not automatically the published RA-RAG, which also generates and filters source-specific answers and votes over them.
The story
Picture the whole chapter as a railway control room running one large station network. The first board separates yard capacity from traffic, then adds duplicate yards for availability. Every logical scatter-gather yard receives each query, but a dispatcher can divide that yard’s requests among replicas. Storage and service demand interact; extra yards are not five copies of the whole corpus. The timetable board separates detecting a change, blocking obsolete versions, inserting replacements and later cleanup. A passenger gets a current schedule only if the serving path checks authoritative versions and permissions; a quick local write alone does not establish freshness. A safety officer compares expected harm with the expected cost of expert review, subject to rules that may require review regardless of confidence. The estimate needs domain validation; a high number on a dashboard is not a safety certificate. Some journeys need a transfer name discovered at an earlier stop. Iterative retrieval can form that next query. It is helpful when the first search misses the bridge, not proof that a one-shot search could never find it. Cargo platforms may use different encoders and permissions, or share a system that enforces both. Routing opens useful authorized platforms, but the switchboard itself has cost and can miss a necessary platform. When performance falls, compare the same journeys before and after the change. Check question-level retrieval, evidence assembly, actual token position and answer behavior; a stable average can hide newly broken journeys. For a retrofit, inspect what can change before promising a named method. A source field can enable grouping, but it cannot manufacture reliable authority or the extra answer-generation and voting steps required by a full credibility method.
Decoder table
| Technical term | Plain-English meaning | Why it matters |
|---|---|---|
| Workload axes | Indexed-vector capacity, traffic and per-query service demand | Different budgets interact; neither QPS nor vector bytes alone sizes the system |
| Indexed count | Number of indexed vectors, not automatically source documents | Chunking or patch encoding can multiply vector count |
| Vector dimension | Components per dense vector; in the toy | Dimension and precision determine vector payload, not complete index memory |
| Logical shard | One partition of an index | Every searched shard receives the query stream before replica load sharing |
| Shard and source counts | counts partitions; counts origins | Use distinct meanings rather than transferring one section’s denominator |
| Scatter-gather | Fan a query to searched logical shards and merge candidates | Replicas of each shard can divide its requests |
| Bi-encoder | Encode query and documents separately | Parameter count does not fix output dimension or search latency |
| Approximate nearest-neighbor (ANN) search | Trade exactness for practical search work | Measure recall, CPU demand, concurrency and tail latency |
| HNSW graph | A hierarchical proximity index with neighbor links | Base-layer slots omit upper layers, metadata and allocation overhead |
| Complexity and | Asymptotic descriptions under specified assumptions | Local expected constant work or a logarithm is not an end-to-end time guarantee |
| 32-bit floating point (fp32) | per component; for components | This is vector payload only |
| HNSW and | Toy , base-layer capacity | Declared setting, not a default shared by all APIs |
| Product Quantization (PQ) | Encode subvectors using shared codebooks | Count per-vector codes, IDs, codebooks and index structures separately |
| PQ subquantizers | groups of dimensions | With 256 centroids per group, the code uses 96 bytes/vector |
| Section-specific | Centroid count, retrieval cutoff or documents per source | A common letter does not imply a common unit or denominator |
| Section-specific | HNSW neighbor parameter or routed-source count | Routing may choose none, some or all authorized sources |
| Scalar or binary quantization | Store components or vectors with fewer bits | Capacity savings and evidence recall require evaluation |
| IVF-PQ | Inverted lists containing compact product codes | Faiss-style /entry before shared overhead |
| Compression ratio | Ratio of explicitly scoped byte budgets | A payload ratio is not a universal all-in memory or cost ratio |
| Usable RAM budget | Memory available for the declared resident structures | An exactly full payload leaves no room for omitted structures |
| Replication factor | copies of a logical shard | Replicas can share load; failure reserve is a separate requirement |
| Recall requirement | Required evidence-retention performance on a defined workload | State metric, cutoff, uncertainty and covered query slices |
| Freshness SLA | Specified delay and success condition after a source event | Define detection, visibility, percentile and safe failure behavior |
| Parametric memory | Information encoded in model weights | Not a keyed serving-data update mechanism |
| Catastrophic forgetting | Training updates damage previously learned behavior | A possible risk, not a theorem that every factual edit fails |
| Model editing | Modify selected model behavior through weights | Requires validation; not the default hot path for fee updates |
| Invalidation | Exclude obsolete or unauthorized versions from serving | Enforcement and propagation matter beyond one local flag |
| Warm ingestion | Validate and insert changed evidence | Queueing, retries and read visibility belong in latency |
| Tombstone | Logical deletion marker enforced on reads | Support and search degradation depend on implementation |
| Compaction | Clean or rebuild index structures | Schedule by measured memory, quality and service behavior |
| Version/recency check | Compare evidence with authoritative version and effective state | Timestamp age alone does not prove current truth |
| Append-only workload | New records do not supersede old facts by assumption | Revocations, security removals and corrections may still require exclusion |
| Calibrated confidence | Estimated probability aligned with observed outcomes in a defined population | Validation uncertainty, selection and shift limit its interpretation |
| Confidence | Decision-relevant estimated correctness probability | Raw token likelihood is not this quantity |
| Acceptance threshold | under the simplified loss model | Mandatory review and evidence eligibility remain separate |
| Wrong-answer cost | Expected harm from an accepted error in common cost units | Assume ; heterogeneous harms may need richer losses |
| Escalation cost | Expected review cost, delay and residual harm | Assume , not automatically the cost of evidence tracing |
| Reject option | Choose automatic answering or escalation using expected loss | The algebra requires an appropriate probability and loss model |
| Acceptance gate | Final eligibility and risk decision before delivery | A high score cannot repair missing required evidence |
| Evidence trace | Versioned document, source and supporting span linked to a claim | Traceability is not itself factual correctness |
| Entity-linked graph | Typed assertions over resolved entities | False merges and false splits affect both precision and recall |
| Credibility-weighted evidence | Use estimated source reliability with relevance and authority | A reliable source can still be outdated or wrong on a specific claim |
| Causal tracing | Intervene on model components and measure output changes | Requires suitable internal access and careful interpretation |
| Attention head | One attention component inside a model | The stipulated black-box API does not expose CrAM’s intervention |
| Multi-hop question | A question requiring combined facts | One document can contain multiple facts; iteration is not always necessary |
| Hop facts and queries | Later queries can depend on validated earlier evidence | A false bridge can direct every later search off target |
| Missing-candidate failure | A needed item is absent from the current candidate pool | Reranking that fixed pool cannot add it; new retrieval can |
| IRCoT | Interleave retrieval and generated reasoning sentences | Intermediate text still needs evidence checks |
| Self-ask | Pose and answer explicit follow-up questions | A visible query format does not guarantee a correct decomposition |
| ITER-RETGEN | Use previous generation to guide later retrieval | Distinguish retrieval schedule from a minimum required hop count |
| FLARE | Use a predicted upcoming sentence and low-confidence tokens to trigger retrieval/regeneration | Not simply a final-answer confidence gate |
| Adaptive-RAG | Select no retrieval, single step or multiple steps | Real routing errors change both quality and latency |
| Silver routing label | A strategy label inferred from model outcomes | Not proof of the question’s minimum reasoning depth |
| Hop cap | Maximum permitted retrieval/reasoning work | At the cap, stop safely rather than force a confident answer |
| Modality source | A representation-specific retrieval source | Separate stores do not automatically enforce document permissions |
| Modality router | Select eligible sources under a relevance/quality policy | Budget feature checks, overhead and evidence misses |
| RAGRoute-style classifier | Score query-source pairs using compatible source features | Published text-source results do not validate every multimodal adaptation |
| Source centroid | Mean embedding within a compatible representation | A centroid from a different encoder need not be comparable |
| Query-type heuristic | A simple initial routing policy | Audit missed evidence and define an appropriate fallback |
| Shared embedding space | Map supported modalities into a joint representation | Score calibration and access controls still need validation |
| CLIP-style joint encoder | Map images and text into compatible learned representations | A baseline, not a universal winner or failure |
| Per-modality calibration | Validate score or decision meaning for each representation | A shared decision rule can work after suitable calibration |
| ColPali-style encoding | Roughly page vectors in a common setup | Not one vector per page or a universal fixed patch count |
| MaxSim | Sum query-token best matches across document/page representations | Its cost depends on query tokens, page vectors and candidate selection |
| Document-as-image encoding | Represent rendered pages visually | Preserves layout but needs footprint and evidence-quality measurements |
| Optical character recognition (OCR) | Extract text from page pixels | Compare errors, structure loss and cost with visual/hybrid methods |
| Authorization filtering | Enforce principal, tenant and document access | Source-level eligibility is not sufficient for mixed-grant sources |
| Per-source reranking | Refine candidates with a compatible scorer | Can precede validated rank or calibrated-score fusion |
| Cross-encoder reranker | Jointly score query and candidate | Text-only BERT cannot directly rerank raw photos |
| Reciprocal rank fusion (RRF) | Merge ranks rather than uncalibrated scores | Weights, depth, duplicates and permissions still matter |
| Visual question answering (VQA) | Answer a question about supplied visual content | Does not by itself test corpus routing or retrieval recall |
| Macro pass | Compare overall metrics on matched inputs | An average identifies a symptom, not its cause |
| Micro pass | Inspect selected individual cases | A regression diff is not an unbiased traffic sample |
| Mezzo pass | Analyze defined slices with denominators and uncertainty | Confirm hypotheses beyond handpicked examples |
| Scores | Matched before/after end-to-end metrics | Separate score noise and question-level transitions |
| Correct sets | Evaluation items correct before and after | Their overlap is needed to count regressions and fixes |
| Recall at | Evidence coverage at a specified common cutoff | Stable aggregate recall does not exonerate retrieval |
| nDCG | A rank-sensitive metric with declared gains and cutoff | Rank quality and final evidence use are different measurements |
| Diff set | Newly broken cases under fixed judgments, not all current failures | |
| Gold-chunk presence | Marked support appears in the serialized prompt | Presence need not mean sufficient, current or nonconflicting evidence |
| Context assembly | Select and serialize evidence for generation | Measure the actual prompt, including truncation and permissions |
| Token-budget truncation | Remove content to fit a context budget | Can drop a needed hop even if one gold chunk remains |
| Rank bucket | A coarse relative chunk-rank group | Not the same as normalized token position |
| Rank , context depth , bucket | , for | Absent evidence is separate; small k leaves empty buckets |
| Exact match (EM) | Fraction matching the evaluation answer convention | Not automatic proof of source faithfulness or deployment safety |
| Macro- | Unweighted mean of class-specific F1 scores | Does not determine the overall error fraction |
| latency | Median response latency | Not a weighted mean of branch latencies |
| Lost in the middle | Observed position-sensitive evidence use in studied models/tasks | A deployment-specific cause needs controlled tests |
| Prompt-template diff | Compare instructions, fields, delimiters and ordering | Large effects are possible, not a promised double-digit change |
| Ranked-list truncation | Send fewer candidates to generation | An unchanged rank-six item cannot survive top-four truncation |
| Pipeline bisection | Replay component combinations or targeted reversions | Interactions can prevent a unique one-knob explanation |
| Access-surface audit | Check actual model, metadata, lineage and deployment interfaces | Do not choose a mechanism the configuration cannot expose |
| Hosted generation API | A service exposing specified model operations | This drill stipulates no attention or usable fine-tuning access |
| Foreign key | A verified mapping between chunk and document/origin | A plausible key name does not prove recoverable lineage |
| CrAM | Modify selected influential heads using document credibility | Model-specific internal access and validation are required |
| CAG | Credibility-aware fine-tuning in the cited baseline | Data/interface readiness determines feasibility, not a universal sprint rule |
| RA-RAG | Estimate reliability; generate/filter source answers; select and vote | Not merely a document selector before one combined generation |
| Source identity | Origin metadata with appropriate granularity and version | Domain duplicates may not be independent corroboration |
| Metadata-only update | Change supported fields without re-embedding | Verify API support, read visibility and rollback |
| Reliability estimate | A source-related credibility weight | Needs independent validation and drift/correlation checks |
| Selected sources | Number retained by a relevance/reliability policy | Selection work and rejected-source checks can still cost calls |
| Estimation query count | Questions used to infer source reliability | Two hundred is an experiment setting, not sufficient certification |
| Reliability-weighted vote | Aggregate normalized, filtered source-specific answers | A relevance-weighted document score is a different operation |
| Feature flag | Reversible control for a tested policy | Rollback still needs data consistency and release monitoring |
| Revalidation | Reassess model-specific interventions and credibility after change | Not a one-time promise attached to a mechanism name |
Core mechanics
Mathematical conventions
Use decimal storage: and . Count indexed vectors, not source files, unless one vector per document is explicitly assumed. Vector/base-link payloads omit other index, metadata, text, cache, allocator and replica storage; capacity ceilings based on them are lower bounds. Let denote query rate and CPU-seconds of search per query. At target utilization , a logical shard needs approximately search cores. With equally loaded replicas, replace by for each replica. Wall-clock search latency need not equal CPU service demand. Embedding, reranking, generation, networking and failure reserve are separate budgets. All dollar prices, service times and example outcomes below are stipulated planning inputs, not measured SLAs or invoices. A weighted sum of route latencies is a mean, not a median or tail quantile. Keep full precision until reporting. Percentages and percentage-point changes are different units. For the reject-option calculation, correctness has zero cost, an accepted error costs , escalation has expected cost , and is a decision-relevant correctness probability. Regulatory, professional-review, evidence or permission rules can prohibit automation regardless of that comparison. Estimated calibration is uncertain and may not transfer across domains, subgroups, routing or distribution shift. Aggregate recall, gold presence, answer correctness and causal faithfulness are separate measurements. A regression diagnosis requires matched inputs, question-level transitions, uncertainty and controlled ablations; a higher aggregate score does not exonerate a component. Correlated or copied sources do not provide independent corroboration.
41.1 Enterprise RAG over 100M documents at 500 QPS
What
Treat corpus size and query rate as separate inputs, while recognizing that corpus size, index settings, hardware and compression also affect per-query work. The arithmetic below assumes : one indexed vector per document only for this toy. Chunking or page patches can make the vector count much larger than the file count. Capacity depends on the complete resident footprint and shard balance, not just raw vector bytes. Measure all index structures, metadata, caches and reserve before choosing the final node count. Traffic sizing needs measured CPU/GPU service demand, batching, utilization, replication and tail latency for the chosen index. A single wall-clock latency does not by itself determine core throughput. Scatter-gather can encode each query once, send it to every logical shard, merge candidates, rerank and generate. Replicas of a shard normally share its requests rather than each receiving every request. Approximate per-shard retrieval and final merging need recall evaluation.
Why
The example stipulates a -million-parameter bi-encoder with output dimensions. Parameter count does not determine vector dimension, encoding latency or ANN time by itself. At fp32, the vector payload alone is:
Under the common HNSW base-layer capacity convention, choose and neighbor slots, each budgeted as a four-byte internal identifier. Occupancy, upper levels and other metadata are separate. Treat as this drill’s setting, not a universal default shared by every hnswlib and Faiss API. Faiss exposes different index constructors and an HNSW memory budget that includes graph links; check the actual implementation and version.[1] The base-layer link budget is per vector. Adding it to fp32 payload gives per vector, or the following scoped subtotal—not a complete HNSW footprint:
PQ splits dimensions into subvectors of dimension . With centroids per subquantizer, each code uses bits, so the code payload is per vector. A hypothetical four-byte posting identifier gives per vector. Standard Faiss IVF-PQ uses eight-byte vector IDs, giving here, before shared tables and other overhead.[1]
The toy ratio is . Using the Faiss-style posting gives and for entries. The fp32 PQ codebook adds once; coarse centroids, list structures, optional precomputed tables and retained full vectors are additional. With available per capacity node, is only a lower-bound shard count for the raw subtotal. It exactly fills all five budgets; any positive omitted resident index storage forces more capacity under this fixed-budget design. A one-shard compressed payload is plausible, not an all-in fit guarantee, especially if full vectors are also retained for reranking.
Failure without it
Dividing QPS by the number of capacity shards is wrong for full scatter-gather: each logical shard receives QPS. Dividing that shard’s requests among replicas is a different operation. Sizing only from QPS can create a memory-starved cluster even when compute is comfortable. Compression can reduce capacity and rebuild requirements, but the raw representation may be justified by recall, update behavior or exact reranking needs. The QPS budget alone does not decide which representation is wasteful. Partitioning one corpus across five graphs does not multiply the total data by five: each graph holds roughly vectors. Construction work, coordination and parallel wall time differ; five full-corpus replicas would instead replicate construction. Do not multiply full-corpus rebuild cost merely by capacity-shard count. Compression and approximate search can lose evidence. Broader candidate retrieval and reranking may help but cannot guarantee recovery if the relevant item never enters the candidate pool. Evaluate recall and end-to-end quality at the chosen compression and search settings. Scalar, binary and product quantization are options to benchmark, not mandatory replacements at a fixed memory boundary. Metadata or semantic routing can reduce shard fan-out only with authorization enforcement and measured evidence recall.
Cost and complexity
For a stipulated single-core CPU demand of , reciprocal service capacity is QPS per fully utilized core. This assumption is stronger than observing an -millisecond wall-clock search on an unspecified threaded implementation. At QPS, cores is the saturation requirement per logical shard. A target utilization of implies aggregate search cores, before failures and other stages; saturation is not a safe tail-latency target. Two replicas of a hypothetical five-shard raw subtotal use ten node slots, but that subtotal is not a valid final all-in capacity plan. With balanced replica load, each copy sees QPS and needs about search cores at target utilization under this CPU-demand toy. Provisioning for a replica failure needs a separate reserve calculation. If the full compressed serving footprint fits one node, three replicas use three nodes. Balanced traffic gives QPS per replica; the same CPU-demand toy implies cores per replica. IVF-PQ and HNSW need separately measured service demand; using the same value is only a comparison assumption. A reported dense index and learned-sparse index on another corpus cannot validate this one: document count, vector dimension, representation and included structures must match. Treat it only as an unverified order-of-magnitude anecdote, not an independent check on the or calculation. At QPS with unchanged corpus and representation, capacity payload is unchanged, but replication, caches and service nodes may grow. The same assumed CPU demand requires aggregate saturation cores per searched logical shard. Keeping the earlier policy gives aggregate search cores, not headroom cores. Distribute this demand across replicas as appropriate; benchmark the changed concurrency and tail behavior. Increase throughput replicas, optimize search or change partitioning according to measured bottlenecks. Smaller shards may reduce local work but add fan-out/merge overhead. More QPS neither universally requires nor universally forbids repartitioning.
41.2 A RAG system that must stay fresh
What
The fee assistant’s contract requires a published change to affect answers within minutes, and prohibits superseded fees beyond that window. Define the publication/effective event, clock, serving regions, success percentile and what happens when ingestion fails. Separate detection, stale exclusion, replacement availability and background maintenance. The three-path design is an operational pattern, not a proof of a latency bound. The hot path records a version-aware invalidation or deny rule and propagates it to all serving reads. Blocking a document with many chunks or caches can involve more than one operation. The warm path validates, embeds and upserts changed chunks, then waits for the required read visibility. Queueing, retries, permissions, replicas and index refresh are part of publication-to-answer latency. The cold path compacts tombstones or rebuilds when supported and needed. Keep obsolete versions excluded while maintenance runs; deletion/update capabilities are implementation-specific. At retrieval and before delivery, check authoritative versions, effective dates, revocations and permissions. A timestamp-age test alone can accept a recently indexed but obsolete fact. If no valid evidence is available, abstain or use an approved live source.
Why
A nightly-only refresh cannot guarantee a much shorter freshness target. Scheduling delay is only one part of the end-to-end path. For a fixed 24-hour refresh cycle versus a 15-minute target, the scheduling-delay supremum in SLA units is:
A change at 09:00 followed by a midnight refresh waits hours, or minutes: SLA windows. A change just after a refresh can wait nearly minutes before processing even starts. An in-memory hash lookup or one invalidation-record write may have expected local work in corpus size. Detecting the change, identifying every affected chunk, durable replication and enforcing it across reads are not thereby constant-time or bounded by . That time is only a stipulated toy input. For million chunks, the following logarithm is a scale reference. HNSW’s search/insertion behavior depends on its graph, dimensions, construction/search settings and implementation; this logarithm is not an exact hop count, worst-case complexity proof or millisecond bound:
The toy assumes an embedding round trip near and very short local insertion. Neither is a measured guarantee, and neither includes every queue, visibility, retry or propagation delay. If the complete verified path really took –, a target would allow a factor of –, about – decimal orders. That arithmetic does not establish that the real publication-to-answer path is subsecond.
Failure without it
An atomic version swap can be desirable when the replacement is ready within the target. If ingestion may miss the deadline, stale exclusion must not wait indefinitely for the swap; serve a safe fallback or abstention until the new version is available. A full corpus reindex on every small change can make work depend on total corpus size rather than changed content. Incremental paths still need validation, consistency and rollback. Model fine-tuning or editing is not an appropriate default hot path for live fee facts: it adds training, verification, uncertainty and potentially unrelated regressions. Whether a particular method meets a measured deadline is empirical, not a theorem that every weight change is too slow. Replication lag, partial failures, stale caches and clock skew can expose old records. Version-aware serving gates help only if every relevant read enforces them and failure behavior is defined.
Cost and complexity
Compaction duration is workload- and implementation-dependent; it can be short or long. Budget its resource contention and keep the serving invalidation rules active throughout. Choose maintenance triggers from measured tombstone burden, memory, recall, update rate and tail latency. Do not infer compaction need from a latency increase alone; compare against other sources of drift. Elasticsearch documents a default one-second refresh for recently searched indexes. That is a visibility mechanism in a different implementation, not confirmation of a –-millisecond HNSW ingestion claim; an asynchronous refresh can itself add delay.[2] Keep live factual updates addressable in serving data where possible. Behavioral fine-tuning is a different intervention, not the only legitimate reason training might change. A truly never-superseded append-only workload may not need semantic replacement invalidation. Permission revocations, security removals, retention rules and corrections can still require exclusion, so append-only storage does not by itself remove that obligation. Report detection-to-block, publication-to-valid-replacement, read visibility and maintenance separately, with their percentiles and failure modes. Confirm the end-to-end target with serving probes rather than adding optimistic component minima.
41.3 High-stakes RAG: medicine and law
What
Place an evidence and acceptance gate before delivery. In high-stakes use, permissions, missing provenance or mandatory expert review can stop automation regardless of a model confidence score. Let estimate correctness for this decision, let be expected harm from an accepted wrong answer, and let include escalation cost, delay and any residual harm. Costs need common units. The simplified model assigns zero cost to a correct automatic answer. Expected automatic cost is , while expected escalation cost is . Asymmetric error types, action-dependent harms, review imperfections or nonzero correct-answer cost require a richer loss model. When automation is permitted, prefer it strictly under the following inequality; at equality the simplified costs tie:
For , the interior threshold is . If , the numerical rule has no positive confidence floor; if , strict preference for automation never occurs. These limiting cases do not override mandatory review. This is a simplified cost-based reject-option derivation in the tradition of Chow’s optimal error/reject trade-off. It is not a theorem that a generative model’s score is calibrated or that cost minimization authorizes clinical/legal practice.[3]
Why
With and in common hypothetical cost units, . The units and harm assumptions must be justified for the actual product. With the separately stipulated clinical values and , the simplified threshold is:
The threshold can change while the numerical model stays fixed. Calibration must still be revalidated if deployment domain, question mix, evidence, accepted subgroup or error severity changes; model identity alone does not preserve calibration. A faster, reliable escalation path can lower expected escalation cost. A disclaimer does not automatically reduce the wrong-answer harm assumed in this model. A governing requirement for expert review is a separate eligibility constraint, not necessarily an ordinary finite cost ratio that pushes a threshold near one. Confidence may prioritize review rather than authorize an autonomous answer.
Failure without it
Within this model, an interior threshold corresponds to . A borrowed , or is not justified without the loss model, calibration evidence and applicable operating constraints. Token probabilities are not calibrated probabilities of a correct, safe, source-supported clinical or legal answer. Risk depends on the action and error type, not merely lexical confidence. Some medical/legal questions require composed relations or historical validity that a single prose lookup misses. Others are simple; use the least complex evidence system that meets the verified need. Entity-linked graphs are one option for composed facts, not a requirement. Resolution can cause both false merges and false splits, changing precision and recall in either direction. Validate relation semantics and provenance. Check authority, effective dates, jurisdiction and subsequent treatment. A citation or a source-level reliability estimate does not prove the specific assertion is current or applicable. Decompose risk where justified, but recomposition can create a high-risk action even when individual facts seem low risk. Gate the delivered decision as well as its subquestions.
Cost and complexity
In a hypothetical -query score distribution, scores exceed and exceed . These are routing counts, not evidence that either threshold achieves its advertised error risk. The resulting coverage is versus ; the latter escalates . Report observed correctness and uncertainty on the accepted population separately. macro- is not equivalent to one error in five: it averages class-specific precision/recall combinations and does not fix the error rate. More importantly, a generic support judge does not certify accepted-answer risk. Under an illustrative independent Bernoulli model, even zero failures in accepted validation cases gives a one-sided error upper bound of about , not . Use representative, held-out, post-selection validation. For zero observed independent failures at constant error probability, the one-sided upper bound is ; reaching at most needs zero-failure accepted cases. This conditional illustration does not cover correlation, adaptive threshold selection, severity-weighted harms or shift. Attach document IDs, versions, sources and offsets to supported claims, and verify the spans actually support them. If required provenance is missing, block automation or escalate; raising a score threshold alone does not repair missing evidence. Improved traceability may reduce audit cost or reveal risk, but it is not by definition a change in , which denotes expected escalation cost here. Estimate its actual effect and retain any evidence eligibility rule independently of the numerical threshold. Cross-source corroboration can help when sources are identifiable and not merely copies. Neither agreement nor a credibility model guarantees truth; test correlated misinformation, outdated authority and the incident’s failure modes.
41.4 Multi-hop question answering
What
A multi-hop question requires combining facts, not necessarily exactly one distinct document per fact. Write for an intermediate fact and for a retrieval query; later queries may depend on earlier evidence. For a film-director/university/country question, one useful retrieval sequence discovers the director, then the university, then its location and the relevant country. A corpus may already contain a passage with several steps, so iteration is a workload-dependent remedy. A useful pattern is , where is accumulated source evidence. Verify the intermediate fact before letting it determine later searches. One-shot retrieval uses the original query, but dense semantics, a bridge-rich document or existing model knowledge can still retrieve intermediate evidence. It may miss unnamed bridge facts; it is not mathematically incapable of retrieving them. IRCoT interleaves retrieval with generated reasoning sentences, using retrieval to inform later reasoning and those sentences to guide later search. This is the published method’s design, not a guarantee that its intermediate claims are correct.[4] Self-ask explicitly poses follow-up questions, obtains answers through search and continues or stops. Log the explicit query, source spans and concise evidence summaries; a formatted follow-up can still ask the wrong question.
Why
Use an unambiguous historical example: “Who won the first U.S. presidential election held after the Soviet Union formally dissolved?” This is different from asking who was president immediately after the dissolution. The Soviet Union formally ceased to exist on December 26, 1991. George H. W. Bush remained the U.S. president immediately afterward; calling that answer wrong to the original “right after” question is an error.[5] For the revised election question, identifying the December 1991 dissolution leads to the next presidential election, held November 3, 1992, which Bill Clinton won. Election victory and taking office are different events; do not silently replace one relation with another.[5][6] An iterative reasoning query is flexible but can propagate an unsupported bridge. Evaluate search quality, intermediate factual support and final correctness independently; auditability depends on the recorded evidence, not the method’s label. Explicit follow-up questions can be logged, cached or displayed with sources. Neither a fixed question/answer schema nor free-form reasoning guarantees success on comparison or aggregation tasks. ITER-RETGEN uses earlier generation to guide subsequent retrieval. FLARE predicts an upcoming sentence, detects low-confidence tokens and can retrieve and regenerate that sentence; it is more specific than “retrieve on any low-confidence final token.” These are different retrieval schedules, not universally interchangeable hop counters.[7]
Failure without it
A reranker cannot promote an absent item within a fixed candidate pool. Widening first-stage retrieval or issuing a bridge query can change that pool; neither is guaranteed to recover every missing hop-two document. Unconditional iteration adds retrieval and model work even for questions that already have sufficient evidence. Context may grow or be bounded by summarization/selection; state the actual policy. Require stopping, duplicate-query detection, resource budgets and a safe no-answer path. Reaching a hop cap is evidence of a budget stop, not proof that a factual answer exists. Log retrieval actions, documents, query reformulations, versioned evidence and observable decision summaries. Do not treat a model’s generated rationale as a faithful causal trace; isolate decomposition, retrieval and bridge-support errors with ablations.
Cost and complexity
The constructed workload is single-hop and needing the two-intermediate-round route below. The main mean calculation assumes perfect routing; real misclassification changes both quality and latency. Stipulate per retrieval, decoded tokens/s, generated intermediate tokens per round and a -token final answer. Thus intermediate decoding is and final decoding . Omit prefill, queueing, networking, reranking and retries explicitly. The one-shot proxy is one retrieval plus final decoding:
Define the iterative route consistently: two rounds, each with one retrieval and intermediate tokens, then a -token final answer using the accumulated evidence with no extra retrieval. It is , exactly twice the one-shot proxy. The previously printed belongs to three such intermediate rounds: . It cannot be derived from . If final generation performs a separate retrieval, add its latency instead of hiding it in either result. For sensitivity only, a three-round slow route gives a perfectly routed mean of . Keep this separate from the main two-round example. A stipulated classifier perfectly routes the stated mix in the main two-round illustration:
Against always taking the two-round route, the mean reduction is . This is a weighted mean, not a measured median or tail latency, and assumes no routing errors. Adaptive-RAG reports no-retrieval, single-step and multi-step routing, trained with silver model-outcome labels plus dataset-based inductive bias. Its reported route times of , and seconds are experiment-specific; , not this drill’s latency multiplier or a universal tenfold law.[8] Evaluate a router’s confusion matrix and end-to-end cost/quality rather than assuming perfect labels or a universal required hop count. Model-generated silver labels reflect which tested strategy succeeded, not a proven minimum number of reasoning steps. Datasets can provide supporting-fact annotations or single-/multi-hop construction signals, but these do not directly label the optimal retrieval policy for every model. Adaptive-RAG combines such inductive bias with predicted outcomes; “no natural dataset has any hop labels” is too broad.[8] The cost of false extra retrieval and false early stopping is workload-dependent. Tune using explicit losses and measured answer risk; extra retrieval can introduce distractors, so biasing toward more work is not always safer. A three- or four-round cap is a planning heuristic, not a correctness guarantee. Escalate or report insufficient evidence when the budget runs out; high stakes can favor early human review rather than unconditional iteration. An median target is not met by either main proxy: even the one-shot path is . In the deterministic perfectly routed mix, the median is while the mean is . Shorter output, caching, different serving or a different task may help, but routing alone does not satisfy that target. A maintained, source-linked graph can sometimes replace repeated search with traversal. Graph construction, update freshness, relation semantics and query planning remain costs; not every multi-hop problem is already encoded in it.
41.5 Multimodal enterprise search
What
The hypothetical inventory has million text chunks, million tables, million scanned pages, million photos and million slide decks: million heterogeneous items, not necessarily million vectors. A deck can contain many slides and a page encoder can emit many patch vectors. Modality-specific retrievers are one useful design. Each representation needs relevance evaluation, provenance, query-time authorization and a declared score/fusion rule. A unified system can preserve the same metadata and access policy. RAGRoute’s checked design uses query embedding, source centroid, query-centroid distance, source size and density. It was tested over compatible text embedding sources, not proved as a drop-in router across arbitrary incomparable modality encoders. A multimodal adaptation needs compatible features and training/audit data; it may route to none, some or all authorized sources.[9] Enforce source-level eligibility before routing where possible, and document/tenant permissions on every searched source and final result. Locally rank compatible evidence, then fuse using a validated rule. Source-only permission checks are insufficient for mixed-grant indexes.
Why
A shared embedding space does not by itself calibrate relevance scores or preserve modality-specific evidence. Conversely, separate indexes do not by themselves solve calibration or permissions. Compare a unified representation with specialized routes at matched quality. A CLIP-style image/text encoder is a baseline, not proof that every multimodal space fails. Tables, OCR, images and slides have different information needs; the useful representation and fusion policy depend on the query and corpus. ColPali-style page retrieval commonly uses roughly page vectors including patch/special-token representations, with query-token MaxSim late interaction. Count vectors, dimensions, pages and search settings for the selected implementation. Skip that work only when routing safely preserves the needed page evidence.[10] Merging indexes need not erase provenance or grants. Preserve source IDs, document versions, modality and authorization filters whether the store is unified or partitioned; validate access isolation and recall under filters. The toy restricts finance tables to two departments. Enforce actual principal/document permissions, not merely a modality label or a router’s semantic prediction. A skipped index can avoid its search and candidate reranking work. Feature construction, policy checks, router inference, audits and cached source-summary maintenance can still incur cost.
Failure without it
Full fan-out can spend work on irrelevant sources, but parallelism, coverage needs and router mistakes determine end-to-end trade-offs. Count aggregate resource consumption separately from elapsed latency. Removing unauthorized results only after fusion can let restricted items affect ranking, candidate availability, counts or timing. Design authorization enforcement for the actual threat model; neither one shared index nor a post-filter automatically provides isolation. Do not add uncalibrated heterogeneous scores as if they were comparable. Rank fusion, calibrated scores or a trained multimodal reranker are alternatives to evaluate. RRF can merge per-source ranks without assuming raw score comparability, but still needs duplicate handling, depth/weight choices, authorization and quality validation. There is no mathematical rule that a shared space or full fan-out is acceptable only when the source count is at most two. Single-image VQA does not validate corpus routing or evidence recall. Use retrieval-and-answer tasks with distractors, multi-source evidence and permission-sensitive slices appropriate to the enterprise design.
Cost and complexity
Stipulate candidates per source and of serial reranking work per candidate using modality-compatible scorers. A text BERT cross-encoder does not directly score raw photos, and real scorer costs can differ by modality and batch. With equal unit costs and serial execution, full fan-out produces 100 candidates and the following reranking-work proxy:
Routing this return-policy/packaging-photo query to text and photos gives 40 candidates in the same equal-unit-cost toy:
Candidate count falls and serial reranking work falls by . This is not automatically an -millisecond latency saving with parallel/batched scoring; router overhead and route misses also matter. In this serial-only comparison, router overhead below is necessary to preserve that isolated saving if everything else is equal. Skipping tables, scans and slides can also avoid their search work. With heterogeneous per-source candidate costs , reranking saving is , not necessarily the unweighted candidate reduction; is the selected set and the full eligible set. RAGRoute reports MMLU call reduction (about ) and communication reduction (about ). Its MMLU accuracy is versus , a -percentage-point drop; MIRAGE top-32 is separately versus . Neither experiment validates the toy’s multimodal saving or proves identical accuracy.[9] A query-type heuristic can be a starting policy, but needs labeled audits and a fallback when evidence may be missed. Full fan-out is reasonable whenever its measured coverage/cost trade-off beats routing, not only below an arbitrary two-source cutoff. Page-image encoding can preserve layout that OCR loses; OCR, structural parsing, captions and hybrids may be preferable on other slices. Benchmark the actual answer/evidence loss, vector footprint, indexing cost and serving demand rather than assigning one modality a universally correct ingestion method.
41.6 Debugging a RAG system that got worse
What
Reproduce baseline and post-deploy on matched inputs, versions, decoding settings and evaluation labels. Report uncertainty, newly fixed cases and newly broken cases, not only a macro difference. Compare old and new retrieval at the same diagnostic cutoff , including per-question evidence coverage, rank-sensitive metrics, permissions, duplicates and source quality. A change in cutoff must not be mistaken for a better retriever. If retrieval loses evidence, inspect embeddings, corpus snapshots, indexing, filters and candidate assembly. Improvements elsewhere can coexist with that failure, so inspect slices rather than reverting blindly. Even when aggregate recall holds or improves, inspect question-level transitions. Define the newly broken set using matched baseline and new answer judgments:
and are the same evaluation questions answered correctly before and after. excludes newly fixed cases, so it is a regression-localization sample, not an unbiased sample of all failures or traffic. Check the actual serialized prompt, not merely a retriever log: sufficient evidence may be missing, truncated, conflicting, unauthorized or present without all required hops. A gold-chunk flag is only a proxy for usable support. For integer rank and , the following chunk-rank bucket lies in . Absent evidence has no rank and must be a separate group. With fewer than ten chunks some buckets are empty; unequal chunk sizes make rank a poor proxy for token position:
Report group counts and intervals across the full matched evaluation, including absent-evidence cases. Control question difficulty and evidence sufficiency, and randomize evidence position while holding content fixed to test a positional explanation.
Why
Stable or improved aggregate recall does not exonerate retrieval: it can hide lost questions, worse ranks, duplicates, conflicting sources or incomplete multi-hop evidence. Nor does it prove the new reranker should be kept unchanged. Missing sufficient evidence in the final prompt suggests a retrieval/assembly/filter/truncation problem. Compare the actual transition points to locate it; do not label every missing gold chunk an augmentation-only bug. A middle-position association is a hypothesis consistent with reported lost-in-the-middle effects, not causal proof. Difficulty, length, distractors and evidence quality can confound it; test matched position interventions.[11] A flat rank slice does not rule out position effects or prompt problems. Compare actual token offsets, separators, instructions, model versions and decoding with controlled ablations. Prompt sensitivity can be large, but a generic double-digit claim is not a predicted effect for this deployment.
Failure without it
A guess about the newest component can remove a useful change and preserve the bug. Conversely, aggregate retrieval gains do not justify keeping every part of a bundled retrieval change. Under fixed labels and evaluation conditions, each item in the diff set was correct before and wrong after. With stochastic generation or judgment noise, repeat or assess uncertainty before treating each difference as a stable regression. A recovered mean can hide new failure pockets or evaluation overfitting. Validate on held-out cases, domain/risk slices, evidence coverage and operational metrics. Candidate-pool width and generator-context depth are separate controls. A broad rerank pool can feed a shorter evidence-complete prompt; evaluate whether necessary supporting items survive. Replay component combinations or use factorial/bisected ablations for bundled changes. Interactions can matter, so changing one knob at a time may not uniquely identify the cause.
Cost and complexity
The hypothetical baseline retrieves five candidates, sends three roughly -token chunks ( evidence tokens) and scores EM on questions: correct and wrong. Use a common cutoff when separately comparing diagnostic retrieval recall. The bundled deploy retrieves twenty and sends ten chunks, about evidence tokens. At EM, are correct and wrong. These constructed outcomes are not a reproduced benchmark. The change is percentage points, or fewer correct answers. It is not an eight-point change or a nine-percent relative decrease; the relative decrease is . Separate diagnostic measurements at a common cutoff report evidence recall and final-prompt gold presence . They count different stages and do not prove every question improved or that all present evidence was sufficient. If , the endpoints imply newly fixed cases: both correct, newly broken, newly fixed and both wrong. In a random sample of broken cases, have the marked gold chunk. Its illustrative Wilson interval is roughly –; this sample does not estimate all-query gold presence. The stipulated slice accuracies are in buckets 1–2, in 3–7 and in 8–10. Report denominators, absent-evidence handling and uncertainty; these percentages alone need not reproduce the aggregate . Selection into rank buckets can be confounded. Try a top-four prompt as one controlled intervention, but compare reranker changes, context selection/order, fixed-evidence prompts and format changes before declaring a cause. Verify multi-hop evidence recall and high-risk slices after shortening. The stated intervention yields EM (), a -point improvement over the deploy and six points above baseline, while gold presence falls to . Four -token chunks use evidence tokens, fewer than ten chunks. These are hypothetical outcomes requiring independent validation. A median gold rank of two out of four gives , still a middle rank bucket, not an edge. A rank-six item cannot survive unchanged-order top-four truncation. Different before/after medians can reflect changed cohorts or ordering; they do not prove that the same evidence moved from the middle to an edge.
41.7 Retrofitting credibility onto an existing pipeline
What
The hypothetical inherited system is 18 months old: a flat vector store, a hosted generator, no planned downtime and missing source metadata. Audit the actual permissions, APIs and data lineage rather than assuming all hosted services expose the same controls. An incident preferred a two-year-old blog to an authoritative regulatory bulletin. Age alone does not establish falsehood; inspect applicability, authority, version and the specific conflicting claim. This drill stipulates no attention access and no usable fine-tuning surface. Audit generator access and chunk metadata before comparing mechanisms. CrAM identifies influential attention heads with an extended causal-tracing procedure and modifies attention using document credibility scores. The stipulated black-box generation API does not expose this intervention. The method also needs usable credibility information; attention modification is not a truth detector.[12] The CAG baseline described by CrAM fine-tunes a model on credibility-aware prompts/examples. Availability of a suitable fine-tuning interface, data and validation determines feasibility. Engineer-weeks or a two-week impossibility is a scenario assumption, not an inherent lower bound for every deployment.[12] Published RA-RAG estimates source reliability iteratively, retrieves from reliable/relevant sources, generates source-specific answers, filters unsupported/misaligned answers, and aggregates answer votes. It need not change model weights, but it is not merely a document-ranking layer before one generator call.[13] Its weighted majority vote operates on normalized source-specific answers, not directly on document relevance scores. Relevance and reliability are distinct; copied sources or correlated errors can defeat apparent consensus. The original study emphasizes closed-ended answers.[13] A source-aware post-retrieval selector can be a smaller retrofit, but label it as a design inspired by source reliability rather than the full published RA-RAG. Grouping a global top-k pool does not guarantee k documents from every source; source-filtered retrieval or additional queries may be required.
Why
Legacy chunks may contain only an identifier, vector and text. Inspect whether a reliable document foreign key or reversible chunk mapping actually exists; do not infer source identity from an identifier’s name alone. An upstream document record may retain source identity, license, author, authority, effective date and revision. Domain alone can be too coarse, and different domains may repeat one origin. If verified keys connect chunk to document to origin, backfill versioned source metadata. Test missing/ambiguous joins and permission propagation before updating production records. A supported metadata-only update can avoid re-embedding or recrawling. Whether the store accepts it, how it becomes visible and whether evidence origins are recoverable must be checked; a missing lineage map can require a more expensive repair.
Failure without it
For this API-only configuration CrAM is unavailable. A different hosted service with an explicit compatible attention-control interface would be a different configuration; do not use “hosted” alone as a universal technical proof. CAG is unavailable under the stipulated no-fine-tuning interface. If fine-tuning later becomes available, readiness of data, access, validation and rollout capacity—not a universal sprint-duration rule—determines feasibility. Source-aware reliability lookup and source-specific voting require identifiable origins or a justified alternative grouping. A source field alone does not establish reliable authority or complete source-specific candidate coverage. Choosing from benchmark accuracy before checking these surfaces can select a mechanism the system cannot run. An initial access-surface audit can be brief, but five minutes is an illustrative planning target, not a verified audit or incident-response SLA. For self-hosting, CrAM head selection and credibility validation are model- and setup-dependent. Reassess after weight, architecture, task or source changes; a universal 100–300-head prescription or generic adversarial-injection score is unsupported by the checked setup.[12]
Cost and complexity
The metadata-only machine-time illustration contains chunks. Engineering, lineage recovery, review, rollback planning and source-reliability estimation are separate work. Stipulate a sustained join throughput of rows/s, with compatible keys and no missing-row work:
At a sustained metadata updates/s, writes take . Serial join plus writes is minutes. This is not a promise of a sub-20-minute production rollout: API limits, retries, replication, checks and contention are omitted. The simplified selection toy has sources and documents each, hence candidates. Keeping sources retains documents. This assumes the per-source candidates exist; obtaining them may add source-filtered retrieval and reranking. With equal document lengths, the retained document/evidence-token fraction changes as follows. It is not a complete system cost reduction:
At tokens/document and per input tokens, one combined prompt has document tokens costing , versus costing . Instructions, questions, output tokens, selection and extra calls are excluded; context feasibility must also be checked. The isolated document-input saving is per query or per queries/day. Full RA-RAG adds source-specific generation/filtering and reliability-estimation costs, so this subtraction is not its measured net saving. The checked RA-RAG v1 experiments use three to nine constructed sources, top-three documents/source and , with queries for reliability estimation and test queries/dataset. The idealized calculation is not a measured 1,000-source token-reduction result from those experiments.[13] , with decimal orders—not two orders. A source-count ratio does not directly predict token or total-cost savings when relevance checks, source lengths and per-source generation differ. A -query reliability exercise across all sources can require source-query answers before filtering, iterations and separate validation. RA-RAG’s original estimation can use unlabeled questions; latent consensus is not ground-truth certification. Use independent fact-checks, domain slices, uncertainty and drift checks to evaluate the resulting weights.[13] Ship a tested, source-aware policy behind a feature flag only if permissions, truth/freshness checks, latency and quality meet the release gates. Record whether it is a simple selector or the full answer-voting pipeline, and which missing resources would make CAG or CrAM feasible.
Diagrams
Figure 41.1
Diagram description and source
flowchart TB
Q["Query stream: 500 QPS"] --> E["Encode query once if representations allow"]
E --> S1["Logical shard 1: 500 QPS aggregate"]
E --> S2["Logical shard 2: 500 QPS aggregate"]
E --> SS["Each remaining logical shard: 500 QPS aggregate"]
S1 -.-> R1["Replicas share this shard's requests"]
S1 --> M["Merge candidates and enforce permissions"]
S2 --> M
SS --> M
M --> R["Rerank"] --> G["Generate and verify"]
Figure : Full scatter-gather sends the system query rate to each logical shard, not necessarily every replica. Count indexed vectors and the complete resident footprint for capacity, then measure service demand, fan-out, replication and tail latency. The raw subtotal is not an all-in five-node deployment guarantee.
Figure 41.2
Diagram description and source
flowchart TB
D["Publish or effective-version event"] --> X["Detect and validate the change"]
X --> H["Hot path: propagate version-aware exclusion"]
X --> W["Warm path: embed, upsert and wait for read visibility"]
H --> I["Serving index, metadata, caches and replicas"]
W --> I
C["Cold path: supported compaction or rebuild"] --> I
I --> Q["Authorized query"] --> RC{"Current authoritative version and permissions?"}
RC -->|yes| G["Generate; recheck before delivery as required"]
RC -->|no| F["Abstain or use an approved live source"]
Figure : Separate exclusion, replacement visibility and background maintenance, including change detection and propagation. A local constant-size operation or optimistic insertion estimate is not a serving-wide freshness bound. When the old fact is blocked but the new fact is unavailable, the safe result may be no automatic answer.
Figure 41.3
Diagram description and source
flowchart TB
Q["Clinical or legal request"] --> R["Retrieve sufficient authorized, current evidence"]
R --> V["Verify authority, applicability and source support"]
V --> G["Generate candidate answer; estimate decision-relevant confidence"]
G --> P{"Automation permitted and required evidence present?"}
P -->|no| X["Escalate or abstain"]
P -->|yes| D{"Expected automatic harm below expected escalation cost?"}
D -->|yes| A["Deliver only under validated risk and operating gates"]
D -->|no or unresolved tie| X
Figure : Under the simplified loss assumptions, prefer automation when , equivalently for . Mandatory review and missing evidence remain separate gates. Calibration uncertainty and residual accepted risk require validation; a confidence threshold is not a clinical or legal safety certificate.
Figure 41.4
Diagram description and source
flowchart TB
Q["Who won the first U.S. presidential election after the USSR formally dissolved?"] --> O1["One-shot retrieval may or may not find both facts"]
Q --> I1["First find the dissolution event"]
I1 --> I2["USSR formally ended: December 26, 1991"]
I2 --> I3["Ask which U.S. presidential election came next"]
I3 --> I4["November 3, 1992 election: Bill Clinton won"]
I4 --> V["Verify both dates and the requested relation"]
Q -.-> C["Different question: president immediately afterward was George H. W. Bush"]
Figure : An intermediate date can guide a second query, but one-shot retrieval is not guaranteed to fail. Clinton is the election winner for the revised question; Bush is correct for the original question about who was president immediately after dissolution. More retrieval does not excuse changing the question.[5][6]
Figure 41.5
Diagram description and source
flowchart TB
Q["Query and principal permissions"] --> R["Evaluate eligible sources and route with measured recall"]
R --> T["Text: authorized retrieval and compatible reranking"]
R --> P["Photos: authorized retrieval and compatible reranking"]
R -.-> B["Tables skipped in this example; no table search"]
R -.-> S["Scans skipped in this example; no page search"]
R -.-> L["Slides skipped in this example; no slide search"]
T --> M["Fuse ranks or calibrated scores; deduplicate and recheck access"]
P --> M
M --> G["Generate and verify evidence"]
Figure : Skipped sources avoid their search/candidate-scoring work, not all feature, router, policy or maintenance cost. The two-source choice is hypothetical and must preserve required evidence. A unified authorized index is also a valid baseline; no two-source cutoff establishes when routing is worthwhile.
Figure 41.6
Diagram description and source
flowchart TB
M["Matched macro regression"] --> R["Compare per-question retrieval, ranks, sources and evidence coverage"]
R --> D["Inspect newly broken AND newly fixed cases"]
D --> P["Check actual prompt, sufficient evidence and permissions"]
P --> W["Measure token position, formatting, distractors and answer behavior"]
W --> Z["Test hypotheses with matched ablations; randomize position if relevant"]
Z --> F["Confirm on held-out questions, risk slices and operational metrics"]
R -.-> C["Stable aggregate recall does not exonerate retrieval"]
Figure : The diagnostic path generates hypotheses rather than ruling out components from one average. Presence is not sufficiency, chunk rank is not token position, and an observational U-shape is not causal proof. Repeated or controlled tests are needed when generation or judgments are stochastic.
Figure 41.7
Diagram description and source
flowchart TB
G["Audit actual model, data and metadata interfaces"] --> A{"Compatible attention access?"}
A -->|yes| C["CrAM candidate: credibility inputs, head selection and validation"]
A -->|no| F{"Suitable fine-tuning access and data?"}
F -->|yes| T["CAG candidate: training and release validation"]
F -->|no| S{"Recoverable source lineage and permitted metadata update?"}
S -->|yes| B["Backfill and validate versioned source metadata"]
B --> P["Choose a simple source-aware selector OR full source-answer voting"]
P --> V["Evaluate authority, freshness, correlated sources, cost and rollback"]
S -->|no| R["Repair lineage or narrow/stop automation; do not promise a cheap retrofit"]
Figure : The stipulated API has neither attention control nor suitable fine-tuning. A metadata backfill may enable a source-aware policy, but published RA-RAG also needs source-specific answer generation, filtering and weighted voting. Missing keys, unsupported metadata writes or absent validation can defeat a sprint plan; neither “hosted” nor a source field alone settles feasibility.[12][13]
Whiteboard pack
Numbered drawing order
- Write indexed-vector count and QPS separately; add complete storage, service demand, replicas and tail targets.
- Draw full scatter-gather to logical shards, then split each shard’s load across replicas.
- Add change detection, hot exclusion, warm read visibility and cold maintenance, with authoritative serving checks.
- Write the simplified risk inequality and separate mandatory review/evidence gates from confidence.
- Show an intermediate fact forming a new query; preserve the requested relation and verify both facts.
- Draw authorized modality routes and their compatible scorers; label router overhead, evidence misses and fusion rules.
- Compare newly broken and fixed cases, sufficient prompt evidence and actual token position; test rather than assume the cause.
- Finish with actual access surfaces, recoverable lineage, a source-aware selector versus full RA-RAG, and a reversible validated rollout.
90 to 100 word script
Separate vector capacity from query traffic, then budget replicas, service demand and tail latency. Every logical scatter-gather shard sees the query stream; replicas share it. Freshness needs detection, exclusion, visible replacement and serving checks. High-stakes automation needs validated risk estimates plus mandatory review rules. Iteration can discover bridge facts but must preserve the question. Route authorized modalities when quality-adjusted savings justify overhead. Debug per-question retrieval and actual prompts, not aggregate recall alone. Finally, audit access and source lineage. A source-aware selector is not full RA-RAG: source-specific generation, filtering and answer voting add work.
Interview traps
Probe 1: How do 100 million documents, 500 QPS, and a 15-minute freshness SLA change one architecture?
Answer: Count indexed vectors and all resident structures, measure per-query service demand, and distinguish logical shards from load-sharing replicas. Add version-aware exclusion, asynchronous replacement with verified visibility, background maintenance and serving checks. Capacity nodes do not establish freshness; component minima do not establish the publication-to-answer SLA.
Probe 2: A clinical question is both low-confidence and multi-hop. Which problem do you solve first?
Answer: If required evidence is missing, obtain it within a safe resource budget or escalate; do not force a clinical system to finish a chain before seeking review. Validate the delivered decision’s probability and expected harm, then apply only if automation is otherwise permitted. A disclaimer, a larger top- or a high raw token probability cannot substitute for supported evidence and professional-review requirements.
Probe 3: Why not place text, tables, scanned contracts, photos, and slides in one shared index?
Answer: A shared index can work if representations, authorization, provenance and fusion are validated. Separate modality routes can reduce expensive work, but their overhead and misses must be measured. Use compatible scorers and ranks/calibrated scores; there is no universal two-source cutoff for a shared space or full broadcast.
Probe 4: Recall improves from to , yet exact match falls from to . Do you revert the reranker?
Answer: Do not decide from the two averages. Audit matched per-question retrieval, newly broken/fixed cases, sufficient serialized evidence, actual token positions and bundled changes. The toy’s top-four intervention reaches EM, but does not prove position causality or automatically vindicate the reranker. Rank two of four is still a middle bucket under the chapter’s formula.
Probe 5: Leadership wants CrAM after a credibility incident, but generation uses a hosted API. What ships this sprint?
Answer: The stipulated API blocks CrAM and CAG. Verify a usable lineage join and metadata update, then test a reversible source-aware policy with authority/freshness checks. Calling it full RA-RAG requires source-specific generation, filtering and voting, whose latency and costs must be budgeted. If lineage or validation is missing, narrow or stop automation instead of promising a sprint-sized fix.
Key numbers
| Drill | Checked calculation and claim boundary |
|---|---|
| Interview setup | A -second sketch is an interview target, not a production sizing exercise |
| Enterprise workload | indexed vectors and QPS; documents equal vectors only by assumption |
| Encoder vectors | million parameters, , fp32: /vector; parameter count does not fix d |
| HNSW base links | , ; /vector before upper layers and metadata |
| Raw scoped subtotal | /vector; for vectors, not all-in memory |
| PQ layout | groups of dimensions; centroids/group; codes; shared codebook |
| PQ posting payloads | Four-byte toy ID: , , ratio ; Faiss eight-byte ID: , , ratio |
| Node memory | usable is a stipulated budget, not a hardware default; count all resident structures |
| Capacity lower bound | exactly fills the subtotal; omitted positive storage requires more capacity. One compressed shard is conditional |
| Search throughput | Assumed CPU/query gives saturation QPS/core; at QPS, saturation or cores at utilization |
| Replica sizing | Five subtotal shards with two copies gives ten slots, not an all-in deployment. Three compressed replicas share load if the full footprint fits |
| Unmatched storage anecdote | dense versus sparse elsewhere does not validate this representation or corpus |
| Traffic expansion | QPS gives saturation or aggregate cores/logical shard at under the same CPU assumption |
| Freshness target | from a declared event, with visibility and failure behavior specified |
| Nightly scheduling miss | delay-window supremum; 09:00 to midnight is minutes or windows |
| Freshness toy inputs | million chunks; local invalidation and embedding are assumptions, not serving-wide guarantees |
| HNSW scale reference | ; not exactly 24 graph hops or a latency bound |
| Conditional timing margin | – versus is – times; about – orders, if complete-path timing is real |
| Refresh and maintenance | Compaction duration is workload-dependent; Elasticsearch’s default one-second refresh is a different visibility mechanism, not HNSW validation |
| Tombstone symptom | A hypothetical latency increase over three months suggests investigation, not proof of tombstone causation |
| Missing-ingestion symptom | A launch-only index can become stale six months later; event detection and serving checks must be tested |
| General risk gate | , gives under the simplified losses and eligibility constraints |
| Clinical risk gate | , gives ; not a certified clinical automation rule |
| Gate coverage counts | ; ; escalate. These score counts do not validate retained error risk |
| Confidence limit | macro- does not mean error. With zero failures, IID cases give about upper error; are needed for at one-sided |
| Faithfulness probe | Two systems at judged support can have different harmful-error rates; the residual and judge uncertainty need independent risk analysis |
| Threshold warning | Under interior simplified costs, implies ; copied , , thresholds are unjustified without validation |
| Reject-option scope | Chow-style cost-based rejection assumes specified losses and probabilities; review requirements are a separate constraint |
| Hop workload mix | single-route and two-intermediate-round route; perfect classifier is a toy assumption |
| Candidate depths | A pool of or can still miss bridge evidence; a reranker cannot add an item absent from its fixed pool |
| Hop unit work | retrieval; tokens/s; intermediate tokens give ; final tokens give |
| One-shot proxy | ; excluded prefill and serving overhead remain |
| Two-round iterative proxy | , exactly twice one shot. Three rounds instead give |
| Adaptive mean | ; below the always-two-round route |
| External route timing | Adaptive-RAG experiment: , , seconds by route; multi/one ratio , not a universal timing law |
| Hop cap | Three or four rounds is a budget heuristic; reaching it must permit abstention or escalation |
| Tight median target | is below even the one-shot proxy; the deterministic routed median is , not its mean |
| Heterogeneous inventory | million items across text, tables, scans, photos and decks; item count is not vector count |
| Restricted modality | Tables limited to two departments in the toy; enforce per-document/tenant grants, not only source labels |
| Page representation | About vectors/page in a common ColPali setup; patch configuration and pages/deck affect capacity |
| Reranking unit | candidates/source; each is an equal-cost serial-work assumption using compatible scorers |
| Full modality work | candidates; serial reranking, not a general batched wall time |
| Two-source work | candidates; serial work; fewer candidates and less work before overhead |
| RAGRoute experiments | MMLU: about fewer calls, less transfer; accuracy . MIRAGE top-32 separately: |
| Router break-even | No universal two-source cutoff. Compare routing overhead, evidence misses and weighted search/scoring savings |
| Debug baseline | questions; EM means correct/ wrong; three -token chunks give evidence tokens |
| Debug deploy | EM means correct/ wrong; ten chunks give evidence tokens |
| Regression arithmetic | percentage points, fewer correct; relative decrease |
| Stage-specific evidence | At matched diagnostic cutoff, recall ; prompt gold presence . Neither exonerates retrieval or proves sufficient support |
| Paired and micro counts | newly broken implies fixed, both correct, both wrong. In a broken-case sample, have the marked gold chunk |
| Mezzo observations | , , across rank groups need denominators, absent-evidence handling and controlled causal checks |
| Top-four intervention | EM, gold presence, evidence tokens; -point improvement from deploy. Rank is bucket , not an edge |
| Format sensitivity | Prompt format can matter; neither a flat rank slice nor a generic double-digit example diagnoses this deployment |
| Retrofit scenario | -month system, two-year-old blog incident, two-week planning window; age alone does not establish falsehood |
| Access audit | A five-minute initial check is an illustration, not a full security/lineage/feasibility audit guarantee |
| CrAM scope | Model-specific influential-head intervention; the checked setup does not justify a universal –-head or injection-performance claim |
| Backfill machine time | join; writes; serial minutes before other work |
| Source-selection toy | sources, documents/source gives candidates; retaining sources gives documents. Full RA-RAG adds answer generation/filtering/voting |
| Source reduction scope | equal-length payload cut. is idealized arithmetic, not the checked paper’s measured 1000-source result |
| Source-scale comparison | ; orders. Source counts do not fix token or total-cost ratios |
| Input-token toy | tokens/document at tokens: versus for document inputs only |
| Isolated daily saving | /query times /day gives /day, before selector, extra generation, outputs, calibration and operating costs |
00-START-HERE · 01-READING-ROUTES · 40_graph_rag · A1_formula_sheet