Skip to content

Commit d0ffbcb

Browse files
committed
Merge Section 2 & 2.5: Unified Retrieved Context Engineering
Major restructuring of Section 2 to consolidate RAG fundamentals and context quality engineering: ## Changes ### New Section 2 Structure (2 notebooks, 2.5-3 hours) - **Notebook 1**: RAG Fundamentals and Implementation (45-50 min) - Vector embeddings and semantic search basics - Building first RAG system with Redis - Added Part 4: Context Quality Matters (preview) - **Notebook 2**: Engineering Context for Production (90-105 min) - Data engineering pipelines for context - Chunking strategies with LangChain (4 strategies) - Three engineering approaches (RAG, Structured Views, Hybrid) - Production pipeline architectures - Added Part 6: Quality Optimization ### Deleted - Old Section 2 notebook (01_engineering_retrieved_context_with_rag.ipynb) - Section 2.5 directory (merged into Section 2) ### Updated - Section 1 NB2: Updated "What's Next" to reference new Section 2 structure - README.md: Updated course overview, duration (13-18 hours), and Section 2 description - COURSE_SUMMARY.md: Updated Section 2 details and course stats - .gitignore: Added course_catalog_section2.json ### Documentation - Added SECTION_2_MERGE_ANALYSIS.md with detailed merge rationale ## Results - Before: 3 notebooks across 2 sections (Section 2 + Section 2.5) - After: 2 notebooks in 1 unified section - Clear progression: RAG Basics → Production Engineering - Zero redundancy, smooth transitions - Both notebooks fully tested and executed successfully ## Testing - ✅ Notebook 1 executed successfully (all cells pass) - ✅ Notebook 2 executed successfully (all cells pass) - ✅ All outputs verified and saved - ✅ Course navigation updated and verified
1 parent 8647c22 commit d0ffbcb

File tree

8 files changed

+3166
-758
lines changed

8 files changed

+3166
-758
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,6 @@ python-recipes/agents/02_full_featured_agent-Copy1.ipynb
239239
python-recipes/vector-search/01_redisvl-nk.ipynb
240240
python-recipes/vector-search/08_vector_algorithm_benchmark.ipynb
241241
python-recipes/vector_search.py
242+
243+
# Context engineering course - generated data files
244+
python-recipes/context-engineering/notebooks/section-2-retrieved-context-engineering/course_catalog_section2.json

python-recipes/context-engineering/COURSE_SUMMARY.md

Lines changed: 27 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## 📊 Course Overview
88

9-
**Duration**: 18-23 hours
9+
**Duration**: 13-18 hours
1010
**Format**: Self-paced, hands-on Jupyter notebooks
1111
**Level**: Intermediate to Advanced
1212
**Prerequisites**: Python, basic AI/ML understanding, familiarity with LLMs
@@ -60,26 +60,36 @@ None (pure theory and conceptual foundation)
6060

6161
---
6262

63-
### **Section 2: Retrieved Context Engineering** (3-4 hours)
63+
### **Section 2: Retrieved Context Engineering** (2.5-3 hours)
6464

65-
**Notebooks**: 1 | **Prerequisites**: Section 1
65+
**Notebooks**: 2 | **Prerequisites**: Section 1
6666

6767
#### Notebooks
68-
1. **Engineering Retrieved Context with RAG** - Vector embeddings, semantic search, course recommendations
68+
1. **RAG Fundamentals and Implementation** (45-50 min) - Vector embeddings, semantic search, building your first RAG system, context quality preview
69+
2. **Engineering Context for Production** (90-105 min) - Data engineering pipelines, chunking strategies with LangChain, production architectures, quality optimization
6970

7071
#### Learning Outcomes
7172
- ✅ Implement vector embeddings with OpenAI
7273
- ✅ Build semantic search with Redis and RedisVL
7374
- ✅ Create a course recommendation system
7475
- ✅ Understand RAG architecture patterns
7576
- ✅ Ingest and query vector data
77+
- ✅ Engineer production-ready context from raw data
78+
- ✅ Apply chunking strategies (fixed-size, recursive, semantic, custom)
79+
- ✅ Build data engineering pipelines for context
80+
- ✅ Implement three engineering approaches (RAG, Structured Views, Hybrid)
81+
- ✅ Optimize context quality for production
7682

7783
#### Key Concepts
7884
- **Vector Embeddings**: Converting text to numerical representations
7985
- **Semantic Search**: Finding similar items using vector similarity
8086
- **RAG Pattern**: Retrieval Augmented Generation
8187
- **Redis Vector Search**: Using Redis for vector storage and retrieval
8288
- **Course Catalog Management**: Storing and querying course data
89+
- **Data Engineering Pipeline**: Transform raw data → structured data → LLM-optimized context
90+
- **Chunking Strategies**: Fixed-size, Recursive Character, Semantic, Custom domain-specific
91+
- **Engineering Approaches**: RAG (semantic search), Structured Views (pre-computed), Hybrid (best of both)
92+
- **Context Quality**: Relevance, Completeness, Efficiency, Accuracy
8393

8494
#### Reference Agent Components Used
8595
- `CourseManager` - Course storage and semantic search
@@ -92,6 +102,9 @@ None (pure theory and conceptual foundation)
92102
- Semantic search with similarity scoring
93103
- Hybrid search (keyword + semantic)
94104
- Course recommendation algorithms
105+
- Batch processing pipelines for data engineering
106+
- LangChain text splitters (RecursiveCharacterTextSplitter, SemanticChunker)
107+
- Quality metrics and optimization workflows
95108

96109
---
97110

@@ -175,108 +188,6 @@ None (pure theory and conceptual foundation)
175188

176189
---
177190

178-
### **Section 5: Optimization & Production** (4-5 hours)
179-
180-
**Notebooks**: 3 | **Prerequisites**: Sections 1-4 | **Status**: ✅ Complete
181-
182-
#### Notebooks
183-
1. **Measuring and Optimizing Performance** - Token counting, cost tracking, performance metrics
184-
2. **Scaling with Semantic Tool Selection** - 🆕 **RedisVL Semantic Router & Semantic Cache**
185-
3. **Production Readiness and Quality Assurance** - Validation, monitoring, error handling
186-
187-
#### Learning Outcomes
188-
- ✅ Implement token counting and budget management
189-
- ✅ Optimize context assembly for cost reduction
190-
- ✅ 🆕 **Use RedisVL Semantic Router for production tool selection**
191-
- ✅ 🆕 **Implement Semantic Cache for 92% latency reduction**
192-
- ✅ 🆕 **Apply industry-standard semantic routing patterns**
193-
- ✅ Build production monitoring and analytics
194-
- ✅ Handle errors and edge cases gracefully
195-
- ✅ Deploy scalable AI agents
196-
- ✅ Implement advanced tool selection strategies
197-
198-
#### Key Concepts
199-
- **Token Counting**: Accurate token estimation for cost management
200-
- **Token Budgets**: Allocating context window space efficiently
201-
- **Cost Optimization**: Reducing LLM API costs
202-
- **🆕 Semantic Routing**: Production-ready tool selection with RedisVL
203-
- **🆕 Semantic Caching**: Intelligent caching for similar queries
204-
- **Performance Monitoring**: Tracking agent performance metrics
205-
- **Production Deployment**: Scaling to thousands of users
206-
- **Error Handling**: Graceful degradation and recovery
207-
208-
#### 🆕 RedisVL Extensions Used (Notebook 2)
209-
- **`SemanticRouter`**: Production-ready semantic routing for tool selection
210-
- Automatic index creation and management
211-
- Route-based tool organization
212-
- Distance threshold configuration
213-
- Serialization support (YAML/dict)
214-
- 60% code reduction vs custom implementation
215-
216-
- **`SemanticCache`**: Intelligent caching for LLM operations
217-
- Semantic similarity-based cache matching
218-
- TTL policies for cache expiration
219-
- Filterable fields for multi-tenant scenarios
220-
- 30-40% cache hit rate typical
221-
- 92% latency reduction on cache hits (5ms vs 65ms)
222-
223-
#### Reference Agent Components Used
224-
- Optimization helpers: `count_tokens`, `estimate_token_budget`, `hybrid_retrieval`
225-
- Production utilities: `create_summary_view`, `filter_tools_by_intent`
226-
- `classify_intent_with_llm` - LLM-based intent classification
227-
- `extract_references` - Reference extraction for grounding
228-
- `format_context_for_llm` - Context formatting utilities
229-
230-
#### Production Patterns Demonstrated
231-
```python
232-
# Semantic Router Pattern (Notebook 2)
233-
from redisvl.extensions.router import Route, SemanticRouter
234-
235-
# Define routes for tools
236-
route = Route(
237-
name="search_courses",
238-
references=["Find courses", "Search catalog", ...],
239-
metadata={"tool": search_tool},
240-
distance_threshold=0.3
241-
)
242-
243-
# Initialize router (handles everything automatically)
244-
router = SemanticRouter(
245-
name="tool-router",
246-
routes=[route1, route2, ...],
247-
redis_url=REDIS_URL
248-
)
249-
250-
# Select tools (one line!)
251-
matches = router.route_many(query, max_k=3)
252-
selected_tools = [m.metadata["tool"] for m in matches]
253-
254-
# Semantic Cache Pattern (Notebook 2)
255-
from redisvl.extensions.llmcache import SemanticCache
256-
257-
# Initialize cache
258-
cache = SemanticCache(
259-
name="tool_selection_cache",
260-
distance_threshold=0.1,
261-
ttl=3600
262-
)
263-
264-
# Check cache first (fast path)
265-
if cached := cache.check(prompt=query):
266-
return cached[0]["response"] # 5ms
267-
268-
# Cache miss - compute and store (slow path)
269-
result = compute_expensive_operation(query) # 65ms
270-
cache.store(prompt=query, response=result)
271-
```
272-
273-
#### Key Patterns
274-
- Token budget estimation and tracking
275-
- Hybrid retrieval (summary + targeted search)
276-
- Tool filtering by intent
277-
- Structured view creation for efficiency
278-
- Production monitoring and analytics
279-
280191
---
281192

282193
## 🎯 Complete Learning Outcomes
@@ -647,21 +558,20 @@ from redis_context_course import (
647558

648559
### Recommended Learning Path
649560

650-
#### For Beginners (3-4 weeks, 6-8 hours/week)
561+
#### For Beginners (2-3 weeks, 6-8 hours/week)
651562
1. **Week 1**: Complete Section 1 (Foundations) and Section 2 (RAG)
652563
2. **Week 2**: Work through Section 3 (Memory Systems for Context Engineering)
653564
3. **Week 3**: Build agents in Section 4 (Integrating Tools and Agents)
654-
4. **Week 4**: Optimize in Section 5 (Production)
655565

656-
#### For Experienced Developers (1-2 weeks full-time)
566+
#### For Experienced Developers (1 week full-time or 2 weeks part-time)
657567
- **Skip to Section 2** if familiar with context engineering basics
658568
- **Jump to Section 3** if you've built RAG systems before
659569
- **Start at Section 4** if you want to focus on LangGraph and agents
660570

661571
#### Time Commitment Options
662-
- **Intensive**: 1 week (full-time, 8 hours/day)
663-
- **Standard**: 3-4 weeks (part-time, 6-8 hours/week)
664-
- **Relaxed**: 6-8 weeks (casual, 3-4 hours/week)
572+
- **Intensive**: 1 week (full-time, 6-8 hours/day)
573+
- **Standard**: 2-3 weeks (part-time, 6-8 hours/week)
574+
- **Relaxed**: 4-6 weeks (casual, 3-4 hours/week)
665575

666576
### Learning Tips
667577
1. **Start with Section 1** - Build foundational understanding
@@ -805,11 +715,11 @@ After completing this course, you can:
805715
- OpenAI GPT-4
806716

807717
**Course Stats**:
808-
- **Duration**: 18-23 hours
809-
- **Sections**: 5
810-
- **Notebooks**: 12
811-
- **Hands-on Exercises**: 30+
812-
- **Production Patterns**: 15+
718+
- **Duration**: 13-18 hours
719+
- **Sections**: 4
720+
- **Notebooks**: 10
721+
- **Hands-on Exercises**: 25+
722+
- **Production Patterns**: 12+
813723

814724
---
815725

python-recipes/context-engineering/README.md

Lines changed: 23 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
## 🎓 Course Overview
3434

35-
**Duration**: 18-23 hours
35+
**Duration**: 13-18 hours
3636
**Format**: Self-paced, hands-on notebooks
3737
**Level**: Intermediate to Advanced
3838
**Prerequisites**: Python, basic AI/ML understanding, familiarity with LLMs
@@ -79,19 +79,24 @@ Learn the foundational concepts of context engineering and the four context type
7979

8080
---
8181

82-
### **Section 2: Retrieved Context Engineering** (3-4 hours)
83-
**1 notebook** | **Prerequisites**: Section 1
82+
### **Section 2: Retrieved Context Engineering** (2.5-3 hours)
83+
**2 notebooks** | **Prerequisites**: Section 1
8484

85-
Build a RAG system using Redis and RedisVL for semantic course search.
85+
Build production-ready RAG systems with Redis, from fundamentals to advanced engineering patterns.
8686

8787
**Notebooks**:
88-
1. **Engineering Retrieved Context with RAG** - Vector embeddings, semantic search, course recommendations
88+
1. **RAG Fundamentals and Implementation** (45-50 min) - Vector embeddings, semantic search, building your first RAG system
89+
2. **Engineering Context for Production** (90-105 min) - Data engineering, chunking strategies, production pipelines, quality optimization
8990

9091
**Learning Outcomes**:
9192
- Implement vector embeddings with OpenAI
9293
- Build semantic search with Redis and RedisVL
9394
- Create a course recommendation system
9495
- Understand RAG architecture patterns
96+
- Engineer production-ready context from raw data
97+
- Apply chunking strategies with LangChain
98+
- Build data engineering pipelines
99+
- Optimize context quality for production
95100

96101
**Reference Agent Components Used**:
97102
- `CourseManager` - Course storage and search
@@ -147,37 +152,6 @@ Build production agents with LangGraph, semantic tool selection, and state manag
147152

148153
---
149154

150-
### **Section 5: Optimization & Production** (4-5 hours)
151-
**3 notebooks** | **Prerequisites**: Sections 1-4 | **Status**: ✅ Complete
152-
153-
Optimize for production with token management, cost optimization, semantic routing, and caching.
154-
155-
**Notebooks**:
156-
1. **Measuring and Optimizing Performance** - Token counting, cost tracking, performance metrics
157-
2. **Scaling with Semantic Tool Selection** - 🆕 RedisVL Semantic Router & Semantic Cache
158-
3. **Production Readiness and Quality Assurance** - Validation, monitoring, error handling
159-
160-
**Learning Outcomes**:
161-
- Implement token counting and budget management
162-
- Optimize context assembly for cost reduction
163-
- 🆕 **Use RedisVL Semantic Router for production tool selection**
164-
- 🆕 **Implement Semantic Cache for 92% latency reduction**
165-
- Build production monitoring and analytics
166-
- Handle errors and edge cases gracefully
167-
- Deploy scalable AI agents
168-
169-
**🆕 New in Notebook 2**:
170-
- **RedisVL Semantic Router**: Production-ready semantic routing (60% code reduction vs custom implementation)
171-
- **RedisVL Semantic Cache**: Intelligent caching for tool selections (30-40% cache hit rate)
172-
- **Performance**: 5ms cache hits vs 65ms cache misses (10-20x faster)
173-
- **Industry Patterns**: Learn production-ready approaches, not custom implementations
174-
175-
**Reference Agent Components Used**:
176-
- Optimization helpers: `count_tokens`, `estimate_token_budget`, `hybrid_retrieval`
177-
- Production utilities: `create_summary_view`, `filter_tools_by_intent`
178-
179-
---
180-
181155
## 📁 Repository Structure
182156

183157
```
@@ -195,8 +169,7 @@ context-engineering/
195169
│ ├── section-1-context-engineering-foundations/ # Section 1 notebooks
196170
│ ├── section-2-retrieved-context-engineering/ # Section 2 notebooks
197171
│ ├── section-3-memory-systems-for-context-engineering/ # Section 3 notebooks
198-
│ ├── section-4-integrating-tools-and-agents/ # Section 4 notebooks
199-
│ └── section-5-optimization-production/ # Section 5 notebooks
172+
│ └── section-4-integrating-tools-and-agents/ # Section 4 notebooks
200173
201174
└── reference-agent/ # Production-ready reference implementation
202175
├── README.md # Reference agent documentation
@@ -452,25 +425,24 @@ docker-compose down -v
452425
## 📖 Recommended Learning Path
453426

454427
### For Beginners
455-
**Timeline**: 3-4 weeks (6-8 hours/week)
428+
**Timeline**: 2-3 weeks (6-8 hours/week)
456429

457430
1. **Week 1**: Complete Section 1 (Foundations) and Section 2 (RAG)
458431
2. **Week 2**: Work through Section 3 (Memory Systems for Context Engineering)
459432
3. **Week 3**: Build agents in Section 4 (Integrating Tools and Agents)
460-
4. **Week 4**: Optimize in Section 5 (Production)
461433

462434
### For Experienced Developers
463-
**Timeline**: 1-2 weeks (full-time) or 2-3 weeks (part-time)
435+
**Timeline**: 1 week (full-time) or 2 weeks (part-time)
464436

465437
- **Skip to Section 2** if familiar with context engineering basics
466438
- **Jump to Section 3** if you've built RAG systems before
467439
- **Start at Section 4** if you want to focus on LangGraph and agents
468440

469441
### Time Commitment Options
470442

471-
- **Intensive**: 1 week (full-time, 8 hours/day)
472-
- **Standard**: 3-4 weeks (part-time, 6-8 hours/week)
473-
- **Relaxed**: 6-8 weeks (casual, 3-4 hours/week)
443+
- **Intensive**: 1 week (full-time, 6-8 hours/day)
444+
- **Standard**: 2-3 weeks (part-time, 6-8 hours/week)
445+
- **Relaxed**: 4-6 weeks (casual, 3-4 hours/week)
474446

475447
### Learning Tips
476448

@@ -495,6 +467,8 @@ docker-compose down -v
495467
- Implement vector embeddings and semantic search
496468
- Build RAG systems with Redis and RedisVL
497469
- Create course recommendation engines
470+
- Engineer production-ready context from raw data
471+
- Apply chunking strategies and quality optimization
498472

499473
**Section 3: Memory Systems for Context Engineering**
500474
- Master dual memory systems (working + long-term)
@@ -506,11 +480,6 @@ docker-compose down -v
506480
- Implement semantic tool selection
507481
- Manage complex agent workflows
508482

509-
**Section 5: Optimization & Production**
510-
- Optimize token usage and costs
511-
- Implement production monitoring
512-
- Deploy scalable AI agents
513-
514483
### Complete Program Outcomes
515484

516485
By completing this course, you will be able to:
@@ -660,11 +629,11 @@ This is an educational resource. Contributions that improve clarity, add example
660629
- OpenAI GPT-4
661630

662631
**Course Stats**:
663-
- **Duration**: 18-23 hours
664-
- **Sections**: 5
665-
- **Notebooks**: 12
666-
- **Hands-on Exercises**: 30+
667-
- **Production Patterns**: 15+
632+
- **Duration**: 13-18 hours
633+
- **Sections**: 4
634+
- **Notebooks**: 10
635+
- **Hands-on Exercises**: 25+
636+
- **Production Patterns**: 12+
668637

669638
---
670639

0 commit comments

Comments
 (0)