Key takeaways
- Production RAG starts with reliable ingestion, metadata, document versions, and permissions, not prompt tuning.
- Hybrid retrieval with reranking is safer than vector search alone for business workflows with exact terms and access rules.
- Citations, refusals, and validators should be part of the answer contract from day one.
- Evaluation must test retrieval, groundedness, citation accuracy, permission safety, freshness, latency, and cost.
- Monitoring should trace the whole answer path while protecting sensitive content in logs.
Start with the production shape, not the chatbot demo
To build a RAG system for production, treat it as a data product with an LLM interface, not as a prompt wrapped around a vector database. You need reliable ingestion, controlled chunking, access-aware retrieval, grounded citations, fallback behaviour, evaluation datasets, and monitoring before users depend on it.
RAG: retrieval-augmented generation, where an application retrieves relevant source material at query time and asks a language model to answer using that material.
A useful production architecture has seven moving parts:
- Source connectors for PDFs, web pages, databases, tickets, emails, contracts, or internal tools.
- Ingestion pipeline for extraction, cleaning, deduplication, metadata, and versioning.
- Indexing layer with vector search, keyword search, or hybrid retrieval.
- Permission filter that applies tenant, role, document, and field-level rules before generation.
- Answer service that handles retrieval, reranking, prompt assembly, citations, validation, and fallbacks.
- Evaluation harness with golden questions, adversarial tests, and regression checks.
- Observability stack for traces, retrieval quality, latency, cost, and user feedback.
At Zettaura, this distinction matters because our products handle practical workflows rather than toy corpora. A live document product such as ZiaSign has to respect documents, signatures, audit trails, and legal context. A future finance workspace such as Buckhy has a different risk profile because money-related answers need stricter confidence boundaries.
What should the ingestion pipeline do before indexing?
Bad retrieval usually starts before retrieval. If the ingestion pipeline extracts noisy text, loses table structure, ignores document versions, or drops permissions, the LLM will produce confident answers from broken context.
A production ingestion pipeline should be asynchronous, retryable, and inspectable. Do not make users wait for every document to finish indexing inside a request-response path. Store each stage output so engineers can debug whether an answer failed because of OCR, chunking, embedding, retrieval, or generation.
Minimum ingestion stages:
| Stage | Production requirement | Common failure mode |
|---|---|---|
| Extract | Preserve text, tables, page numbers, headings, and file metadata | PDF text order is wrong, tables become unreadable |
| Clean | Remove boilerplate, repeated headers, footers, and corrupted characters | Chunks repeat irrelevant content across pages |
| Classify | Detect document type, language, sensitivity, and source system | Retrieval mixes policies, invoices, contracts, and FAQs blindly |
| Version | Track source ID, checksum, ingestion time, and superseded versions | Answers cite an old policy after a newer upload |
| Authorise | Attach tenant, user, group, document, and field permissions | Users retrieve content they should not see |
| Index | Write to vector, keyword, and metadata indexes atomically | Partial updates create missing or duplicate results |
Document versioning: storing enough identity and timestamp information to know which source revision produced a chunk, embedding, citation, and answer.
For document AI, extraction quality is not the same as OCR. OCR turns an image into text; document AI needs layout, fields, clauses, tables, and workflow context. We cover that distinction separately in AI Document Processing vs OCR, and the same lesson applies to RAG ingestion.
If you process personal data in India, ingestion design must also account for consent, purpose limitation, access controls, retention, and vendor handling. The Digital Personal Data Protection Act, 2023 is available via India Code, and our practical product checklist is here: DPDP Act compliance checklist for startups in India.
How should you chunk documents for reliable answers?
Chunking is a product decision, not only an embedding decision. The right chunk boundary depends on what the user asks, how citations should appear, and whether the answer requires one clause, one table row, or a whole policy section.
Chunk: the smallest retrievable unit of source content stored with text, metadata, permissions, and a citation pointer.
Use structure-aware chunking where possible. A contract clause, event policy section, payment FAQ, or invoice table is usually a better unit than a fixed 800-token slice. Fixed-size chunks are acceptable for early systems, but production teams should add document-aware rules as soon as answers need citations and auditability.
| Chunking method | Best use | Trade-off |
|---|---|---|
| Fixed token window | Fast prototype, uniform text | Cuts clauses, tables, and lists in awkward places |
| Heading-based | Policies, manuals, help centres | Fails when documents have poor heading structure |
| Semantic chunking | Mixed prose with topic shifts | More processing cost and harder repeatability |
| Layout-aware | PDFs, contracts, invoices, forms | Requires better extraction and page mapping |
| Entity-aware | Contracts, finance, compliance records | Needs domain rules and validation |
Every chunk should carry metadata that supports filtering and citations: source ID, page, section heading, document type, owner, tenant, created time, effective date, language, sensitivity label, and version. For contracts, a clause title and party names may matter. For event ticketing, venue, date, organiser, and refund policy may matter. A platform like MakeMySquad, which is launching soon for event booking and live experiences with QR ticketing and UPI payments, would need retrieval units that separate ticket terms, payment status, organiser instructions, and attendee-facing policies.
Avoid over-chunking. Tiny chunks improve precise matching but starve the model of context. Large chunks preserve context but dilute retrieval and increase prompt cost. A practical rule is to optimise against evaluation questions, not a universal token count.
Retrieval architecture: vector search is not enough
Vector search is good at semantic similarity, but production RAG often needs exact identifiers, dates, names, SKUs, invoice numbers, clause references, and policy titles. A user asking for "termination clause in the vendor agreement" and a user asking for "agreement ZS-1042" need different retrieval signals.
Use hybrid retrieval by default for business workflows:
- Apply permission and tenant filters before candidate expansion.
- Run keyword search for exact terms, identifiers, and titles.
- Run vector search for semantic matches.
- Merge and deduplicate candidates.
- Rerank with a cross-encoder, lightweight LLM, or domain scoring rules.
- Trim to the smallest context that can answer the question with citations.
Hybrid retrieval: combining lexical search, vector similarity, metadata filters, and reranking instead of relying on one search technique.
The reranker is where many small teams get a large quality jump without changing the model. You can score chunks for query relevance, freshness, authority, document type, and citation quality. For example, a signed agreement should outrank an unsigned draft if the user asks about a final obligation. A current policy should outrank an archived policy if both match semantically.
The hard part is access control. Never retrieve broadly and then ask the model to ignore forbidden content. Permission filtering must happen before the prompt is assembled. If your app supports teams, clients, organisers, departments, or external collaborators, model the access rules as data and test them like security logic.
The NIST AI Risk Management Framework is a useful reference for thinking about governance, mapping, measurement, and management of AI risks. For LLM-specific application risks such as prompt injection and data leakage, the OWASP Top 10 for Large Language Model Applications is a practical engineering checklist.
Answer generation needs citations, refusals, and validators
The answer service should not simply paste retrieved chunks into a prompt and return the model output. It should assemble context, instruct the model to answer only from sources, require citations, validate the result, and choose a fallback when confidence is weak.
A production answer contract should define:
- What sources were retrieved and which were used.
- Whether the answer is extractive, summarised, or inferential.
- Which citation supports each factual claim.
- What the model must do when sources conflict.
- What the model must refuse to answer.
- Which structured fields must pass validation.
Citation: a source pointer that lets the user inspect where an answer came from, ideally down to page, section, clause, row, or timestamp.
Citations are not decoration. They are part of the product interface and debugging system. If a contract assistant says a renewal notice period is 30 days, the user should be able to open the exact clause. If an event organiser asks about a refund rule, the system should point to the organiser policy or ticket terms, not a vague source title.
Use validators after generation. These can be simple JSON schema checks, citation coverage checks, date parsers, currency normalisers, contradiction checks, or domain rules. For legal and document workflows, we discuss validation patterns in Validating LLM Outputs in Production, and the broader build constraints in What it actually takes to build an AI document platform.
Fallbacks should be explicit. A good RAG system can say: "I could not find this in the available documents", "I found conflicting sources", or "You do not have access to the document that may contain this answer". Those responses are more useful than a fluent guess.
What should you evaluate before launch?
You cannot evaluate a RAG system only by reading a few nice answers. Build a small but representative evaluation set before launch, then keep adding failures from production.
Start with 50 to 150 hand-written questions if your domain is narrow. That number is not a benchmark; it is a practical range for a small team to cover happy paths, edge cases, and regressions without creating a research project. Include questions that should be answered, questions that should be refused, and questions where the answer changed after a document version update.
Track these evaluation dimensions:
| Dimension | What to check | Example failure |
|---|---|---|
| Retrieval recall | Did the correct source appear in top candidates? | Right contract clause never reached the prompt |
| Groundedness | Is every factual claim supported by cited sources? | Model adds a notice period not in the document |
| Citation accuracy | Do citations point to the exact supporting text? | Citation opens the right PDF but wrong page |
| Permission safety | Can a user retrieve another tenant's content? | Shared embedding index leaks metadata |
| Freshness | Does the system prefer current versions? | Archived policy beats current policy |
| Refusal quality | Does the system decline unsupported questions? | Model answers from general knowledge |
| Latency and cost | Is the flow usable at expected load? | Reranking or OCR blocks the user path |
Evaluation should run in CI for prompt, chunking, retrieval, and model changes. Store the retrieved chunks and final prompts for failed cases, or your team will waste hours guessing which layer regressed.
For structured outputs, define machine-checkable contracts. JSON schema validation, required citation IDs, allowed enum values, and deterministic post-processing catch many problems before users see them. The W3C work on web standards, including accessibility guidance, is also relevant when RAG answers become part of user-facing workflows that must be readable, navigable, and auditable.
Monitoring production RAG after users arrive
Production monitoring should separate infrastructure health from answer quality. A low error rate does not mean the product is answering correctly. A fast response can still cite the wrong source.
Instrument the full trace for each answer:
- user, tenant, role, and permission scope, with sensitive values protected;
- query text and query classification;
- retrieval filters, candidate IDs, ranks, and scores;
- chunks sent to the model;
- prompt template and model version;
- answer, citations, validator results, and fallback path;
- latency and cost by stage;
- user feedback and subsequent correction.
Do not log raw sensitive content by default. Use redaction, sampling, access controls, and retention limits. If your product handles contracts, finance, or identity-linked workflows, logs can become a secondary data store with the same privacy and security obligations as the primary system.
Operational dashboards should show retrieval miss rate, citation failure rate, refusal rate, validator failure rate, model timeout rate, ingestion backlog, stale index count, and top failing document types. These metrics are more actionable than a single "AI accuracy" chart.
Plan for model changes. Store prompts, retrieval inputs, and evaluation outputs so you can compare behaviour before switching model versions or embedding models. Embedding migrations need dual indexing or background reindexing; otherwise old and new vectors become difficult to reason about.
Where this leaves you
A production RAG system is a controlled retrieval and evidence system with an LLM at the end. If you build ingestion, permissions, citations, evaluation, and monitoring late, the rewrite usually happens after users have already found the failure modes.
For a small team, the concrete next step is to choose one narrow workflow, collect real documents, write evaluation questions, and implement the full path from ingestion to cited answer before adding more sources. If you are building AI features around documents, contracts, events, or finance workflows, you can explore Zettaura's product direction at our products page or start a focused conversation through contact.
Frequently asked questions
What is the simplest production RAG architecture?
The simplest production architecture has an ingestion pipeline, a searchable index, permission-aware retrieval, an answer service with citations, an evaluation set, and monitoring. You can start with one vector database and one LLM, but you should still design the data flow so extraction, chunking, retrieval, and generation can be debugged separately.
Should I use vector search or hybrid search for RAG?
Use hybrid search for most production business applications. Vector search handles semantic similarity, while keyword and metadata search handle exact names, dates, IDs, document types, and permissions. Reranking then decides which candidates should reach the model.
How do I stop a RAG system from hallucinating?
You cannot eliminate hallucinations with a prompt alone. Reduce them with better retrieval, strict source-grounded prompts, citations, schema validation, contradiction checks, refusal rules, and regression tests for known failure cases.
How should permissions work in a RAG system?
Permissions should be applied before retrieval results are sent to the model. Each chunk should carry tenant, user, group, document, and sensitivity metadata, and retrieval should filter candidates using those rules. Never rely on the model to ignore content the user should not see.
How do I evaluate RAG quality before launch?
Create a representative set of questions with expected sources, expected answer behaviour, and refusal cases. Measure retrieval recall, groundedness, citation accuracy, permission safety, freshness, latency, and cost. Add real production failures back into the test set as regressions.
ZiaSign is live today. Learn more about ZiaSign or explore the full Zettaura portfolio.


