Production RAG needs authorized sources, reliable ingestion, tested retrieval and answers that respect the evidence. Evaluate these stages separately and define what happens when knowledge is missing, stale or contradictory. Retrieval can ground a response; it does not automatically authorize an action.
What is current—and what remains your responsibility
OpenAI’s current file-search documentation describes hosted retrieval with semantic and keyword search, result controls and optional inclusion of search results for inspection. Its retrieval guide describes vector-store searches and attribute filtering. These are useful capabilities; they do not eliminate your need to define permissions, authoritative sources and acceptance tests.
OWASP’s vector and embedding guidance treats access partitioning and poisoned knowledge as security concerns. Its prompt-injection prevention guidance covers the risk of instructions embedded in material an LLM processes. A retrieved document can be relevant while still containing untrusted instructions.
This edition replaces unsupported deployment counts, universal cost claims and private benchmark results with a concrete evaluation method. Configuration examples are starting points to test, not provider defaults or proof that a particular chunk size works everywhere.
Design RAG as an evidence pipeline
1. Define authoritative sources and their lifecycle
Choose an owner for each source and establish how updates, deletion and approval reach the index. A policy document should carry its product, country, language, revision and effective period. Keep ingestion status visible so a failed import is not mistaken for missing business knowledge.
Handle tables, scanned files and embedded images deliberately. A parser that drops a column heading can transform a correct policy into misleading text. Compare extracted content with representative originals and record rejected or ambiguous documents for correction.
2. Enforce authorization before retrieval
Resolve tenant, user and applicable access rules on the server. Apply those rules to the candidate set and any reranking or caching path. A model instruction saying “do not reveal another customer’s data” does not repair a query that already fetched it.
Test a user with revoked access, overlapping group membership and a copied query from another tenant. Verify that search, citations and diagnostic logs all honor the boundary. A filtered final answer is insufficient if protected chunks remain exposed through a debug endpoint.
3. Retrieve the evidence the question actually needs
Use semantic search for paraphrased questions and exact matching for identifiers, part numbers or policy clauses. Consider hybrid retrieval and reranking where the workload benefits, but measure the change. More retrieved text can add conflicting or irrelevant evidence as easily as it adds useful context.
Do financial calculations with structured records and deterministic code. Document retrieval is appropriate for explaining a rule; a transactional API may be necessary to establish the current order state. Connect the two only through explicit identifiers and policy logic.
4. Generate, verify and abstain
Give the model a bounded evidence bundle and require citations for consequential factual claims. Check that a citation points to material that actually supports the claim, not merely a related document. When evidence is insufficient, the answer should name the missing information or route the case to an appropriate person.
Keep tool authority separate. Even a fully grounded answer about refund policy does not prove that a specific customer is eligible or that this agent can issue a refund.
Find the failed stage before changing the model
| Test layer | Question | Correction when it fails |
|---|---|---|
| Ingestion | Did the correct revision and its meaning survive extraction? | Repair parsing, approval or synchronization. |
| Authorization | Can this identity retrieve only permitted evidence? | Fix server-side filtering and isolation. |
| Retrieval | Are necessary passages present in the candidate set? | Improve metadata, query routing, indexing or retrieval settings. |
| Answer grounding | Does each material claim follow from the supplied evidence? | Improve synthesis, instructions, evidence selection or abstention. |
| Business outcome | Did the user complete the intended task safely? | Repair workflow, tools, approval or handoff. |
Build a versioned set of real, appropriately protected questions with expected evidence and acceptable answers. Include unanswerable cases and conflicting versions. Separate tuning examples from holdout acceptance cases. Label who reviewed the ground truth and how disagreements were resolved.
Use retrieval metrics appropriate to the task. A question needing one rule differs from a comparison requiring several sources. Record whether the necessary evidence is found at the chosen cutoff and whether access constraints are upheld. Then score answer correctness and unsupported claims independently.
For high-consequence workflows, review severity as well as averages. One answer leaking an account record should not disappear inside a generally strong accuracy score. Keep regressions visible when changing embeddings, chunking, reranking, prompts or models.
Worked example: two return policies that are both real
Illustrative scenario: a store has a general thirty-day returns page and a separate fourteen-day rule for a product category in a particular country. An older archived document still says sixty days. The customer asks whether an item purchased three weeks ago can be returned.
A basic vector search may find all three documents because they are semantically relevant. A reliable workflow first resolves product and market, then filters for the effective policy revision. It retrieves the controlling rule and explains how it applies to the verified order.
If product metadata is missing or the policy hierarchy is ambiguous, the system should seek clarification or human review. It should not average the time limits or select whichever passage appears first. Citations to all three pages would make the answer look researched without settling the decision.
Turn this scenario into several tests: a product outside the exception category, an order from a different country, a document update during the conversation and a user without access to the order. Keep the expected behavior explicit for each variation.
The most useful RAG test often asks whether the system knows which evidence should control the answer.
Price the completed answer, including the failures
Account for ingestion and reindexing, storage, embeddings, retrieval, reranking, model input and output, monitoring and review. Hosted retrieval may bill differently from your own infrastructure. Check the current contract and provider pricing rather than borrowing a token estimate from an older comparison.
Illustrative usage calculation: 60,000 answers using an average 2,000 input tokens and 300 output tokens imply 120 million input tokens and 18 million output tokens before retries. Multiply each quantity by the applicable current rate. Then add retrieval, storage and non-model operating costs. This is workload arithmetic, not a vendor quote.
Compare cost per accepted answer or completed task. If a cheaper configuration increases escalations, users’ correction time or repeated contacts, its token savings may be economically irrelevant. Keep cost and quality on the same evaluation set.
Cache only with a defined scope and expiry. A policy answer might be reusable within a product, region and revision. A customer-specific answer also needs identity and current account state. Test cache invalidation on policy updates and deletion requests.
See the agentic data-layer guide when the workflow combines documents with live records, and the ROI framework when comparing deployment economics.
A practical release checklist
- Approve the authoritative source set and verify representative extraction outputs.
- Confirm source timestamps, policy revisions and deletion behavior.
- Test unauthorized queries across every retrieval and diagnostic route.
- Compare candidate configurations on a fixed, versioned evaluation set.
- Exercise missing evidence, contradictory sources and injected instructions.
- Verify citations support the claims and remain accessible to the intended user.
- Test dependency timeout, fallback and exception ownership.
- Measure accepted outcomes, review burden and actual usage cost.
- Document the rollback path for source, index and model changes.
Launch in a bounded workflow with an owner who can inspect failures and correct the source of error. A scorecard without source lineage cannot explain regressions. A continuously updated index without regression checks can silently introduce them.
Choose RAG, fine-tuning or a combination according to the problem. Retrieval supplies external evidence; fine-tuning can address repeatable behavior. Neither substitutes for permission checks or deterministic action rules. The support architecture comparison develops that decision.
Questions about production RAG
Does RAG eliminate hallucinations?
No. Retrieval can supply evidence, but missing, stale or conflicting sources and incorrect synthesis can still produce unsupported answers.
Should every question use a vector database?
No. Exact identifiers, calculations and live transactional state may need keyword search, structured queries or APIs. Route the question according to its evidence requirements.
What should we measure first?
Check ingestion, authorization and retrieval separately from answer correctness. This identifies the failed stage before you change the model.
Can a cited policy authorize a refund?
No. Verify the customer’s current record, eligibility and the agent’s action authority separately before executing a refund.
Primary references checked for this edition
- OpenAI file search
- OpenAI retrieval
- OWASP vector and embedding weaknesses
- OWASP prompt-injection prevention
Checked on 11 October 2026. The examples and release methodology are editorial guidance, not private benchmark results or guaranteed deployment performance.
Research Path