Skip to content

Design the hypothetical enterprise knowledge base for 10 million documents

15 min reading

Defend a complete retrieval service with workload-derived storage, freshness and access assumptions.

Page details

GenAI · Lesson 18 of 45 · 2 / case 1

Sources · 15 min reading · 33 min with practice

Published · Last edited:

More
20px

Progress is saved in this browser when storage is available.

View guided paths and progress

Know first: Ingestion, permissions, revisions and deletion as one evidence lifecycle. Optional help: GenAI foundations.

Optional background references

Hypothetical scenario. Northwind brings its retrieval decisions into a larger knowledge-base exercise. Maya describes the answers employees need. Dev starts with a document count, while Priya asks him to derive the searchable artifacts and revision workload before choosing infrastructure.

Maya: “The service needs current, permitted evidence, even while documents change.”

Dev: “A document can create several chunks and several derived records.”

Priya: “Show that ledger and the answer path before translating scale into machines.”

You will combine the supplied hypothetical collection calculations with retrieval, freshness and authorization contracts. The earlier mechanisms become a service design whose storage assumptions and request failures can be inspected independently.

Which assumptions turn a collection into an operable service?

Hypothetical scenario. Choose 10,000,000 documents, eight chunks per document, 768 components per embedding and four bytes per component. The collection contains 10,000,000 × 8 = 80,000,000 chunk vectors. One vector's raw payload is 768 × 4 = 3,072 bytes. Total raw embedding payload is 80,000,000 × 3,072 = 245,760,000,000 bytes, or 245.76 decimal GB. Two complete copies require 491.52 GB of embedding payload.

This excludes source text, metadata, index structures, replicas beyond those two copies, temporary rebuild state and filesystem overhead. It therefore cannot justify a machine count. Suppose a daily revision exercise changes 1% of documents: 10,000,000 × 0.01 = 100,000 documents, yielding 100,000 × 8 = 800,000 replacement chunk vectors under the fixed-chunk assumption. Authorization and version visibility must remain correct during that work.

Defend ingestion checkpoints, tenant filtering, dense/sparse fusion, reranking and evidence assembly as separate boundaries. If the freshness goal cannot tolerate a full rebuild, define incremental version publication and deletion behavior. The scale case is complete only when a learner can trace an authorized question through those boundaries and explain what happens during a partial revision failure.

Hypothetical scenario. An updated policy reaches storage but has not reached the assistant’s searchable index.

In short. Track each source revision through ingestion. Carry authorization into retrieval and caches.

Design the answer before choosing the components

Hypothetical scenario. An equipment library wants a question-answering service over its handbook. Readers ask about borrowing rules; staff also maintain restricted inspection records. The proposed service must explain current public rules, cite their source, and say when the evidence cannot resolve a question. It will not reserve equipment or change records.

That last boundary matters. A read-only explanation service has a different contract from an assistant that performs transactions. Adding a generator does not authorize access to staff records or make an ambiguous policy decision acceptable. Start by describing a useful answer, a safe abstention, and what the system must never disclose.

This chapter connects retrieval, chunking, embeddings, and indexes into a design a reviewer can challenge. The goal is to trace one request across its evidence boundaries, derive a complete hypothetical context budget, and locate failures using a small evaluation table.

Submit a complete knowledge-base design packet

Hypothetical scenario. For the ten-million-document exercise, define document and chunk identities, permission ownership, index generations and the answer evidence record before selecting shards. Document count alone cannot determine vector count, update work or query capacity.

Submit a complete knowledge-base design packet
ArtifactConcrete evidenceDecision boundary
Interfaceingest revision / query / withdrawExplicit accepted outcomes
Manifestsource, children, index generation, watermarkCoherent publication
Answer recordcaller scope, evidence, dispositionSupport and disclosure audit
Publish eligible source revisions: Source + ACL authority → Versioned retrieval.Publish eligible source revisions: Source + ACL authority → Versioned retrieval. Source + ACL authority to Versioned retrieval: publish eligible source revisions; Versioned retrieval to Answer service: candidate evidence; Answer service to Model gateway: bounded permitted prompt; Model gateway to Answer service: proposal to validate.Source + ACLauthorityVersioned retrievalAnswer serviceModel gatewaypublish eligible source revisionscandidate evidencebounded permitted promptproposal to validate
Publish eligible source revisions: Source + ACL authority → Versioned retrieval. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

The ingestion plane builds versioned candidate indexes from coherent source boundaries. The serving plane authenticates, retrieves permitted candidates, reranks, assembles bounded context and validates supported output. Keep shared permission, embedding and generation services visible as failure domains. Warm-cache measurements cannot certify a cold replacement index or source outage. Compare two deployment options using the same workload assumptions, current-disclosure rule and recovery obligation.

Working components can still make a broken service

A text extractor can successfully return text while scrambling a table's headers. An embedding job can complete while using the wrong document revision. Search can return a nearby passage that lacks the relevant exception. Generation can produce fluent prose that cites an unrelated line. Checking that every component returned a value does not establish that the answer met the task.

“Local” is also a deployment description, not a privacy or reliability certificate. A locally hosted service can send text to external telemetry, retain it in logs, or expose it to the wrong user. Conversely, component location alone does not specify access control, update behavior, or evidence quality.

Test component behavior separately from integration and user-visible outcomes. A successful search response alone does not establish that the complete evidence path selected current, authorized sources or generated a supported answer. Exercise the entire request boundary with known evidence.

Separate index publication from answer serving

In the preparation path, identify the source revision, extract its content, preserve meaningful sections, and construct searchable units. Keep text, location, permissions, and representation version associated with each record. A searchable index is derived from these records; it must be possible to explain which source snapshot it represents.

Publish an evidence revision, then serve bounded requests The preparation path creates and checks a versioned record set and index before publishing a revision. The request path resolves identity and scope, retrieves and expands permitted evidence from that revision, composes a bounded request, and checks answer support. An unavailable or insufficient evidence path can end in abstention. Source snapshot+ extractionRecords + vectors+ index checksPublish revisionretain provenanceRequest + identityresolve scopeRetrieve + expandpermitted evidenceBudget + answercheck or abstainPreparation and serving share a declared revision.

Publish a candidate only after checking that its text records, vector representation, and index agree. One possible design writes a new complete revision and switches a reference after validation. This is a design option, not a claim that every storage system provides an atomic switch automatically. Define what happens to requests already using the previous revision and to source changes arriving during the build.

At serving time, resolve the caller's scope, retrieve candidates, recover any permitted surrounding context, and preserve source references. Then account for the actual assembled request. The answer contract should require support for substantive claims and an explicit response when the evidence is absent, inconsistent, or unavailable.

Anthropic’s Contextual Retrieval describes adding chunk-specific context for retrieval and combining semantic and lexical retrieval. It is a concrete retrieval intervention, while the coherent-publication and permission boundaries here remain application design choices. The name RAG does not establish those guarantees.

Balance the complete request budget

Hypothetical scenario. The design chooses a combined input/output allowance of 4,096 tokens for one request. This is an illustrative application limit, not a statement about any vendor model. All counts use the generator's tokenizer and include the declared request formatting.

AllocationTokensWhat is included
Output reserve512Maximum planned response
Instructions and fixed formatting384Task contract and fixed wrappers
User request128This example's formatted question
Source labels and evidence separators96This example's selected references

The non-evidence allocation is 512 + 384 + 128 + 96 = 1,120 tokens. Evidence allowance is 4,096 − 1,120 = 2,976 tokens. Three expanded source units of 900, 800, and 700 tokens total 2,400. The plan leaves 2,976 − 2,400 = 576 tokens unused.

A fourth 650-token unit would make evidence total 3,050, which exceeds its allowance by 3,050 − 2,976 = 74 tokens. The application must choose a different evidence set, shorten it under an explicit policy, or change its request plan. Silently cutting the last passage may remove the exception needed to answer correctly.

The 96-token reference allocation is specific to this example. If the evidence set changes, measure its actual labels and separators again. Count after expansion and deduplication; neither an index's child-window size nor its embedding tokenizer establishes the generator's final request size.

Also declare a request deadline. Suppose the design allocates 80 ms to queueing, 50 to query encoding, 40 to search, 30 to source expansion, 1,500 to generation, and 100 to answer checks. Their sequential allocation sums to 1,800 ms within a chosen 2,000 ms deadline, leaving 200 ms. These are planning assumptions, not measured durations or added latency percentiles. A proposed 500 ms retry cannot fit the remaining allowance.

In the wild: Designing a Retrieval Service from Source to Answer

Daniel Ford's Contextual Retrieval report at Anthropic: Contextual Retrieval adds chunk-specific context before indexing as a concrete retrieval intervention.

Inspect where evaluation cases fall out

Hypothetical scenario. A reviewer labels 20 cases before a design comparison: 16 are answerable from the permitted current collection, and four are not. For the 16 answerable cases, retrieval supplies sufficient evidence in 14 and misses needed evidence in two.

Case groupSupported answerUnsupported answerAbstentionTotal
Answerable, sufficient evidence retrieved121114
Answerable, evidence missed0022
Not answerable from the collection0134
Total122620

Evidence coverage among answerable cases is 14/16 = 87.5%. Supported answers among answerable cases are 12/16 = 75%. Across every case, supported answers are 12/20 = 60%, unsupported answers 2/20 = 10%, and abstentions 6/20 = 30%. The last three fractions sum to 100% because the outcome categories are disjoint and exhaustive here.

Three abstentions concern answerable questions: two follow missing evidence and one occurs despite sufficient context. The other three are appropriate for unanswerable questions under the chosen contract. Thus the abstention count alone cannot identify a good or bad system. The table points to different investigations: source selection, evidence use, and refusal to guess.

This small invented set illustrates diagnosis. It does not prove statistical significance, a real production success rate, or safety on other questions. Test changed permissions, conflicting revisions, extraction damage, and unavailable dependencies as separate conditions.

A valid index can point to the wrong text

Hypothetical scenario. The service rebuilds vectors from a new handbook extraction but leaves its text lookup table on the previous revision. Chunk identifiers are reused. Search returns a valid identifier, expansion resolves it successfully, and the answer quotes text that was not represented by the selected vector.

Every individual call can succeed. The broken invariant is the association between source text, representation, and revision. Repair the publication boundary and verify those associations. Do not assume that rewording the prompt or increasing search depth will fix mismatched records.

Retain revision information that detects mismatched artifacts and test recovery against known source evidence. Restoring files alone is insufficient when identifiers, source versions or authorization metadata disagree. The recovery target is a coherent evidence release, including the relationships between its parts.

Promises that exceed the design

“Local means private.” Inspect network calls, logs, caches, access decisions, and backups. The machine location alone does not establish who can see the content.

“The pipeline works because it produced an answer.” An answer must satisfy the evidence, scope, and output contract. Returning prose is only one stage.

“All stages passed, so the whole path is correct.” Shared identifiers, revisions, and assumptions can fail between individually functioning components. Exercise the complete path.

“More retrieved text is always safer.” Extra text can consume the budget, add contradictions, or expose forbidden material. Select and inspect the evidence that the answer actually requires.

Choose a service you can explain and operate

Use a retrieval-and-answer pipeline when the collection is large or changing enough to justify selection and users benefit from synthesized, inspectable evidence. Start with an exact or otherwise transparent retrieval baseline and a small set of demanding cases. Add acceleration or reranking when the measured gap warrants it.

A document browser with good search may already satisfy the task. A structured inventory lookup should not be replaced by generated guesses about availability. If a question requires judgment beyond the permitted source, return the evidence and a clear boundary instead of presenting a policy inference as an established fact.

Before extending the service to actions, design the authorization, side-effect, and recovery contract separately. This chapter's read-only service does not establish that a reservation or record update would be safe.

Limits of Designing a Retrieval Service from Source to Answer

The read-only service needs coherent source, representation and permission identities. A successful answer does not authorize a future edit. Expanding into actions requires a separate accepted-state and recovery contract at the authority that performs the write.

Test the interface boundary

Recovery keeps the original contract: prove coverage / reauthorize.Recovery keeps the original contract: prove coverage / reauthorize. Candidate index to Current permission: prove coverage / reauthorize; Current permission to Reader switch: eligible cutover only.Candidate indexCurrent permissionReader switchprove coverage / reauthorizeeligible cutover only
Recovery keeps the original contract: prove coverage / reauthorize. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

A replacement index is ready but its ACL watermark trails revocations. Which alternative can still serve?

Reveal the design reasoning

A separate current authority check may enforce eligibility if it covers every disclosure path. Otherwise hold cutover or return unavailable for affected work. Matching source totals cannot establish permission completeness.

Decision: Approve one bounded architecture with cold, failed-dependency and migration cases.

Check yourself: challenge the proposed pipeline

The selected evidence fits the budget as indexed children, but parent expansion adds an exception and doubles the text. Which count governs the request?

The final assembled request under the generator's tokenizer governs it. Recount after expansion, labels, formatting, and deduplication. Preserve enough evidence to support the decision; do not silently truncate the exception merely to keep the old count.

In the 20-case table, all six abstentions are removed by forcing an answer. Can the supported-answer rate be calculated for that new policy?

No. The original table does not tell us what forced answers would say. Some cases lack evidence entirely. Evaluate the changed policy rather than converting abstentions into assumed successes; retain unsupported-answer counts as a separate outcome.

Search and text lookup both return HTTP success, but their revision identifiers differ. Should the generator proceed and let a citation reassure the reader?

No. The source association has not been established. Reject or recover through a verified matching revision under a defined policy. A successful transport response and a citation cannot repair a mismatched evidence record.

Northwind decision log

Track each source revision through ingestion.
Carry authorization into retrieval and caches.
Expose evidence freshness in the answer record.

Go deeper into evidence-path design

Check the mechanism in this lesson

Can 245.76 GB of calculated raw embeddings justify purchasing a single server with that much memory?

Compare the explanation

No. The figure excludes index structures, text, metadata, rebuild state and operating overhead. It also says nothing about throughput or latency. Derive those demands separately and measure the selected implementation.

Carry the decision forward

Northwind can defend an evidence-backed answer path. Page 19 introduces a different promise: changing a support record, where a generated proposal must cross an explicit action boundary.