Module 10 RAG OpenSearch and LiteLLM - akash-coded/aws-bedrock-agentcore-strands GitHub Wiki
Retrieval done properly โ chunking, hybrid search, reranking, and an evaluation gate.
Module 10 of 16 ยท track Ground ยท Estimated time: 8โ10 hours ยท Prerequisites: Module 02. Module 06 or 08 for the agentic RAG labs.
The largest module, and the one with the most production value. Naive RAG is easy and usually bad. This module walks the whole pipeline โ corpus, chunking, lexical and dense retrieval, fusion, reranking, context packing, evaluation โ with a reusable ragkit library you can lift into your own work.
Open the module on GitHub โ: the slides, notebooks, exercises and solutions are there. This page is the reading order, with the tutorial and the workbench alongside.
The lesson that frames this module is Is 82% Good Enough? How to Prove an AI Agent Meets Its Bar (6 min): the evaluation gate retrieval has to pass. Then try the acceptance bar calculator in the workbench: the same decision, with your numbers.
- Build RAG by hand before using any managed service
- Choose a chunking strategy from document structure rather than habit
- Combine lexical and dense retrieval with reciprocal rank fusion
- Add reranking and measure whether it actually helped
- Gate a RAG release on evaluation metrics, not impressions
- Route across model providers with LiteLLM and fail over cleanly
| Portable GenAI concepts | AWS-specific surface |
|---|---|
| Chunking | Amazon OpenSearch Serverless |
| Embeddings | Bedrock Knowledge Bases |
| Lexical vs dense retrieval | Bedrock embeddings |
| Hybrid search and RRF | Bedrock Runtime |
| Reranking | |
| Context packing | |
| RAG evaluation | |
| Model routing |
Portable concepts transfer to any stack. The AWS column is where this module touches the cloud โ see docs/concepts/portability-matrix.md.
| # | Step | What it is | |
|---|---|---|---|
| 1 | ๐ | slides/02_RAG_slides.md |
RAG fundamentals |
| 2 | ๐ | src/rag_by_hand.py |
RAG by hand โ no library, no magic |
| 3 | ๐ป | labs/rag-labs/01_foundations.ipynb |
Lab 1 โ foundations |
| 4 | ๐ป | labs/rag-labs/03_index_design.ipynb |
Lab 3 โ index and chunking design |
| 5 | ๐ป | labs/rag-labs/04_retrieval_reranking.ipynb |
Lab 4 โ retrieval and reranking |
| 6 | โ๏ธ | exercises/EX3_RAG_interim1.md |
RAG interim exercise 1 |
| 7 | ๐ป | labs/rag-labs/05_context_generation.ipynb |
Lab 5 โ context packing and generation |
| 8 | ๐ป | labs/rag-labs/06_evaluation_gate.ipynb |
Lab 6 โ the evaluation gate |
| 9 | โ๏ธ | exercises/EX5_RAG_final.md |
RAG final exercise |
| 10 | ๐ป | labs/rag-labs/07_tokens_cost.ipynb |
Lab 7 โ tokens and cost |
| 11 | ๐ป | labs/rag-labs/08_agentic_fde_lab.ipynb |
Lab 8 โ agentic RAG |
| 12 | ๐ | slides/AWS_OpenSearch_Deck_1.pptx |
OpenSearch, part 1 |
| 13 | ๐ป | labs/opensearch/opensearch_lab.py |
OpenSearch lab |
| 14 | ๐ | slides/01_LiteLLM_slides.md |
LiteLLM โ provider routing |
| 15 | ๐ป | notebooks/01_LiteLLM_notebook.ipynb |
LiteLLM notebook |
| 16 | โ๏ธ | exercises/EX6_consolidated_takehome.md |
Consolidated take-home |
๐ read ๐ป run โ๏ธ practise ๐ workbook ๐ reference
Worked solutions live in solutions/. Attempt every exercise closed-book first โ the solutions are written to be read after you have a wrong answer to compare against.
labs/rag-labs/ragkit is a complete, reusable retrieval library โ chunking, fusion, reranking, evaluation, cost. Lift it into your own projects.
- Chunking by character count because it was the default. Structure beats size.
- Reranking added without measurement โ it costs latency and may not help your corpus.
- Evaluating RAG on vibes. Build the golden set first.
Every error anyone has hit in this course is in the Error Index, by the exact string. Model access and region problems are in Model and Region Notes. If it is a question rather than an error, check the answered ones first, then ask in Q&A.
Frameworks
- Grounding Triangle โ The three sides most systems confuse
- Context Budget Ledger โ Pack to a token budget, not a top-k
- Evidence Ladder โ Why the golden set must be frozen first
Quick reference
- RAG pipeline โ Stage by stage, with the failure decoder
- Model selection โ Routing and provider portability
Recipes and procedures
- Runbook ยท stale knowledge base โ Index freshness as a gate check
โ Module 09 ยท LLM Memory Mechanics ยท All modules ยท Module 11 ยท Amazon Bedrock AgentCore โ
โ๏ธ This page is generated from modules/10-rag-opensearch-litellm/README.md. To change it, edit the module README: an edit made here is replaced at the next sync.