Articles · Artificial intelligence · · 8 min read
RAG Retrieval Design on Azure AI Foundry
Retrieval decisions made at index time — chunk unit, filters, freshness, the context contract — set the ceiling on what any RAG answer can be.
By Matthieu de La Mettrie · Founder, Skopura
A RAG system that answers badly is usually retrieving badly. The model gets blamed because the model is the visible part, but the decisions that bound the answer were made upstream — when someone chose a chunk size, decided where the permission filter lived, and picked what the retriever hands the generator. Azure AI Foundry gives you somewhere to host the orchestration. It does not make those choices for you, and swapping the model underneath will not undo them.
This is about the decisions, and what each one costs you later.
What is the unit of retrieval?
Start here, because everything downstream inherits it. The unit of retrieval should be the unit the answer is made of. If users ask “what is the notice period in this contract”, the answer is a clause, and a clause is the chunk. If they ask “summarise what changed in this policy”, the answer spans a document, and chunk-level retrieval will hand the generator five fragments that each look relevant and collectively misrepresent the document.
The failure mode is subtle: retrieval returns something plausible for every query, so nothing errors. You only find out when someone who knows the corpus reads an answer and says that is technically in there but it is not the point.
Splitting on token counts is the default because it is easy to implement and uniform to reason about. It is also indifferent to meaning — it will cut a definition away from the term it defines, and strand a table header from its rows. Structural splitting respects the document’s own boundaries and produces chunks of wildly uneven size, which makes your embedding and ranking behaviour uneven too.
| Fixed-size chunks | Structural chunks | |
|---|---|---|
| Boundary logic | Token or character windows with overlap | Headings, clauses, sections, list items |
| Chunk size | Uniform and predictable | Uneven, sometimes very short or very long |
| Typical failure | Definition severed from the term it defines | A single huge chunk dominating every result |
| Ingestion effort | Low — one parser for everything | Higher — per-format parsing rules |
| Suits | Homogeneous prose | Structured documents with stable headings |
| Hard to change later | Reindex and re-embed everything | Reindex, re-embed, and revisit parsing rules |
A practical middle path: chunk structurally, then carry the parent context into the chunk’s text — document title, section path, effective date if the corpus has one. Retrieval then matches on the fragment but the generator sees where it came from. You pay for this in embedding volume, and you should know that before you do it at corpus scale.
Where does the permission filter live?
In the index query, before scoring. Not as a post-retrieval filter, and never as an instruction in the prompt.
The post-filter version is the one that sneaks through review because it produces correct output. You retrieve the top candidates, drop the ones the user cannot see, pass the rest. The answer is correct. The problem is that the candidate set was chosen without regard to permissions, so a user with narrow access gets a thin, arbitrary slice of what was actually relevant to them — and the system has no way to tell them that. Worse, retrieval metadata, chunk counts, and any “sources considered” display leak the shape of what they cannot read.
This is the same argument as row-level security on a semantic model: the filter belongs where the data is selected, applied by identity, not applied afterwards by the application. Index your access metadata as filterable fields at ingestion. If entitlements live in a system that changes independently of your documents, you need a reconciliation path, because a stale entitlement in an index is a disclosure, not a bug.
How many knobs are you actually committing to?
More than the design document suggests. Chunking strategy, embedding model, filter design, hybrid weighting, candidate depth, reranking, context assembly — each is a decision with a small set of defensible options, and they interact.
The point is not that you must test all of them. It is that you cannot tune this by intuition one deploy at a time, and that every configuration change invalidates whatever qualitative judgement you formed about the previous one. Fix the corpus, fix a query set, and move one thing at a time — or accept that you are guessing.
Do you need a reranker?
Not always. A reranker fixes ordering, not recall. If the right chunk is not in the candidate set, a second pass will not conjure it, and the money goes on reordering wrong answers.
Skip it — pass the candidates and spend the effort on chunking
Before reranking, check whether hybrid retrieval solves it. Dense retrieval handles paraphrase and misses exact identifiers — part numbers, section references, surnames. Lexical retrieval does the reverse. A corpus containing both natural language and identifiers needs both, and the weighting between them is a tuning decision you should own explicitly rather than inherit from a default.
How does the index stay current?
The same way a warehouse table does: by processing what changed, not everything. Incremental refresh over a document corpus means change detection at the source, re-embedding only affected chunks, and — the part that gets skipped — tombstoning deletions.
Deletes are where private-corpus RAG goes wrong quietly. A document is withdrawn, the source system removes it, and your index keeps serving it because nothing in your pipeline listens for absence. The model cites a withdrawn policy with full confidence and perfect formatting. Build the delete path on day one, and give yourself a way to prove the index matches the source — a reconciliation job that compares identifiers both ways and reports drift.
Freshness also has a retrieval dimension. If your corpus has superseded versions, relevance alone will rank an old version highly because it is textually similar. Supersession is metadata, and it belongs in the filter or the ranking, not in a prompt instruction asking the model to prefer recent documents.
What contract does retrieval hand the generator?
A typed one. The generator should not receive a concatenated blob of text with separators; it should receive a structured packet where each passage carries its identifier, its source path, and whatever provenance you intend to display. Then constrain the output to a schema that requires every claim to reference a passage identifier that was actually supplied.
type Passage = {
id: string;
documentId: string;
sectionPath: string[];
text: string;
supersededBy?: string;
};
type ContextPacket = {
question: string;
passages: Passage[];
scopeNote: string; // what the filter excluded, in plain words
};
type Answer = {
claims: Array<{ text: string; passageIds: string[] }>
;
unanswered?: string; // what the corpus did not cover
};Structured outputs constrain the response to the schema, which gives you a mechanical check rather than a judgement call: reject any answer whose passage identifiers were not in the packet. That one validation catches a whole class of confident fabrication without a model-graded evaluation in the loop.
The unanswered field matters more than it looks. A system that can say which part of the question the corpus does not cover is a system users can calibrate against. One that always produces a complete-looking answer trains people to stop checking.
How do you tell retrieval failures from generation failures?
By evaluating them separately, with different instruments. Retrieval is scoreable without a model in the loop: for a fixed query set with known relevant passages, you can check whether the right passage appeared in the candidate set and where it ranked. That is deterministic, cheap to run on every index change, and it tells you whether the ceiling moved.
Generation quality sits on top of that ceiling and needs its own harness. Conflating the two produces the familiar loop where someone rewrites the system prompt for a week to fix a problem that was a chunk boundary.
The shape above is the argument for sequencing: prompt work has a ceiling set by retrieval, and retrieval work has a ceiling set by the corpus. Order your effort accordingly.
Which of these decisions age badly?
The ones that require a full re-embed to revisit — chunk unit, embedding model, what metadata you captured at ingestion. Anything in that group should be decided deliberately and instrumented so you can tell when it is wrong.
The cheap decisions are the ones teams spend the most time on, because they are the ones you can change without a reindex. Spend the design effort at the top of that tree, capture more metadata at ingestion than you think you need, and keep a query set with known answers from the day the first document lands. The system you can diagnose is worth more than the one that demos well.
rag · azure-ai-foundry · retrieval · agentic-ai · system-design
Share on LinkedIn ↗Work with Skopura
Facing this bottleneck in your own estate?
Skopura builds production-grade lakehouse pipelines, evaluation harnesses, and provides fractional data leadership. Thirty-minute call, no deck.