Retrieval-augmented generation, or RAG, lets a business app retrieve relevant information and provide it to a language model while generating an answer. It is useful when answers depend on documents your organization owns, such as support guides, product manuals, or internal procedures. A dependable RAG app also needs permission checks, current source material, traceable citations, and a way to recognize when the evidence is insufficient.
The central engineering question is whether the right user receives an answer supported by the right version of the right document. Uploading PDFs and connecting a chat interface only demonstrates a small part of that workflow.
This guide uses an illustrative support assistant for a software company. Staff ask questions about product setup and support procedures. Some documents are shared across the company, while others belong to a particular customer. The assistant drafts answers for review; it does not issue refunds or change customer accounts.
When does a business app need RAG?
Start by asking where the answer should come from. RAG is a reasonable candidate when the source material is too large or changeable to include in every prompt, and users need help finding and combining relevant passages.
Microsoft's RAG architecture overview describes grounding model responses in organizational content. Its examples also show that retrieval, token limits, response time, and access control are part of the design, rather than details to add after a demo.
RAG is not automatically the best interface for every question. If the user wants an order's current status, a permission-checked API lookup is usually a clearer source than a vector index containing yesterday's order export. If the workflow needs a calculation, use the appropriate application logic and verified inputs. If a small help section already works through ordinary search, measure whether a generated answer adds enough value to justify the extra work.
Choose one question category for a pilot. “Help support agents explain setup steps from approved manuals” is easier to evaluate than “answer anything about our business.”
Define the answer contract first
Before selecting a model or vector database, agree on the response the product should produce. For the support assistant, I would require a direct draft, source references, and a clear explanation when the available sources do not support an answer.
Define the boundary between retrieval and action. Reading a troubleshooting guide should not give the model permission to run a customer command. If action tools are introduced later, they need their own authorization and confirmation rules. My MCP vs REST guide explains why an integration protocol does not replace those application rules.
Also name the reviewer. A staff drafting tool and a public self-service chatbot have different consequences when they are wrong. For an initial internal release, a visible draft with source links and a review step can provide useful feedback without making the generated wording the company's final response.
Prepare documents before generating embeddings
Create an inventory of approved sources. For each source, record its owner, document ID, version, effective date, permitted audience, and canonical location. Decide who can publish a revision and how withdrawn content is removed.
Inspect extracted text before indexing a large collection. A PDF can look clear to a person while its extracted text loses reading order, splits a table, or joins unrelated columns. The model will receive that extracted representation, not the visual document your team reviewed.
For a setup manual, check headings, numbered instructions, warnings, and product version labels. Keep a warning attached to the step it qualifies. Do not merge two customers' documents into one passage just because their file names resemble each other.
For my proposed pilot, I would start with a small, well-owned collection and manually inspect a sample of the extracted passages. That makes a retrieval failure easier to diagnose than beginning with every shared drive and trying to repair ownership and formatting later.
Chunk around meaning, then evaluate retrieval
Chunking divides documents into passages that can be retrieved independently. The Azure AI Search chunking guide describes several approaches, including preserving document structure and using overlap to retain context at boundaries.
There is no useful universal chunk size for every company's documents. A short policy paragraph, a configuration reference, and a multi-step repair procedure have different shapes. Begin with headings and logical sections, then inspect the results against actual questions.
For example, a passage saying “restart the service” may be misleading if the preceding paragraph says that the operation requires a maintenance window. Returning more text can restore that context, but also adds irrelevant material and consumes the model's input budget. Compare a few strategies rather than copying a token count from a tutorial.
Test retrieval before asking the model to write polished answers. For each question, record which source passage should appear and inspect whether it does. If the correct evidence never reaches the model, adjusting the answer prompt is unlikely to fix the underlying problem.
Compare keyword, vector, and hybrid search
Vector search can help with questions that use different wording from the source. Keyword search remains useful for exact product names, error codes, identifiers, and unfamiliar abbreviations. A hybrid approach combines both types of evidence.
Microsoft's ranking overview explains how its search service ranks different query types. The important product lesson is to evaluate the complete retrieval configuration, including filters and any reranking stage, against your own questions.
For this assistant, my comparison set would include a natural-language setup question, a literal error code, an old product name, and an ambiguous question that needs clarification. Inspect false matches as well as missing results. A highly similar passage about another product version can still be the wrong evidence.
Keep the selected passages within an explicit context budget. Adding every search result increases cost and gives the model more opportunities to combine incompatible instructions. Sometimes the best response is a follow-up question about the product version, rather than another retrieval pass.
Enforce document permissions before model input
Authenticate the user at the backend and derive their tenant and access scope from trusted application state. Apply that scope to retrieval. Never let a prompt or client-supplied tenant ID choose which customer's collection is searched.
Document-level access control guidance describes approaches such as query-time security filters. The available mechanisms and preview status depend on the service and data source, so verify the exact integration you intend to deploy.
For the proposed assistant, I would also check the selected documents before passing their text into the model. A stale index or misconfigured search filter should not silently become permission to disclose a document. The source viewer must independently enforce access when a user opens a citation.
Apply the same reasoning to answer caches, conversation history, exports, and debug logs. Caching by question text alone can serve one customer's response to another. Cache keys and invalidation need to account for the access boundary and source versions, or the answer should not be shared across those requests.
Treat retrieved text as untrusted evidence
A document can contain instructions addressed to an assistant, including text that tries to override the task or disclose private information. OWASP's prompt-injection guidance explicitly notes that RAG does not fully prevent this class of attack.
Separate system instructions, the user's question, and retrieved evidence in the application. Keep source-ingestion privileges limited, and test documents that contain malicious or misleading instructions. Prompt wording can help define the task, but it cannot serve as the application's permission system.
Keep secrets and unnecessary personal data out of model context. For this read-only pilot, I would not give the model sending, payment, deletion, or administration tools. Extending its capabilities later should require a new review of the workflow, rather than inheriting every backend permission.
The broader issue is covered in AI agent security: model output is an input for application handling, not a trusted command to execute without checks.
Make citations traceable and freshness visible
Assign source IDs to the passages actually selected for the request. Ask the model to reference those IDs, then validate that each returned ID belongs to that permitted evidence set. Construct citation labels and links from backend metadata instead of accepting arbitrary model-generated URLs.
That verifies the citation's identity, not whether the claim is supported. During evaluation, inspect whether the cited passage actually justifies the statement. A real link to an unrelated paragraph is still a bad citation.
For the support workflow, I would display the relevant manual version and let staff open the source. If evidence conflicts, the draft should identify the conflict or ask for clarification. A similarity score alone should not be presented as a probability that an answer is correct.
Maintain an update path too. New versions, deletions, and permission changes must propagate to indexes and caches. Track when each source was last processed and alert on failed ingestion. Define a freshness requirement with the document owner; “the documents update eventually” is difficult to operate or accept.
Evaluate retrieval and answers separately
Microsoft's evaluation documentation distinguishes retrieval, groundedness, relevance, and completeness evaluators. Those categories are useful even if your pilot uses a different stack or begins with a manually reviewed evaluation set.
My initial set would contain these cases:
- Answerable: the current manual contains a direct answer and should be cited.
- Terminology mismatch: the question uses wording different from the manual.
- Missing evidence: no approved document supports an answer, so the assistant should explain the limitation or escalate.
- Wrong version: an older manual contains a plausible but outdated procedure.
- Permission boundary: a relevant customer-specific document is unavailable to the requesting user.
- Conflicting sources: two approved passages disagree and need a defined precedence rule or visible uncertainty.
- Injected instruction: source text attempts to redirect the assistant.
Record the expected source, required facts, prohibited disclosures, and acceptable failure behaviour for each case. Review a held-out set after tuning; repeatedly editing the system to pass the same handful of examples can hide weaknesses. Model-based grading can help organize review, but should not be the sole judge of access control or consequential factual claims.
Control latency, cost, and release scope
Measure ingestion, retrieval, reranking, and generation separately. A slow answer can come from any of those stages. Track end-to-end response time alongside answer quality; a faster response that omits necessary evidence is not an improvement.
Set limits on input length, retrieved context, generated output, retries, and concurrency. Estimate operating costs using the chosen provider's current prices and a stated workload. Include document processing, search infrastructure, and maintenance rather than treating model tokens as the entire budget.
For a pilot, agree on the approved collection, supported question categories, review process, evaluation threshold, and rollback route. Keep conventional search or human support available when generation fails. Expand the collection only after you can explain the failures in the smaller release.
Common questions before starting a RAG project
Does RAG train the model on company documents?
RAG supplies retrieved material at request time; that is different from updating model weights. Separately review the provider's data-handling terms and your logging configuration. Using retrieval alone does not establish how a service retains submitted data.
Does a vector database make the answers accurate?
It supplies a retrieval capability. Accuracy still depends on source quality, the search configuration, permissions, evidence selection, and how the answer uses that evidence. Evaluate the whole workflow.
What should a first delivery include?
Include a source inventory, ingestion and removal workflow, access rules, retrieval tests, answer evaluations, citation handling, monitoring, and handover. A chat demo alone does not establish those behaviours.
If you are exploring this kind of feature, my AI integration services and backend development services start with the workflow and its evidence boundary. Share the questions and source material so we can define a pilot with a clear evaluation plan.



