6500: MLOps Pipelines for RAG¶
Module Overview¶
This module covers MLOps practices specifically for RAG systems, including lifecycle management, CI/CD, and model registries. You'll learn to build production-ready ML pipelines for retrieval-augmented generation.
Why This Matters:
- RAG systems require continuous updates and monitoring
- CI/CD ensures reliable model deployments
- Model registries track model versions and lineage
- Production ML needs automation and reproducibility
Learning Objectives¶
After completing this module, you will be able to:
- ML Lifecycle: Manage the complete ML pipeline for RAG
- CI/CD for ML: Build automated testing and deployment
- Model Registry: Track and version models effectively
- Re-Embedding Policy: Separate churn upserts from forced full re-embeds and size the experiments that ship them
- Response Caching and Stage Scaling: Cache at the response boundary and scale each stage on its own signal
- Monitoring: Track model performance and data drift
- Production ML: Deploy and maintain RAG systems
Module Contents¶
6501: ML Lifecycle Management¶
End-to-End ML Pipeline
- The complete ML lifecycle for RAG
- The five lifecycle stages in depth
- How data, training, and deployment connect
- Monitoring and feedback across stages
- The stage-by-stage checklist
Experiments:
- Build ML pipeline for RAG
- Implement data versioning
- Set up model evaluation
- Deploy and monitor system
6502: CI/CD for ML¶
Continuous Integration and Deployment
- CI/CD architecture for ML
- Pipeline configuration
- Job dependencies
- Automated training
- Validation gates and deployment
Experiments:
- Set up GitHub Actions for ML
- Implement automated testing
- Build deployment pipeline
- Test rollback procedures
6503: Model Registry¶
Model Versioning and Governance
- Model registry architecture
- Model versioning
- Metadata and lineage
- Aliases and promotion workflows
- Registries in practice: MLflow and Weights & Biases
Experiments:
- Set up MLflow model registry
- Track model versions
- Implement model promotion
- Build model governance
6504: Re-Embedding Policy and A/B Testing¶
Updating Embeddings and Shipping Them Honestly
- The churn ledger: incremental upserts vs calendar-cadence rebuilds
- Cross-space incomparability: why a model change forces the full pass
- The shadow window: dual-write economics and the cutover gate
- Sizing on discordant pairs, the peeking trap, and fixed horizons
- Human evaluation with chance-corrected kappa
Experiments:
- Price a re-embedding cadence for your own corpus churn
- Run the shadow-window gate on a golden set
- Size an embedder migration before opening the window
6505: Response Caching and Stage Scaling¶
The Fleet-Level Bill: What Not to Recompute, What to Provision
- The four cache tiers: retrieval-only, raw-key, normalized-key, semantic
- The threshold that cuts both ways: false hits vs forfeited paraphrases
- Invalidation: query-only vs TTL vs version-keyed after the re-embedding cutover
- Per-stage autoscaling: two shortfalls, two signals, two step sizes
- The prefill/decode split and the production disaggregators
- One fleet day priced: token bill, search bill, replica bill
Experiments:
- Key a response cache on (query, index_version) and re-run the cutover
- Tune a semantic threshold on both error types with near-topic negatives
- Price per-stage autoscaling against peak provisioning on your own traffic curve
Prerequisites¶
Before starting this module, ensure you have:
- Module 1400: LLMOps and Model Serving (MLOps fundamentals)
- Module 2400: LLM Pretraining (ML pipelines)
- Modules 6100โ6400: RAG components (vector โ database)
- Git and CI/CD fundamentals
- Docker and deployment basics
Review: PREREQUISITES.md for detailed requirements.
Assessment¶
Quiz¶
- Format: 20 multiple-choice questions
- Passing Score: 80% (16/20)
- Topics: ML lifecycle, CI/CD, model registry
- Location: 6500: MLOps Pipelines for RAG - Quiz
Practice Exercises¶
- Format: MLOps pipeline projects
- Duration: 3 hours
- Topics:
- Build complete ML pipeline
- Set up CI/CD for RAG
- Implement model registry
- Deploy to production
- Location: 6500: MLOps Pipelines for RAG - Practice
Related Modules¶
This module connects to:
- 1400: LLMOps and Model Serving (MLOps fundamentals)
- 2400: LLM Pretraining (training pipelines)
- 6400: Vector Databases (data infrastructure)
- 7300: Multi-Agent Orchestration (agent workflows)
Time Commitment¶
| Activity | Time |
|---|---|
| 6501: ML Lifecycle Management | 4 hours |
| 6502: CI/CD for ML | 4 hours |
| 6503: Model Registry | 4 hours |
| 6504: Re-Embedding Policy and A/B Testing | 3 hours |
| 6505: Response Caching and Stage Scaling | 3 hours |
| Quiz | 30 minutes |
| Practice | 3 hours |
| Total | 21.5 hours |
Resources¶
Essential Tools:
- MLflow (experiment tracking and registry)
- GitHub Actions (CI/CD)
- Docker / Kubernetes (deployment)
- Weights & Biases (experiment tracking)
- DVC (data versioning)
Essential Concepts:
- Feature stores
- Model serving
- A/B testing
- Canary deployments
- Blue-green deployments
ML Pipeline Stages¶
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ML Lifecycle โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 1. Data Collection โ
โ โ โ
โ 2. Data Processing & Feature Engineering โ
โ โ โ
โ 3. Model Training โ
โ โ โ
โ 4. Model Evaluation โ
โ โ โ
โ 5. Model Registry โ
โ โ โ
โ 6. Deployment (Staging) โ
โ โ โ
โ 7. Testing & Validation โ
โ โ โ
โ 8. Production Deployment โ
โ โ โ
โ 9. Monitoring & Logging โ
โ โ โ
โ 10. Feedback & Retraining โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
CI/CD Pipeline Comparison¶
| Stage | Traditional Software | ML Pipelines |
|---|---|---|
| Code | Unit tests | Unit + model tests |
| Build | Compile | Train model |
| Test | Integration tests | Evaluation on test set |
| Deploy | Push to prod | A/B test, canary |
| Monitor | Error rates | Accuracy, drift |
Model Registry Features¶
| Feature | MLflow | Weights & Biases | DVC |
|---|---|---|---|
| Version Control | โญโญโญโญโญ | โญโญโญโญ | โญโญโญ |
| Metadata | โญโญโญโญ | โญโญโญโญโญ | โญโญโญ |
| Deployment | โญโญโญโญโญ | โญโญโญ | โญโญ |
| Lineage | โญโญโญโญ | โญโญโญโญ | โญโญโญโญโญ |
| Open Source | โ | โ | โ |
Deployment Strategies¶
| Strategy | Risk | Speed | Use Case |
|---|---|---|---|
| Big Bang | High | Fast | Small changes |
| Blue-Green | Low | Medium | Major updates |
| Canary | Medium | Slow | Critical systems |
| A/B Testing | Low | Slow | Feature validation |
Monitoring Metrics¶
| Category | Metrics |
|---|---|
| System | Latency, throughput, error rate |
| Model | Accuracy, F1, perplexity |
| Data | Drift, distribution changes |
| Business | User satisfaction, conversion |
Tips for Success¶
- Start simple: Basic CI/CD before complex MLops
- Version everything: Data, models, code, configs
- Automate testing: Catch issues before production
- Monitor continuously: Catch degradation early
- Document decisions: Reproducibility is key
Common Pitfalls¶
- Skipping staging: Testing in prod is dangerous
- No rollback plan: deployments fail
- Ignoring data drift: Models degrade over time
- Poor documentation: Can't reproduce results
- Over-engineering: Start simple, scale when needed
Production Checklist¶
Before deploying to production:
- Automated tests passing
- Model evaluated on test set
- Performance benchmarks met
- Rollback plan documented
- Monitoring configured
- Alerts set up
- Documentation complete
- Stakeholders notified
Model Promotion Workflow¶
Development โ Staging โ Production
โ โ โ
Experimental A/B Test Full Traffic
โ โ โ
Archived Rollback Monitor
MLflow vs W&B vs DVC¶
| Feature | MLflow | W&B | DVC |
|---|---|---|---|
| Experiment Tracking | โญโญโญโญโญ | โญโญโญโญโญ | โญโญโญ |
| Model Registry | โญโญโญโญโญ | โญโญโญ | โญโญ |
| Data Versioning | โญโญ | โญโญ | โญโญโญโญโญ |
| Collaboration | โญโญโญ | โญโญโญโญโญ | โญโญโญ |
| Ease of Use | โญโญโญโญ | โญโญโญโญโญ | โญโญโญ |
Next Module: 7100: Agent Architecture
Previous Module: 6400: Vector Databases
Questions? Review the PREREQUISITES.md or check Phase 6 documentation.