Optimizing Chunking and Embedding Models for Retrieval
This lesson explains an evaluation-driven process for fixing RAG systems that retrieve the wrong passages, usually because of how documents were chunked and embedded.
Learning outcomes
After completing this lesson, you will be able to:
- Measure retrieval quality with a labelled test set.
- Compare and optimise embedding models.
- Optimize chunks and context.
Measuring retrieval
Retrieval cannot be improved reliably without measuring it. A retrieval test set contains realistic questions, each labelled with the passages that answer it. On that set, recall@k measures the share of questions whose relevant passage appears in the top k results; precision@k measures how many of the top k are relevant; mean reciprocal rank (MRR) rewards ranking the first relevant passage highly; and NDCG rewards good ordering of all relevant passages.
Alternatively, Amazon Bedrock retrieve-only evaluation jobs score context relevance and context coverage with an LLM judge, without labelled passages. Without such measurement, changes to chunking, embeddings or search settings are guesses.
Retrieval metrics
Optimizing the embedding model
Compare embedding models on the test set, because quality varies by domain and language. Use a multilingual model for multilingual content. Higher dimensions may improve recall at more storage cost. Some models distinguish document and query input types, which must be set correctly. For specialist vocabulary, a domain-tuned embedding model hosted on SageMaker AI, or fine-tuned on question-passage pairs, can outperform general models. Any change of model requires re-embedding the corpus.
The following diagram compares recall@5 for an English-focused and a multilingual embedding model on English and Spanish questions.

Improve the embeddings
Optimizing chunks and context
Adjust chunk size and overlap, try hierarchical or semantic chunking, improve parsing of tables and layouts, remove boilerplate (headers, footers, navigation text) that dilutes embeddings, and enrich chunks with titles or section headings so they carry context. Add metadata for filtering. The following table maps symptoms to fixes.
| Symptom | Likely fix |
|---|---|
| Relevant passage never retrieved | Better parsing, different chunking, better embedding model, hybrid search |
| Retrieved but ranked low | Reranking |
| Passages from wrong product or period | Metadata filters |
| Chunks lack context to answer | Larger or hierarchical chunks; add headings to chunks |
| Poor results in other languages | Multilingual embedding model |
| Boilerplate passages retrieved | Clean documents before chunking |
A multilingual knowledge base
A travel company's knowledge base serves English and Spanish users. Recall@5 is 0.84 for English questions but 0.52 for Spanish ones.
- Evaluate Cohere Embed Multilingual against the current English-focused embedding model on 300 labelled questions per language.
- Recall@5 for Spanish rises to 0.81 with the multilingual model, with English unchanged.
- Create a new knowledge base with the multilingual model, sync, re-run the evaluation and switch the application.
Changing the generation model would not have helped, because the correct passages were not being retrieved in the first place.
What should be measured before changing anything in retrieval?
Show answer
Retrieval quality, for example recall@k or a Bedrock retrieve-only evaluation.
Exam Tips
Remember for the exam
- Measure retrieval with recall@k or Bedrock retrieve-only evaluation before changing anything.
- Changing the embedding model requires re-embedding and usually a new knowledge base.
- Multilingual content: multilingual embedding model.
- Clean boilerplate and add headings to chunks.
- Change one component at a time and compare on the same test set.