Retrieve information, then use it
Retrieval-augmented generation, usually shortened to RAG, combines a retrieval system with a generative model. The retrieval stage selects material relevant to a question. The generation stage receives selected material and produces a response. A document index and a model are distinct components; adding documents to an index does not necessarily retrain the model.
The original RAG research paper studied models combining pretrained parametric knowledge with a retrieved document representation. Modern applications use a variety of retrieval and prompting arrangements. Describing a system as RAG therefore identifies a broad pattern, not a single algorithm or a guarantee of factual accuracy.
A policy lookup example
Imagine a company assistant answering, “Can a customer return a repaired item?” Its approved collection contains warranty terms, a returns policy, and an obsolete procedure. A retrieval stage searches for passages about repaired items, returns, and applicable exceptions. It supplies selected passages to the model together with the question.
The model might compose an answer that distinguishes the ordinary return period from an exception for repaired products. A useful interface points to the actual passages supporting that distinction. The citation should lead to the correct version and relevant section, rather than merely naming a document that happens to contain similar words.
Now change the example. Suppose the retrieval stage finds only the ordinary return policy and misses the repair exception. A fluent answer can still be incomplete. If it retrieves the obsolete procedure, the response can be well grounded in the wrong evidence. These are different failure modes, requiring inspection of retrieval inputs and results as well as the final prose.
Building a useful collection
A collection needs document boundaries, titles, dates, and a way to update or remove stale material. Dividing a long file into passages can make retrieval more selective, but a passage may lose the heading that tells readers which product it governs. Keep enough surrounding context to preserve meaning.
Microsoft’s RAG architecture overview identifies query understanding, token limits, response time, and access control among the practical challenges. Those concerns exist even when retrieval finds something semantically similar to the question. Similarity alone does not establish authority, currency, or user permission.
Access control belongs before disclosure
Retrieved content can also contain instructions intended to change a model’s behavior. OWASP describes this as indirect prompt injection: a webpage or document may include hostile instructions that are passed to the model along with the user’s question. Treat retrieved passages as untrusted data. Permission checks in the retrieval layer limit which documents a user may receive, but they do not prevent malicious text in an authorized document from influencing a model. Keep access decisions in application-controlled checks, and require explicit human approval for consequential actions rather than relying on the model to recognize every hostile instruction (OWASP Gen AI Security Project).
In the policy example, some documents may be public and others restricted to staff. The retrieval service should return only material the requester is allowed to access. Hiding a source link after the model has already used restricted text would not undo the disclosure. Treat the retrieved passages and generated answer as part of the same information flow.
A small evaluation can create two users with different permissions and a document visible to only one. Ask both users a question answered by that document and inspect what information enters each request. This is a system test, distinct from testing whether the wording of an answer sounds reasonable.
Evaluate the stages separately
First ask whether retrieval found the necessary, authorized, current evidence. Then ask whether the answer accurately used it. Include questions that the collection cannot answer, questions with ambiguous wording, and questions whose answer requires two sources. A response should be allowed to acknowledge insufficient evidence rather than filling a gap with a plausible invention.
One useful diagnostic is to retain the selected passage identifiers alongside a test answer. A reviewer can then distinguish a missed document from a misread document. If the correct passage was absent, changing only the response instructions may leave the real problem untouched. If it was present but contradicted by the answer, inspect generation and answer checking instead.
RAG can make external information available to a language application, but usefulness depends on collection quality, selection, source handling, and response checking. Understanding tokens and context helps explain why selection is necessary. Understanding APIs helps map the boundaries between the interface, retrieval service, and model service.