🔍 RAG & Fine-tuning | RAG与微调¶
🎯 Learning Objective | 学习目标:Learn to make AI use your private data to create a personalized AI assistant | 学会让AI使用你的私有数据,打造专属AI助手
🌟 Why Do We Need RAG and Fine-tuning? | 为什么需要RAG和微调?¶
An AI large model is like a smart graduate: AI大模型就像一个聪明的毕业生:
- 📚 Knowledgeable | 知识渊博 - But doesn't know your company's internal docs | 但不知道你公司的内部文档
- 🧠 Powerful | 能力强大 - But unfamiliar with your professional domain | 但不了解你的专业领域
- 💬 Good communicator | 善于交流 - But might give outdated information | 但可能给出过时信息
RAG and Fine-tuning are two methods to make AI "understand you"! RAG 和 微调 就是让AI"了解你"的两种方法!
🎯 RAG vs Fine-tuning | RAG对比微调¶
| Comparison | RAG (Open-book Exam) | Fine-tuning (Professional Training) |
|---|---|---|
| 对比项 | RAG(开卷考试) | 微调(专业培训) |
| 🎯 Principle | Provide reference materials to AI | Retrain the AI |
| 🎯 原理 | 给AI提供参考资料 | 重新训练AI |
| ⏱️ Speed | Fast deployment | Requires training time |
| ⏱️ 速度 | 快速部署 | 需要训练时间 |
| 💰 Cost | Low cost | Higher cost |
| 💰 成本 | 低成本 | 较高成本 |
| 🔄 Updates | Real-time updates | Requires retraining |
| 🔄 更新 | 实时更新 | 需要重新训练 |
| 📊 Use Cases | Knowledge Q&A | Style/capability changes |
| 📊 适用 | 知识问答 | 风格/能力改变 |
📚 Chapter Contents | 本章内容¶
1️⃣ RAG Fundamentals | RAG基础¶
Introduction to Retrieval-Augmented Generation: 检索增强生成的入门:
- 📖 What is RAG | RAG是什么 - The open-book exam analogy | 开卷考试的比喻
- 🔍 How it works | 工作原理 - Retrieve → Augment → Generate | 检索→增强→生成
- 🛠️ Basic implementation | 基础实现 - Build a simple RAG hands-on | 动手搭建简单RAG
2️⃣ Advanced RAG Techniques | 高级RAG技术¶
Making RAG more powerful: 让RAG更强大:
- 🎯 Retrieval optimization | 检索优化 - Find the most relevant content | 找到最相关的内容
- 📊 Reranking | 重排序 - Improve answer quality | 提高答案质量
- 🔄 Hybrid retrieval | 混合检索 - Combine multiple methods | 结合多种方法
3️⃣ Fine-tuning Guide | 微调指南¶
Train your own AI: 训练你的专属AI:
- 📝 Data preparation | 数据准备 - Prepare training data | 准备训练数据
- ⚙️ LoRA technique | LoRA技术 - Low-cost fine-tuning | 低成本微调
- 🎓 Hands-on tutorial | 实战教程 - Step-by-step guide | 手把手教学
🎮 RAG Workflow Diagram | RAG工作流程图¶
User Question → 🔍 Vector Retrieval → 📄 Find Relevant Docs → 🤖 AI Generates Answer
用户问题 → 向量检索 → 找到相关文档 → AI生成答案
│ │
└───── Answer contains accurate private knowledge ─────┘
答案包含准确的私有知识
💡 Scenario Selection Guide | 场景选择指南¶
Choose RAG when: | 选择 RAG 的场景:¶
- ✅ Need to access latest documents | 需要访问最新文档
- ✅ Data updates frequently | 数据经常更新
- ✅ Want answers with source citations | 希望答案有来源引用
- ✅ Need rapid deployment | 快速部署需求
Choose Fine-tuning when: | 选择微调的场景:¶
- ✅ Need specific output style | 需要特定的输出风格
- ✅ Domain-specific terminology understanding | 专业领域的术语理解
- ✅ Capability improvement for specific tasks | 特定任务的能力提升
- ✅ Data is relatively stable | 数据相对稳定
⏱️ Estimated Study Time | 预计学习时间¶
- RAG Fundamentals | RAG基础:3-4 hours | 小时
- Advanced RAG | 高级RAG:3-4 hours | 小时
- Fine-tuning Guide | 微调指南:4-5 hours | 小时
Total | 总计:About 10-13 hours | 约 10-13 小时
💡 Pro Tip | 小贴士:We recommend learning RAG first - it's simpler and more practical! Fine-tuning is an advanced skill that you can learn later.
建议先学RAG,它更简单实用!微调是进阶技能,可以之后再学。