Table of Contents
Retrieval exists because the model is not your application’s knowledge layer.
A model can answer from patterns encoded in its parameters and from context supplied with the current request. It has no live access to your application data unless the application provides it. Internal documents, current product rules, tenant-specific policies, and recently changed runbooks do not become available just because the application can call a language model.
The model’s built-in knowledge lives in its weights. When the application relies on those weights, the model generates likely output rather than querying a versioned source of truth. The application cannot reliably ask where a fact came from, whether it reflects the approved version for a given date, or whether it applies to the current user. Even if a fact appeared in training data, the model might not recall it correctly.
Retrieval lets the application select evidence from identifiable sources. When the pipeline preserves the necessary metadata, the result can retain source ownership, version, provenance, and access information. The model can still produce a bad answer, but the application no longer depends on model weights as its only knowledge source.
Sending every possible document with every request is not a durable solution either. The application needs a pipeline that manages source freshness, determines which records the user may access, finds relevant evidence, and decides what is worth placing in the model context.
In this article, retrieval means relevance-based evidence selection from a candidate corpus:
Select useful evidence from multiple candidates at runtime.
In RAG, the application makes that selected evidence available to the model as context.
Retrieval does not make the evidence true or the model deterministic. It does not enforce permissions on its own.
The model has a knowledge boundary
A language model draws on patterns stored in its weights and the context supplied with the current request. Neither one owns your application’s source of truth.
Built-in model knowledge is the wrong place to own application facts because it is:
- not live: it does not automatically reflect a policy changed yesterday or the current state of a customer’s order
- not authoritative: the model does not own your policies, runbooks, or business state
- not reliably attributable: the application usually cannot trace a parametric fact back to an approved source
- not guaranteed to be recalled correctly: training exposure does not guarantee an accurate answer
- not dynamically access-scoped: model weights do not enforce the current user’s tenant, role, or document permissions at request time
- not version-addressable: the application cannot reliably request the approved policy version for a particular date
Changing to a newer model may change what the model can answer from its built-in knowledge. It does not connect the model to your live application data.
You can place additional information into the request. That works well when the input is already available and reasonably small. For example, a model can summarize a document the user has just uploaded without a retrieval system.
The problem changes when the application owns thousands of possible documents and only a few of them matter for one question. At that point, context is a selection problem.
Retrieval is runtime context selection
A minimal standard retrieval-augmented generation flow looks like this:
user question
-> retrieve relevant evidence
-> assemble the allowed context
-> generate an answer from that context
A common preparation flow for document-based retrieval looks like this:
source documents
-> parse and chunk
-> add metadata
-> index
The runtime side of that standard RAG flow selects information for one request:
question
-> search and filter
-> rank results
-> select context
-> call the model
Several application layers sit between the source data and the model call. Source ownership determines which system is authoritative. Ingestion and synchronization determine which version is available for retrieval. Authorization determines which records are eligible. Retrieval and ranking find relevant evidence within that set. Context assembly decides what enters the model request.
This is why RAG is an engineering concern rather than a prompt trick. Each stage affects the answer and fails in a different way.
Microsoft’s RAG design guidance separates these stages for the same reason: document preparation, retrieval, and generation have different failure modes and need to be evaluated separately.
Retrieval is not the same as vector search
Retrieval means finding useful information for the request. Vector search is one way to do that.
A retrieval path might use:
- lexical or full-text search for terms and phrases
- metadata filters for tenant, product, language, or version
- vector search for semantic similarity
- hybrid search that combines text and vector results
- a relational database with suitable text or vector search
- an internal API that already exposes a search capability
The information-retrieval phase of a RAG system may use full-text, vector, hybrid, filtered, or multi-query search. Embeddings are important, but they are not the definition of retrieval.
In ordinary language, an API call that fetches application state also retrieves data. I use retrieval more narrowly here to mean selection from a candidate corpus. A structured lookup or query starts with a known key or explicit predicates and returns application state. Corpus retrieval starts with an information need and ranks relevant evidence among multiple candidates. They have different failure modes and should not be forced through the same search path.
Without this distinction, teams often send every question through a vector database because the feature has an LLM in it.
If a user asks for order A-1842, semantic similarity is not the main problem. The application already has an exact identifier. Query the system of record.
If a user asks, “Which runbook explains intermittent timeouts after a deployment?”, semantic retrieval may be useful because the wording in the question might not match the document title.
Choose the retrieval method from the shape of the question and the data, not from the AI label attached to the feature.
What retrieval gives the application
Corpus retrieval becomes useful when the required knowledge is outside the current request and must be selected from many candidates.
Access to private and domain-specific knowledge
Internal policies, product documentation, support notes, architecture decisions, and operational runbooks belong to the application or organization. Retrieval makes selected parts of that corpus available at request time.
The source system still owns the knowledge. The model receives only the material selected from that corpus.
Selection from more information than one request needs
A large knowledge base may contain millions of words, but a question might depend on three paragraphs.
In a standard RAG pipeline, retrieval reduces the candidate set before the model call. A smaller, focused context is usually cheaper and easier to inspect than repeatedly sending the entire corpus. Agentic systems may search several times between model calls, but each search still performs the same selection job.
A larger model context window can move the limit, but it does not remove the selection problem. More available space does not tell the application which document is current or which section answers the question.
Independent updates
Application knowledge changes on its own schedule.
A runbook can be corrected, a policy can expire, or a product version can be retired without changing the model. A retrieval system can reindex that source data and expose the updated material at runtime.
This does not make freshness automatic. The ingestion and deletion paths still have to work. Keeping knowledge outside the model allows it to change independently. Retrieval makes updated material selectable from a corpus without retraining the model.
Permission-aware context
The application can apply tenant, role, product, region, or document-level constraints while it queries the corpus.
Those constraints must come from trusted application context. Similarity is not authorization, and a model-supplied tenant ID is not an access-control decision.
Keep eligibility filters separate from semantic ranking. Authorization should narrow the eligible records using trusted application context. Retrieval can then rank those records by relevance. I use the same boundary in Keep vector search filters separate from semantic ranking.
Inspectable evidence
Retrieved results can carry document IDs, chunk IDs, versions, headings, and source URLs into the generation step.
That gives the application a traceable retrieval path:
question
-> retrieval query
-> retrieved chunk
-> source document
This metadata is the basis for an inspectable evidence path, but it does not prove that a generated claim came from a particular chunk. The model may combine sources, rely on its weights, cite the wrong chunk, or add an unsupported claim. To trace a claim back to evidence, the application has to create an explicit citation or attribution and validate it. Groundedness evaluation answers a separate question: whether the supplied evidence supports the generated claims. Keep RAG citations tied to retrieved chunks covers the first part of that work. Microsoft’s RAG evaluation guidance treats retrieval quality and response groundedness as separate measurements.
One assistant, six different data problems
Consider an internal support assistant. It receives these requests:
| Request | Best starting point | Why |
|---|---|---|
| “Explain eventual consistency.” | Model knowledge or a supplied reference | This is general knowledge unless the company has a specific definition or requires approved sources. |
| “What is our current cancellation policy for German customers?” | Filtered document retrieval, if the governed policy corpus owns the answer | A policy service or rules engine may be the better source when it owns the current policy. |
| “What is the status of order A-1842?” | Direct API or database lookup | The request identifies one structured record. Similarity search adds ambiguity. |
| “Which orders have been delayed for more than three days?” | Structured API or database query | The request applies explicit filters to application state. Relevance ranking adds no value. |
| “Calculate the SLA deadline for this incident.” | Deterministic application code | Business rules and date calculations should not depend on generated reasoning. |
| “Summarize the incident report I attached.” | Put the report directly in context if it fits | Retrieval may still help when the report is too long or the task needs section selection. |
All six requests could be sent to a language model. They should not all use the same data path.
The model can still provide the conversational interface. The application decides whether the request needs general generation, document retrieval, a structured query, deterministic code, or direct context.
That routing decision is part of the application architecture.
What retrieval does not solve
It does not solve:
- missing knowledge in the source corpus
- stale or contradictory documents
- poor chunk boundaries
- weak metadata
- incorrect permission filters
- bad ranking
- excessive or noisy context
- unsupported claims added during generation
- malicious instructions in retrieved content
If the only indexed policy is obsolete, retrieval can return it perfectly and the final answer will still be wrong.
Poor chunk boundaries can prevent the retrieval pipeline from returning enough context to preserve the author’s meaning.
Authorization should be enforced as part of the retrieval query or before results leave the trusted retrieval path. Filtering only after ranking can expose sensitive content to downstream components, logs, caches, or telemetry. It can also leave too few eligible results in the original top-k set. Azure AI Search security filters are one example of applying document-level constraints during the query.
Retrieval does not make content safe. Documents, web pages, and user-provided files can contain misleading instructions or indirect prompt injections. Treat retrieved content as data, not as trusted instructions. Keep tool permissions and authorization decisions outside the model. Indirect Prompt Injection Is a Trust Boundary Problem explains this boundary in more detail.
If you evaluate only the final answer, you may blame the prompt for a retrieval miss.
When corpus retrieval is the wrong solution
Building a dedicated corpus retrieval system is work. Depending on what already exists, the application may have to own ingestion, indexing, synchronization, ranking, evaluation, and operations. Build one when the use case needs runtime selection from a knowledge corpus.
Use a structured lookup or query for application state
Questions about a known customer, invoice, shipment, subscription, or ticket often belong in an authenticated API or database query.
The same applies to filters and aggregations over many records. A request for all delayed orders or the number of cancellations last month belongs in SQL, an API with structured filters, or analytics infrastructure.
Return the structured result to the application. Let the model explain it only if natural-language presentation adds value.
Vector similarity should not decide which customer’s invoice the user meant when the request already contains the invoice ID.
Use deterministic code for rules and calculations
Totals, eligibility checks, deadlines, authorization decisions, and state transitions should use application logic.
A policy document may be retrieved to explain why a rule exists. The actual decision should still come from the code or policy engine that owns it.
Retrieval provides evidence. It does not replace deterministic execution.
Use direct context when the relevant input is already known
If the user uploads one short document and asks for a summary, pass that document to the model.
If every request needs the same small, stable set of instructions, keeping them in a versioned prompt or configuration file may be simpler than building a search index.
Retrieval becomes useful when selection is real. Do not manufacture a search problem where none exists.
Fix behavior problems at the behavior layer
Retrieval is not the first tool for changing tone, output shape, refusal behavior, or tool-selection policy.
Use prompts, structured output, validation, application logic, or, in suitable cases, fine-tuning for those concerns.
Adding more documents will not repair a response-format contract.
Do not treat an ungoverned corpus as authoritative
Retrieval can work over public web pages, user uploads, support tickets, or sources that disagree. The application still needs to preserve provenance and account for the quality and trust level of each source.
A research assistant can report that two sources conflict. An internal policy assistant should not present an outdated or unowned document as company policy. When the use case requires an authoritative answer, establish the source owner, update path, and access model before building retrieval around it.
When retrieval is enough without generation
Sometimes the user needs a list of matching documents, not a generated answer.
In that case, return search results with titles, snippets, filters, and links. Generation adds cost and can blur the distinction between what a source says and what the model inferred.
RAG is useful when synthesis adds value. Search remains a valid product on its own.
A practical decision sequence
Before adding retrieval to an AI feature, ask these questions in order.
1. Does the task require application-owned or source-grounded information that is not already in the request?
If no, retrieval is not needed. Use the model, direct context, or deterministic code according to the task.
If yes, identify the system that owns or provides the missing information.
2. Is the need a structured query, deterministic computation, or relevance-based evidence selection?
- Structured lookup or query: call the database or API using explicit keys, filters, or aggregations.
- Calculation or business decision: run deterministic code.
- Relevance-based evidence selection from a corpus: consider retrieval.
Some requests need more than one path. An assistant might retrieve the policy explanation and call an API for the customer’s current account state.
3. What authority does the source corpus have?
Identify who owns it, how it changes, how deletions propagate, and whether the use case needs authoritative or merely discoverable sources.
If the answer must be authoritative but the corpus has no freshness or ownership model, the work starts before embeddings.
4. Can the application enforce scope before generation?
Define tenant, user, role, region, product, and document constraints. Apply them before the selected context reaches the model.
Do not treat a good semantic match as permission to reveal the content.
5. Can you evaluate retrieval separately?
Keep test questions with expected sources or relevant chunks. For routine telemetry, record document and chunk identifiers, scores, applied filters, and context-selection decisions. Keep raw retrieved content out of logs unless the application’s privacy, security, and retention rules allow it.
If a response is wrong, you should be able to distinguish:
- no relevant source existed
- the source existed but was not retrieved
- the right source was retrieved but excluded during context assembly
- the right context reached the model but the generated answer was still wrong
Without that separation, every failure looks like a model failure.
When to use retrieval
Several conditions make corpus retrieval worth considering:
- the answer depends on private, domain-specific, or changing knowledge that must be selected from multiple candidates
- the available corpus is larger than the useful context for one request
- the application must select evidence using relevance ranking and trusted metadata constraints
- the selected evidence should remain traceable to its source
- the source and retrieval paths can be maintained and evaluated
Do not use retrieval when:
- the required input is already present and small enough to send directly
- the request needs a structured lookup, filter, or aggregation over application state
- deterministic code owns the calculation or decision
- the problem is response behavior rather than missing knowledge
Retrieval can still help discover material in an ungoverned corpus. Do not use that corpus as the authoritative basis for an answer.
Do not add generation when plain retrieval results solve the user need.
Use corpus retrieval when the application must select relevant evidence from many candidates at runtime. When the application supplies that evidence to a model for synthesis, retrieval is the context-selection stage of RAG.
Start with the system that owns the information. If the input is already known, use the simpler path.
Further reading
- RAG Is a Data Problem Before It’s a Prompt Problem
- RAG with EF Core and pgvector
- Keep RAG citations tied to retrieved chunks
- Design and develop a RAG solution
- Develop a RAG solution: information-retrieval phase
- Assess RAG performance: metrics that matter
- Security filters for trimming results in Azure AI Search
- Agent safety