1. Ingestion: retrieval quality starts before search
Ingestion is where many RAG systems quietly lose accuracy.
Before chunking, the system should normalize and preserve the structure of the source material:
- document title
- source URL or system of record
- author, owner, team, product, customer, or account
- version and last updated time
- section hierarchy
- table captions and headers
- image captions or OCR output
- permissions and visibility rules
- document type
- lifecycle state such as draft, approved, deprecated, or archived
Microsoft's advanced RAG guidance calls out content preprocessing, metadata extraction, chunking strategy, organization, and update strategy as ingestion concerns. That matters because metadata is not decorative. It becomes a retrieval control surface.
For example, a customer support RAG system might need filters for product, region, plan, support tier, document version, and customer entitlement. If those fields are not captured during ingestion, the query pipeline has to guess.
Chunking strategy
There is no universal chunk size.
Small chunks improve precision but often lose context. Large chunks preserve context but can dilute retrieval and waste prompt budget. A better approach is to choose chunking based on document shape:
| Source type |
Better chunking approach |
| Product docs |
heading-aware sections with parent references |
| API docs |
endpoint or method-level chunks with code examples attached |
| Contracts |
clause-aware chunks with document, party, and effective-date metadata |
| Support tickets |
issue, environment, root cause, and resolution blocks |
| Tables |
row groups plus table title, column headers, and surrounding explanation |
| Slide decks |
slide-level chunks with speaker notes and nearby slide context |
| Codebases |
symbol-aware chunks: file, class, function, dependency, and usage context |
In many systems, the winning pattern is not "small chunks" or "large chunks." It is parent-child retrieval.
The index stores smaller child chunks for precise matching, but the prompt receives a larger parent section when the child is selected. Microsoft describes this idea as Small2Big: find a small unit, then give the model nearby or parent context.
Contextual chunks
Chunking can destroy context. Anthropic's Contextual Retrieval pattern addresses this by adding a short, chunk-specific explanation before embedding and keyword indexing each chunk. The added context tells the retriever what the chunk means inside the larger document.
That is especially useful when a chunk says something like "revenue grew 3%" or "this setting is disabled by default." Without document context, the retriever may not know which company, product, period, or feature the chunk refers to.
Contextual chunks are most useful when:
- documents are long and section-dependent
- the same terms repeat across many products or customers
- chunks contain pronouns or references like "this feature," "the previous quarter," or "the policy"
- exact metadata is missing from the text itself
- you need both semantic retrieval and BM25 keyword retrieval to benefit from the added context
The tradeoff is indexing cost. You spend extra model calls during ingestion to create contextual descriptions. That is usually acceptable for high-value knowledge bases because it moves cost out of the user-facing path.