實用 RAG 系統:從知識庫到檢索增強生成
這些學生講義提供了構建可用檢索增強生成(RAG)系統的系統級視角。課程涵蓋整個流程,包括資料攝取、分塊策略、嵌入映射、向量存儲、混合檢索、重排序以及可信 AI 應用的評估。
課程
Lesson
This lesson introduces Retrieval-Augmented Generation (RAG) as a solution to the limitations of static, "closed-book" LLMs by grounding model responses in dynamic, external knowledge bases. Students will learn to identify the core components of the RAG lifecycle and understand how to design effective document ingestion and retrieval pipelines to ensure factual reliability and traceability.
This lesson explores the strategic importance of data transformation in RAG systems, focusing on how chunking strategies, embedding models, and indexing algorithms impact retrieval performance. Students will learn to balance the precision-recall paradox by defining optimal retrieval units that maintain semantic coherence while managing latency and token constraints.
This lesson explores advanced retrieval optimization by contrasting the semantic strengths of dense vector search with the precision of lexical BM25 retrieval. Students will learn to implement hybrid search architectures, including Reciprocal Rank Fusion (RRF) and Cross-Encoder reranking, to effectively balance semantic intent with exact keyword matching in production RAG systems.
This lesson explores the "Demo Paradox" in Retrieval-Augmented Generation, emphasizing that system reliability depends on integrated pipelines rather than isolated metrics. Students will learn how to ensure trustworthiness through metadata persistence, traceability, and rigorous observability across all stages of the RAG architecture.
This lesson explores the transition from RAG prototypes to production-ready systems by emphasizing architectural reliability, statistical verification, and the importance of handling real-world data entropy. Students will learn to implement observability through full-trace telemetry and design robust pipelines that prioritize system stability and predictable, evidence-based outputs over anecdotal success.
課程總覽
📚 內容摘要
這些學生講義提供了建立可用的檢索增強生成(RAG)系統的系統級視角。課程涵蓋了整個流程,包括資料攝取、切塊策略、嵌入映射、向量儲存、混合檢索、重排序以及用於值得信賴的人工智慧應用的評估。
透過全面的 RAG 流程方法,掌握打造基於證據的人工智慧系統的藝術。
作者: EvoClass
致謝: EvoClass 團隊
🎯 學習目標
- 区分提示(prompting)、微調(fine-tuning)與 RAG,以根據特定業務需求選擇正確工具。
- 描繪資訊在 RAG 流程中的傳遞路徑,從使用者查詢到有根據的生成。
- 設計專業的資料攝取流程,整合元資料、標準化與版本控制,防止「弱資料」失敗。
- 評估並實踐 基於特定領域需求的多樣切塊策略(固定長度、結構感知、層次式)。
- 解釋嵌入技術的機制,並區分語意相似性與答案實用性的差異。
- 描述向量儲存與索引的技術理論,聚焦於檢索速度(延遲)與準確性之間的權衡。
- 為大型語料庫(10萬+ 條塊)設計多階段檢索計畫,包含元資料與過濾策略。
- 区分檢索(召回率)與重排序(精確度/相關性)的目標差異。
- 分析為何重排序對有效的大語言模型生成至關重要,以及其如何與切塊設計互動。
- 設計上游元資料結構,支援自動引用與版本感知的檢索。
課程
概述: 本課建立從大語言模型(LLM)作為獨立生成引擎,轉變為利用外部知識的穩固系統的過渡。學生將學習檢索增強生成(RAG)的架構流程,理解資料治理是模型品質的支柱,並發現如何設計一個透過元資料與版本控制確保事實可靠性的攝取流程。
學習成果:
- 区分提示(prompting)、微調(fine-tuning)與 RAG,以根據特定業務需求選擇正確工具。
- 描繪資訊在 RAG 流程中的傳遞路徑,從使用者查詢到有根據的生成。
- 設計專業的資料攝取流程,整合元資料、標準化與版本控制,防止「弱資料」失敗。
概述: 本課探討從原始文字轉換為 RAG 流程中可搜尋資料結構的關鍵轉折。內容涵蓋透過不同切塊方法戰略性選擇「檢索單元」、使用嵌入實現意義的數學表示,以及使高維度搜尋在大規模下高效運作所需的技術基礎設施。
學習成果:
- 評估並實踐 基於特定領域需求的多樣切塊策略(固定長度、結構感知、層次式)。
- 解釋嵌入技術的機制,並區分語意相似性與答案實用性的差異。
- 描述向量儲存與索引的技術理論,聚焦於檢索速度(延遲)與準確性之間的權衡。
概述: 本課探討從基本向量搜尋過渡到生產級檢索架構的過程。重點在於混合搜尋——結合詞法與語意檢索——以及兩階段檢索流程,其中重排序器被用來確保最具「答案承載力」的證據能傳遞給大語言模型。學生將學習如何為大型語料庫設計檢索計畫,並理解排名品質與生成準確性之間的關鍵互動。
學習成果:
- 為大型語料庫(10萬+ 條塊)設計多階段檢索計畫,包含元資料與過濾策略。
- 区分檢索(召回率)與重排序(精確度/相關性)的目標差異。
- 分析為何重排序對有效的大語言模型生成至關重要,以及其如何與切塊設計互動。
概述: 本課聚焦於從「看似合理」的原型過渡到值得信賴、可投入生產的 RAG 應用。內容探討元資料設計如何實現可靠的引用與時間準確性(即時性),並提供多層面的評估框架,用以評估檢索與生成階段,避免僅靠誘人的示範誤導。
學習成果:
- 設計上游元資料結構,支援自動引用與版本感知的檢索。
- 實踐即時性策略,在文件新鮮度與權威性之間取得平衡。
- 建構完整的基準測試集,並執行診斷錯誤分析,以識別特定流程失效點。
概述: 本課從理論上的 RAG 模組過渡到實際打造可投入生產應用的現實挑戰。重點在於將各個階段整合成一個連貫的端到端架構,成功定義為可觀測性、有效的故障處理,以及對系統內在權衡的謹慎管理。學生將學習到,一個可用的系統應優先考慮證據可追溯性與平滑行為,而非複雜性。
學習成果:
- 描繪 一個實務上 9 階段的端到端 RAG 系統架構。
- 辨識 並評估性能、準確性與成本之間的關鍵權衡。
- 診斷 流程失敗,透過追蹤錯誤回歸到具體的架構階段。