把 RAG 六部曲濃縮成一張全景圖:左邊「建索引」做一次,右邊「提問」每次跑一遍,中間靠向量庫接起來;對外只露一個 rag_search,要更聰明就在檢索上面加一顆會迭代的控制器。這頁把整套系統拆給你看,也對應到系列六集。
flowchart LR CLIENT(["🤖 Agent / 聊天前端
/ 別的系統"]):::result MCP["🔌 MCP 介面
只開一個 rag_search"]:::data subgraph BUILD["🏗️ BUILD · 建索引(做一次)"] direction TB DOC[("原始文件
手冊 · SOP")]:::infra OCR["OCR
掃描檔轉文字"]:::proc CH["切塊 + embedding"]:::proc DOC -->|數位文字| CH DOC -.掃描檔.-> OCR --> CH end VDB[("🗄️ 向量庫
片段 · 向量 · metadata")]:::data AUTH["access_grants
誰能看哪本"]:::data subgraph SERVE["🔎 SERVE · 每次提問"] direction TB CTL{"控制器
agentic 才有"}:::decision RET["檢索 R + 組裝 A"]:::proc GEN["生成 G · 標出處"]:::proc CTL -->|決定查什麼| RET RET -.不夠再查一輪.-> CTL RET --> GEN end ANS(["✅ 有據答案
+ 出處"]):::result CLIENT --> MCP --> CTL CH --> VDB AUTH -.授權過濾.-> VDB RET <-->|語意檢索 top-k| VDB GEN --> ANS classDef proc fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#17335e classDef data fill:#fef3c7,stroke:#d97706,stroke-width:2px,color:#78350f classDef result fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d classDef infra fill:#e5e9f0,stroke:#475569,stroke-width:2px,color:#1e293b classDef decision fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#4c1d95 style BUILD fill:#f8fafc,stroke:#cbd5e1,color:#475569 style SERVE fill:#eff6ff,stroke:#93c5fd,color:#1e40af
一句話讀圖:BUILD 只做一次(文件切塊算向量存進庫),SERVE 每次提問跑一遍(檢索 → 生成)。控制器是選配 —— 加上它、讓它「不夠就再查一輪」,一般 RAG 就升級成 Agentic。對外永遠只露一個 rag_search。
| 圖上的部分 | 在講什麼 | 對應這一集 |
|---|---|---|
| 切塊 + embedding、OCR | 怎麼把文件變成可檢索的向量 | ① 一般 RAG 怎麼做 · ② 選模型 + 怎麼切 |
| 向量庫 · metadata · access_grants | BUILD/SERVE 分開、授權跟向量解耦 | ③ 一套 RAG 的系統架構 |
MCP 介面(rag_search) | 包成服務,對外只開一個工具 | ④ 最小服務 + 包成 MCP |
| 控制器(agentic 迭代) | 多一顆會決策的腦,反覆查到夠 | ⑤ 升級成 Agentic RAG |
| 「只開一個工具」的克制 | 工具太多 agent 反而變笨、怎麼收 | ⑥ 工具太多,agent 反而變笨 |
📺 對應系列:做 · 切塊選模型 · 系統架構 · 服務+MCP · 升級 Agentic · 工具太多怎麼收 | 📚 回課綱總表 →