Improving Chunking and Embedding Quality for RAG
This lesson explains chunking strategies, what determines embedding quality and how to measure both, since retrieval-augmented generation (RAG) can only be as good as the passages it retrieves.
Learning outcomes
After completing this lesson, you will be able to:
- Compare fixed-size, structure-aware and semantic chunking.
- Identify what determines embedding quality.
- Measure retrieval with metrics such as recall@k and NDCG.
Chunking strategies
Chunking splits documents into units that are indexed and retrieved. Fixed-size chunking splits by a token count (for example 512 tokens with 10-25% overlap) and is simple and predictable, but can cut a table or a procedure in half. Structure-aware chunking follows the document's headings, sections, paragraphs and tables, usually after layout extraction with Azure Content Understanding or the Document Layout skill in Azure AI Search, so each chunk is a coherent unit. Semantic chunking splits where the topic changes, measured by embedding similarity between sentences.
Each chunk carries metadata: the source document, section title, page, date, access-control groups and document type. Prepending the document and section titles to the chunk text improves both keyword and vector matching, because isolated paragraphs often lack the context that names their subject.
The following diagram applies the three strategies to the same manual.

Which chunking strategy?
Embedding quality
An embedding model converts each chunk and each query into a vector. Embedding quality is the degree to which relevant chunks end up close to the queries they answer. It depends on the model (text-embedding-3-large generally retrieves better than text-embedding-3-small at higher cost and storage), on consistent preprocessing between indexing and querying, on chunk size (very long chunks dilute meaning) and on language and domain coverage. The same model and dimensions must be used for documents and queries; changing the model requires re-embedding the whole index.
What affects embedding quality
Measuring retrieval
Chunking and embedding choices are compared with a labelled set of queries and the chunks that should answer them. The following table lists the usual metrics.
| Metric | Question it answers |
|---|---|
| Recall@k | Are the relevant chunks among the top k results? |
| Precision@k | What share of the top k results are relevant? |
| Mean reciprocal rank (MRR) | How high does the first relevant result appear? |
| NDCG | Are the most relevant results ranked highest, accounting for graded relevance? |
Foundry's document retrieval evaluator computes such metrics from query relevance labels. Measuring retrieval separately from answer quality shows whether a poor answer comes from retrieval or from generation.
Retrieval metrics
Split tables
A maintenance assistant answers questions about torque values from equipment manuals. Answers often give values for the wrong model, and inspection shows that tables are split across fixed 512-token chunks, separating column headers from rows.
Structure-aware chunking that keeps each table (or each table row with its headers) in one chunk, with the manual and model name prepended, fixes the cause. A larger embedding model or a stronger generation model would not reunite headers with their rows.
Why measure retrieval separately from answer quality?
Show answer
A poor answer can come from poor retrieval or from poor generation. Retrieval metrics such as recall and precision show which part failed.
Exam Tips
Remember for the exam
- Tables and procedures split mid-way: structure-aware chunking with layout extraction.
- Prepend document and section titles to chunks; attach filterable metadata.
- Measure retrieval (recall, precision, MRR, NDCG) separately from answer quality.