RAG knowledge systems: design, evaluation and release
Practical guide
Updated:
Design a traceable business knowledge system with document permissions, retrieval metrics, supported answers, versioning and operational acceptance.

Retrieval-augmented generation (RAG) brings retrieved material into a model's answer. A dependable business knowledge system also needs source ownership, document permissions, retrieval evaluation, supported citations and a clear response when evidence is missing.
This guide covers product FAQs, policy queries, review analysis and internal training knowledge. Start with data pipelines, then continue to agent workflows.
1. Define the question, evidence and user
| Use case | Appropriate evidence | First checks | Acceptance question |
|---|---|---|---|
| Product FAQ | Approved specifications, manuals and warranty terms | Model, market and effective version | Does the answer match the applicable specification? |
| Policy query | Original platform or organisational policy | Effective date, jurisdiction and business scope | Does it resolve old and new versions correctly? |
| Review analysis | Reviews authorised for this use, with source IDs | Permission, language and sample period | Can claims be traced, and common themes distinguished from isolated comments? |
| Supplier knowledge | Contracts, specifications and confirmed communications | Access to the relevant supplier's information | Does it prevent disclosure across customers, tenants or teams? |
| Internal training | Approved SOPs, courses and operating guidance | Owner, updates and withdrawal process | Can staff complete a task and find its original evidence? |
Begin with a bounded, authorised and testable question set. Translate efficiency goals into actual task time, review time, errors, rework, query cost and user success. Measure a baseline before comparing a pilot.
The original RAG paper combines a parametric model with retrieved non-parametric memory and evaluates specified knowledge-intensive tasks. A business system needs evaluation on its own documents and workflows.
2. Design ingestion, querying, permissions and versions
flowchart LR
A[Authorised source documents] --> B[Parsing, source and permission metadata]
B --> C[Chunking and index versions]
C --> D[Retrieval and reranking]
U[Authenticated user's question] --> D
P[Server-enforced document scope] --> D
D --> E[Evidence checks and answer generation]
E --> F[Answer, sources, versions and next steps]Assign stable document and passage IDs. Retain source location, content version, owner, effective date, language, permission scope and withdrawal status. A chunk must remain traceable to its original page, table, clause or passage.
The server authenticates the user and restricts retrieval to authorised documents. Apply the same permissions to citations, search snippets, caches, logs and downloads. Instructions inside a document cannot grant access.
Microsoft's document-level access guidance is one implementation reference. Check the chosen service version, preview status and identity integration before adopting a particular approach.
Updates and deletion
An edit becomes queryable only after parsing, indexing, version publication and cache updates have completed. Withdrawal must also address old passages, derived summaries and citation links. Preserve pending, failed and completed ingestion states rather than reporting unsuccessful work as finished.
3. Compare technical choices using evidence
| Decision | What to compare | Evidence to retain |
|---|---|---|
| Parsing | PDF tables, scans, page references, punctuation and OCR errors | Source/parsed samples and failures |
| Chunking | Clause integrity, headings, table context and cross-passage questions | Retrieval results for a fixed question set |
| Embeddings | Target language, specialist terms, product codes, model version and dimensions | Comparable retrieval evaluation |
| Search | Keyword, vector, hybrid retrieval and filtering | Recall, precision, latency and cost |
| Reranking | Ranking improvement against added latency and expense | Results on the same candidate set |
| Generation | Evidence use, abstention, citations and output format | Human checks and failure categories |
| Deployment | Identity, storage, backups, data transfers and operating capacity | Configuration, recovery exercises and costs |
Evaluate chunking and Top-K rather than assuming a universally best token length. Changing an embedding model or its dimensions requires an index rebuild and version-switching plan. Test the actual store's capacity, filters, durability and backups under the intended workload.
Lost in the Middle investigates information position in specified long-context tasks. It motivates testing evidence placement and distracting material; its experimental findings are not a fixed performance estimate for every current model.
4. Build an operable knowledge system
- Inventory: establish ownership, permitted uses, access, provenance and publication scope. Separate unapproved or uncertain sources.
- Parsing checks: inspect tables, scans and important figures. Keep failed documents visible for follow-up.
- Indexing: create stable IDs, versions and permission metadata. Evaluate chunking, retrieval and reranking with real questions.
- Query service: authenticate, enforce document scope, handle timeouts and empty results, and return traceable source locations.
- Answer contract: define coverage, citation format and treatment of conflicting or insufficient evidence.
- Evaluation: retain the same questions, source versions, model settings and scoring method for each comparison.
- Controlled pilot: have authorised users complete real tasks. Record review effort, errors and rework.
- Release and recovery: switch index versions after acceptance; monitor source updates, failed jobs and broken citations, with a rollback path.
5. Evaluate retrieval and answers separately
Retrieval metrics
Label relevant documents or passages for answerable questions. Handle unanswerable, unlabelled and permission-restricted questions separately. This function takes actual passage IDs and calculates per-question Precision@K, Recall@K and reciprocal rank truncated at K. It rejects duplicate IDs. Precision@K retains K as its denominator even when fewer results are returned.
function retrievalMetrics(retrievedIds, relevantIds, k) {
const validIds = ids => Array.isArray(ids) && ids.every(id =>
typeof id === "string" && id.length > 0 && id === id.trim());
if (!validIds(retrievedIds) || !validIds(relevantIds)) {
throw new Error("Explicit passage ID arrays required");
}
if (!Number.isSafeInteger(k) || k < 1) throw new Error("Positive integer k required");
if (!relevantIds.length) throw new Error("Evaluate unlabelled or unanswerable questions separately");
if (new Set(retrievedIds).size !== retrievedIds.length ||
new Set(relevantIds).size !== relevantIds.length) {
throw new Error("Duplicate passage IDs must be resolved before evaluation");
}
const relevant = new Set(relevantIds);
const top = retrievedIds.slice(0, k);
const hits = top.filter(id => relevant.has(id)).length;
const first = top.findIndex(id => relevant.has(id));
return {
k, returned: top.length, relevant: relevant.size, hits,
precisionAtK: hits / k,
recallAtK: hits / relevant.size,
reciprocalRankAtK: first < 0 ? 0 : 1 / (first + 1)
};
}These values measure retrieval hits. They do not establish answer faithfulness, support for each claim or business impact. When aggregating results, state the number of questions, annotation method, averaging approach and unscorable items.
Answers and user tasks
| Dimension | Check |
|---|---|
| Facts and versions | Compare claims with effective sources, including units, dates, models and markets |
| Citation support | Verify that the cited passage supports the nearby claim, rather than merely discussing the topic |
| Missing evidence | Explain what is missing and how to clarify the question or obtain human help |
| Permissions | Test the same question across accounts, roles and tenants, including snippets and caches |
| Task success | Observe completed work, review effort, errors and rework |
| Operating cost | Record latency, retrieval/generation charges and human handling cost |
The Ragas paper distinguishes retrieval and generation evaluation dimensions. Automated scoring can assist triage and regression comparisons; business-critical answers still need checks against original evidence and domain judgement.
6. Handle missing, conflicting and hostile evidence
- No results: retain the question and authorised search scope; request a model, date or document, or refer the task to its owner.
- Conflicting versions: show applicable versions and scope. Follow approved precedence rules or obtain the document owner's decision.
- Unsupported citation: prevent the answer from being treated as verified; retrieve again or seek review.
- Changed permissions: enforce the new access policy and address old caches and download links.
- Embedded requests to disclose data or take action: treat these as source content, not permission to escalate access, transmit sensitive information or invoke tools.
OWASP's prompt injection guidance explains that RAG does not fully eliminate prompt injection. Enforce permissions, tool restrictions and data-handling rules in the application.
7. Release, maintain and accept the system
Protect authentication, document access, credentials, uploads and resource use. Inspect the actual data flows of embedding, generation, telemetry and other connectors. Running one model locally does not establish that every component keeps data on the device.
Exercise backup, recovery, reindexing, rollback and deletion. Retain necessary operational logs while preventing private documents and customer queries from spreading into unprotected monitoring services.
Acceptance should cover normal answers, missing evidence, conflicting versions, broken sources, timeouts, unauthorised access, tenant isolation, withdrawal, model/index changes and process restarts. Report the actual questions, data versions, outcomes, failures and improvement actions.