Skip to content

Commit 96bf0f5

Browse files
committed
Reword some content
1 parent 0271fad commit 96bf0f5

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

python-recipes/context-engineering/notebooks/section-2-retrieved-context-engineering/02_crafting_and_optimizing_context.ipynb

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"\n",
1010
"# Crafting and Optimizing Context\n",
1111
"\n",
12-
"## From RAG Basics to Production-Ready Context Engineering\n",
12+
"## From RAG Basics to Practical Context Engineering\n",
1313
"\n",
14-
"In the previous notebook, you built a working RAG system and saw why context quality matters. Now you'll learn to engineer context with production-level rigor.\n",
14+
"In the previous notebook, you built a working RAG system and saw why context quality matters. Now you'll learn to engineer context with professional-level rigor.\n",
1515
"\n",
1616
"**What makes context \"good\"?**\n",
1717
"\n",
@@ -34,10 +34,10 @@
3434
"- Different chunking strategies and their trade-offs\n",
3535
"- How to choose based on YOUR data characteristics\n",
3636
"\n",
37-
"**Production Pipelines:**\n",
37+
"**Context Preparation Pipelines:**\n",
3838
"- Three pipeline architectures (Request-Time, Batch, Event-Driven)\n",
3939
"- How to choose based on YOUR constraints\n",
40-
"- Building production-ready context preparation workflows\n",
40+
"- Building reusable context preparation workflows\n",
4141
"\n",
4242
"**Time to complete:** 90-105 minutes\n",
4343
"\n",
@@ -540,10 +540,10 @@
540540
"\n",
541541
"| Approach | Description | Token Usage | Response Quality | Maintenance | Verdict |\n",
542542
"|----------|-------------|-------------|------------------|-------------|---------|\n",
543-
"| **Naive** | Include all raw data | 50K tokens | Poor (generic) | Easy | ❌ Not production-ready |\n",
543+
"| **Naive** | Include all raw data | 50K tokens | Poor (generic) | Easy | ❌ Not practical |\n",
544544
"| **RAG** | Semantic search for relevant courses | 3K tokens | Good (relevant) | Moderate | ✅ Good for most cases |\n",
545-
"| **Structured Views** | Pre-compute LLM-optimized summaries | 2K tokens | Excellent (overview + details) | Higher | ✅ Best for production |\n",
546-
"| **Hybrid** | Structured view + RAG | 5K tokens | Excellent (best of both) | Higher | ✅ Best for production |\n",
545+
"| **Structured Views** | Pre-compute LLM-optimized summaries | 2K tokens | Excellent (overview + details) | Higher | ✅ Best for real-world use |\n",
546+
"| **Hybrid** | Structured view + RAG | 5K tokens | Excellent (best of both) | Higher | ✅ Best for real-world use |\n",
547547
"\n",
548548
"Let's implement each approach and compare them."
549549
]
@@ -984,7 +984,7 @@
984984
"**Option 3: Hybrid**\n",
985985
"- Combine both approaches\n",
986986
"- Pre-compute catalog view + RAG for details\n",
987-
"- Good for: Production systems\n",
987+
"- Good for: Real-world systems\n",
988988
"\n",
989989
"Let's implement all three and compare."
990990
]
@@ -1646,7 +1646,7 @@
16461646
"| **Response Quality** | ✅ Good (relevant) | ✅ Good (overview) | ✅✅ Excellent (both) |\n",
16471647
"| **Latency** | ⚠️ Moderate (search) | ✅✅ Fast (cached) | ⚠️ Moderate (search) |\n",
16481648
"| **Maintenance** | ✅ Low (auto-updates) | ⚠️ Higher (rebuild views) | ⚠️ Higher (both) |\n",
1649-
"| **Best For** | Specific queries | Overview queries | Production systems |\n",
1649+
"| **Best For** | Specific queries | Overview queries | Real-world systems |\n",
16501650
"\n",
16511651
"**Decision Process:**\n",
16521652
"\n",
@@ -1890,7 +1890,7 @@
18901890
"\n",
18911891
"Table 1 shows the performance comparison across different HNSW configurations. As M increases from 16 to 64,\n",
18921892
"we observe significant improvements in recall (0.89 to 0.97) but at the cost of increased latency (2.1ms to 8.7ms)\n",
1893-
"and memory usage (1.2GB to 3.8GB). The sweet spot for most production workloads is M=32 with ef_construction=200,\n",
1893+
"and memory usage (1.2GB to 3.8GB). The sweet spot for most real-world workloads is M=32 with ef_construction=200,\n",
18941894
"which achieves 0.94 recall with 4.3ms latency.\n",
18951895
"\n",
18961896
"Table 1: HNSW Performance Comparison\n",
@@ -1921,7 +1921,7 @@
19211921
"\n",
19221922
"## 4. Implementation Recommendations\n",
19231923
"\n",
1924-
"Based on our findings, we recommend the following configuration for production deployments:\n",
1924+
"Based on our findings, we recommend the following configuration for real-world deployments:\n",
19251925
"\n",
19261926
"```python\n",
19271927
"# Optimal HNSW configuration for balanced performance\n",
@@ -2025,7 +2025,7 @@
20252025
"```\n",
20262026
"\n",
20272027
"**Best practice:** Chunk code WITH its context and rationale\n",
2028-
"- ✅ \"For production deployment, we recommend M=32 and ef_construction=200 because...\"\n",
2028+
"- ✅ \"For real-world deployment, we recommend M=32 and ef_construction=200 because...\"\n",
20292029
"- ❌ Don't chunk code without explaining WHY these values\n",
20302030
"\n",
20312031
"**3. Query-Specific Retrieval Patterns**\n",
@@ -2067,12 +2067,12 @@
20672067
"\n",
20682068
"There's no single \"best\" chunking strategy - the optimal approach depends on YOUR data characteristics and query patterns. Let's explore different strategies and their trade-offs.\n",
20692069
"\n",
2070-
"**🔧 Using LangChain for Production-Ready Chunking**\n",
2070+
"**🔧 Using LangChain for Professional-Grade Chunking**\n",
20712071
"\n",
2072-
"In this section, we'll use **LangChain's text splitting utilities** for Strategies 2 and 3. LangChain provides battle-tested, production-ready implementations that handle edge cases and optimize for LLM consumption.\n",
2072+
"In this section, we'll use **LangChain's text splitting utilities** for Strategies 2 and 3. LangChain provides battle-tested, robust implementations that handle edge cases and optimize for LLM consumption.\n",
20732073
"\n",
20742074
"**Why LangChain?**\n",
2075-
"- **Industry-standard**: Used by thousands of production applications\n",
2075+
"- **Industry-standard**: Used by thousands of real-world applications\n",
20762076
"- **Smart boundary detection**: Respects natural text boundaries (paragraphs, sentences, words)\n",
20772077
"- **Local embeddings**: Free semantic chunking with HuggingFace models (no API costs)\n",
20782078
"- **Well-tested**: Handles edge cases (empty chunks, unicode, special characters)\n",
@@ -2917,13 +2917,13 @@
29172917
"source": [
29182918
"---\n",
29192919
"\n",
2920-
"## Part 5: Building Production-Ready Context Pipelines\n",
2920+
"## Part 5: Building Practical Context Pipelines\n",
29212921
"\n",
2922-
"Now that you understand data transformation and chunking, let's discuss how to build production-ready pipelines.\n",
2922+
"Now that you understand data transformation and chunking, let's discuss how to build reusable pipelines.\n",
29232923
"\n",
29242924
"### Three Pipeline Architectures\n",
29252925
"\n",
2926-
"There are three main approaches to context preparation in production:\n",
2926+
"There are three main approaches to context preparation in real-world applications:\n",
29272927
"\n",
29282928
"### Architecture 1: Request-Time Processing\n",
29292929
"\n",
@@ -3295,15 +3295,15 @@
32953295
"**3. Three Engineering Approaches**\n",
32963296
"- **RAG:** Semantic search for relevant data (good for specific queries)\n",
32973297
"- **Structured Views:** Pre-computed summaries (excellent for overviews)\n",
3298-
"- **Hybrid:** Combine both (best for production)\n",
3298+
"- **Hybrid:** Combine both (best for real-world use)\n",
32993299
"\n",
33003300
"**4. Chunking is an Engineering Decision**\n",
33013301
"- **Don't chunk** if data is already small and complete (< 500 tokens)\n",
33023302
"- **Do chunk** if documents are long (> 1000 tokens) or multi-topic\n",
33033303
"- Four strategies: Document-Based, Fixed-Size, Semantic, Hierarchical\n",
33043304
"- Choose based on YOUR data characteristics, query patterns, and constraints\n",
33053305
"\n",
3306-
"**5. Production Pipeline Architectures**\n",
3306+
"**5. Context Pipeline Architectures**\n",
33073307
"- **Request-Time:** Process on-the-fly (simple, always fresh, higher latency)\n",
33083308
"- **Batch:** Pre-process in batches (fast queries, can be stale)\n",
33093309
"- **Event-Driven:** Process on changes (real-time, complex infrastructure)\n",
@@ -3332,7 +3332,7 @@
33323332
"\n",
33333333
"### The Systematic Optimization Process\n",
33343334
"\n",
3335-
"Now that you understand data engineering and production pipelines, let's learn how to systematically optimize context quality.\n",
3335+
"Now that you understand data engineering and context pipelines, let's learn how to systematically optimize context quality.\n",
33363336
"\n",
33373337
"**The Process:**\n",
33383338
"```\n",
@@ -3821,7 +3821,7 @@
38213821
"1. **Define Domain-Specific Metrics** - Don't rely on generic benchmarks\n",
38223822
"2. **Measure Systematically** - Baseline → Experiment → Measure → Iterate\n",
38233823
"3. **Balance Trade-offs** - Relevance vs. Efficiency, Completeness vs. Token Budget\n",
3824-
"4. **Test Before Production** - Validate with real queries from your domain\n",
3824+
"4. **Test Before Deployment** - Validate with real queries from your domain\n",
38253825
"5. **Iterate Continuously** - Quality optimization is ongoing, not one-time\n",
38263826
"\n",
38273827
"**The Engineering Mindset:**\n",
@@ -3840,11 +3840,11 @@
38403840
"source": [
38413841
"## 📝 Summary\n",
38423842
"\n",
3843-
"You've mastered production-ready context engineering:\n",
3843+
"You've mastered practical context engineering:\n",
38443844
"\n",
38453845
"**Part 1: The Engineering Mindset**\n",
38463846
"- ✅ Context is data requiring engineering discipline\n",
3847-
"- ✅ Naive approaches fail in production\n",
3847+
"- ✅ Naive approaches fail in real-world applications\n",
38483848
"- ✅ Engineering mindset: Requirements → Transformation → Quality → Testing\n",
38493849
"\n",
38503850
"**Part 2: Data Engineering Pipeline**\n",
@@ -3863,7 +3863,7 @@
38633863
"- ✅ Four strategies with LangChain integration\n",
38643864
"- ✅ Trade-offs and decision criteria\n",
38653865
"\n",
3866-
"**Part 5: Production Pipeline Architectures**\n",
3866+
"**Part 5: Context Pipeline Architectures**\n",
38673867
"- ✅ Request-Time, Batch, Event-Driven\n",
38683868
"- ✅ Batch processing example with data\n",
38693869
"- ✅ Decision framework for architecture selection\n",
@@ -3873,7 +3873,7 @@
38733873
"- ✅ Systematic optimization process\n",
38743874
"- ✅ Baseline → Experiment → Measure → Iterate\n",
38753875
"\n",
3876-
"**You're now ready to engineer production-ready context for any domain!** 🎉\n",
3876+
"**You're now ready to engineer practical context for any domain!** 🎉\n",
38773877
"\n",
38783878
"---"
38793879
]
@@ -3899,7 +3899,7 @@
38993899
"- **Tool Calling:** Let the AI use functions (search, enroll, check prerequisites)\n",
39003900
"- **LangGraph State Management:** Orchestrate complex multi-step workflows\n",
39013901
"- **Agent Reasoning:** Plan and execute multi-step tasks\n",
3902-
"- **Production Patterns:** Error handling, retries, and monitoring\n",
3902+
"- **Practical Patterns:** Error handling, retries, and monitoring\n",
39033903
"\n",
39043904
"```\n",
39053905
"Section 1: Context Engineering Fundamentals\n",

0 commit comments

Comments
 (0)