可靠 LLM 應用的進階 RAG 與 GraphRAG 技術¶
文章資訊
作者:QuarkAndCode 日期:2026-06-12
原文標題:Advanced RAG & GraphRAG Techniques for Reliable LLM Apps
Medium 原連結:https://medium.com/@QuarkAndCode/advanced-rag-graphrag-techniques-for-reliable-llm-apps-ccb2b9cda084
📝 重點摘要¶
TL;DR¶
當問題涉及「關聯」而非「相似」時,圖檢索能補足向量 RAG 的結構性缺陷。
核心問題¶
基礎 RAG 在 demo 階段容易,但要做出可靠產品很難。隨資料量增長,失敗模式從「漏資訊」轉變為「綜合錯誤」(把正確片段拼成錯誤答案),且難以除錯。文章探討如何用進階檢索與 GraphRAG 解決多跳推理與跨文件查詢問題。
關鍵發現 / 數據¶
- NVIDIA 基於 G-Retriever 的生醫 QA:Baseline Hits@1 為 15.57,圖管線提升至 32.09(超過兩倍)。
- 推論時間中位數:Cypher ~0.069s、PCST ~0.166s、GNN+LLM ~0.497s。
- 現行 GraphRAG benchmark 限制在 ≤4 跳問題,且假設答案為節點而非子圖。
- 向量檢索擅長「相似」,圖檢索擅長「連結」——關係型問題(為什麼、如何依賴)是結構問題。
方法亮點¶
- 混合檢索:語意嵌入 + 詞彙比對(BM25/SPLADE),用 RRF 融合排名,兼顧稀有 ID 與語意。
- GraphRAG 檢索:以 PCST(Prize-Collecting Steiner Tree)選取相關子圖,並在 LLM 微調中加入 GNN 層聚焦檢索脈絡。
- 可靠性迴圈:CRAG(生成前檢查證據是否充分)與 LLM-as-judge 校驗答案是否忠於上下文。
- Parent retriever / 上下文蒸餾:小 chunk 精準檢索、回傳大區塊保留語意,並做 query-focused 摘要。
對我的研究有用嗎?¶
值得參考的概念:將圖視為橫跨整條管線(KB 建構、檢索/提示、工作流、圖任務)的工具箱,而非單一「KG 走訪」技巧(引 arXiv 2504.10499 survey)。G-Retriever + PCST + GNN 的子圖選取與神經整合,對 LLM Graph 研究有具體可借鏡的架構。local traversal 與 global community summary 的雙模式檢索、以及可解釋/可除錯(顯示節點與路徑)也呼應 explainable GraphRAG 方向。
評語¶
偏入門綜述、二手引用為主(彙整 Neo4j/Redis/NVIDIA 等部落格),無原創實驗;數據可信但 benchmark 限制需留意。適合建立全貌與術語地圖,研究深度不足,不必細讀。
🌐 中英對照¶
Author: QuarkAndCode
作者:QuarkAndCodePublished:
發布日期:Source: https://medium.com/@QuarkAndCode/advanced-rag-graphrag-techniques-for-reliable-llm-apps-ccb2b9cda084
來源:https://medium.com/@QuarkAndCode/advanced-rag-graphrag-techniques-for-reliable-llm-apps-ccb2b9cda084Fetched: 2026-06-12T23:49:46.495677
擷取時間:2026-06-12T23:49:46.495677
Advanced RAG & GraphRAG Techniques for Reliable LLM Apps / 用於可靠 LLM 應用的進階 RAG 與 GraphRAG 技術¶
Press enter or click to view image in full size
按下 Enter 或點擊以檢視完整尺寸圖片

Imagine you ask an AI assistant a question about your company's policies:
想像一下,你向一個 AI 助理詢問關於公司政策的問題:
"Which enterprise customers renewed last quarter and also opened support tickets about SSO?"
「哪些企業客戶在上一季續約,而且還針對 SSO(單一登入,Single Sign-On)開過支援工單?」
A basic chatbot might sound confident, but it could give you only part of the list, miss important accounts, or confuse customers with similar names. This isn't just a case of the model making things up. Often, the problem is with the retrieval step: the system pulls pieces that seem relevant on their own but don't fit together into a complete answer.
一個基本的聊天機器人(Chatbot)聽起來可能很有把握,但它也許只會給你部分清單、漏掉重要的客戶帳號,或是混淆名稱相似的客戶。這不只是模型在憑空捏造的情況。問題往往出在檢索(Retrieval)這個步驟:系統拉取了一些單獨看起來相關、卻無法拼湊成完整答案的片段。
In the past few years, Retrieval-Augmented Generation (RAG) has become the go-to approach for building useful LLM applications. It works by grounding answers in external data rather than relying solely on what the model learned during training. However, while it's easy to build a RAG demo, making a reliable RAG product is much harder.
在過去幾年裡,檢索增強生成 (Retrieval-Augmented Generation, RAG) 已成為打造實用大型語言模型 (LLM) 應用的首選方法。它的運作方式是將答案立基於外部資料,而非僅僅依賴模型在訓練期間所學到的內容。然而,雖然打造一個 RAG 範例(Demo)很容易,要做出一個可靠的 RAG 產品卻困難得多。
This article breaks down what "advanced RAG" really is, why graph-based retrieval (GraphRAG) is becoming increasingly important for reliability, and how teams can use proven methods such as hybrid search, reranking, query rewriting, memory, and evaluation to build systems that are more accurate and easier to troubleshoot.
本文將拆解「進階 RAG」究竟是什麼、為什麼基於圖的檢索 (graph-based retrieval, GraphRAG) 對可靠性而言愈來愈重要,以及團隊如何運用混合搜尋(hybrid search)、重新排序(reranking)、查詢重寫(query rewriting)、記憶(memory)與評估(evaluation)等經過驗證的方法,來打造更準確且更易於排查問題的系統。
RAG, In One Minute: What It Does / 一分鐘認識 RAG:它做了什麼¶
At its core, a standard RAG pipeline does four things:
就核心而言,一個標準的 RAG 流程(Pipeline)做四件事:
-
Ingests content (split documents into chunks, add metadata, create embeddings)
-
攝取 (Ingests) 內容(將文件切分成片段(chunks)、加上中繼資料(metadata)、建立嵌入向量(embeddings))
-
Indexes it (often a vector index, sometimes also a keyword search)
-
為其建立索引 (Indexes)(通常是向量索引,有時也會加上關鍵字搜尋)
-
Retrieves top-k chunks for a user query.
-
針對使用者查詢檢索 (Retrieves) 出排名前 k 個片段。
-
Generates an answer using the query + retrieved context
-
使用「查詢 + 檢索到的上下文(context)」生成 (Generates) 一個答案
That "retrieve then generate" pattern helps because the model is no longer forced to guess facts from memory. Instead, it can cite and use fresh, domain-specific information.
這種「先檢索再生成」的模式之所以有幫助,是因為模型不再被迫從記憶中猜測事實,而是能夠引用並運用新鮮的、特定領域的資訊。
But RAG's effectiveness depends on what it retrieves and how it includes that information in the prompt.
但 RAG 的成效取決於它檢索到什麼,以及它如何把這些資訊放進提示(Prompt)中。
Why "Naive RAG" Breaks as Soon as Questions Get Real / 為什麼「天真版 RAG」一遇到真實問題就崩潰¶
1) Chunking breaks meaning into disconnected scraps / 1)切片把語意打散成互不相連的碎片¶
Most RAG systems break text into chunks so it fits into the model's context window. However, this process can ruin the structure that made the information clear in the first place, such as dependencies, exceptions, hierarchies, timelines, or rules like "this applies only if…"
大多數 RAG 系統會把文字切分成片段,好讓它能塞進模型的上下文視窗(context window)。然而,這個過程可能會破壞原本讓資訊清晰的結構,例如相依關係、例外情況、層級、時間軸,或是像「此項僅在……時適用」這類規則。
2) Vector similarity is great for "related," not for "connected." / 2)向量相似度擅長處理「相關」,而非「相連」¶
Vector search shines when you want semantic similarity ("this looks like that"). But it often struggles with:
當你想要的是語意相似度(「這個看起來像那個」)時,向量搜尋表現出色。但它在以下情況常常力不從心:
· Rare identifiers (SKUs, case IDs, acronyms like SSO/SOC2)
· 罕見的識別碼(庫存單位 SKU、案件編號、像 SSO/SOC2 這類縮寫)
· Cross-document questions that require multiple linked facts
· 需要多項相互關聯事實的跨文件問題
· Multi-hop reasoning ("A relates to B, which explains C")
· 多跳推理(multi-hop reasoning,「A 與 B 相關,而 B 又能解釋 C」)
3) Scaling makes the failure modes louder (and harder to debug) / 3)規模擴大會放大失敗模式(也更難除錯)¶
When you add more data, you often increase k (the number of chunks retrieved) to maintain high recall. But this can make prompts larger, slow things down, and raise the chance that the model combines unrelated pieces into an answer that only sounds correct.
當你加入更多資料時,往往會調高 k(檢索片段的數量)以維持高召回率(recall)。但這會讓提示變得更龐大、拖慢速度,並提高模型把不相關片段拼湊成一個「只是聽起來正確」答案的機率。
The DevOpsDigest article explains a common pattern: as RAG systems grow, issues move from missing information ("omitted errors") to synthesis errors, where the model combines correct pieces into a wrong answer. This makes debugging almost impossible, even if the retrieved data is accurate.
DevOpsDigest 的文章說明了一種常見模式:隨著 RAG 系統成長,問題會從資訊缺漏(「遺漏型錯誤」)轉變為綜合型錯誤(synthesis errors),也就是模型把正確的片段組合成了錯誤的答案。即使檢索到的資料是準確的,這也讓除錯變得幾乎不可能。
4) Freshness and "embedding drift" are real operational issues / 4)資料新鮮度與「嵌入漂移」是真實的營運問題¶
Documents change, systems get updated, and assumptions shift over time. Without a clear structure connecting information, it's hard to know if the retrieved context matches what's true now or what was true six months ago.
文件會變動、系統會更新,假設也會隨時間改變。在缺乏一個清楚連結資訊的結構下,很難判斷檢索到的上下文是符合現在的真實情況,還是六個月前的真實情況。
Advanced RAG: The Goal Is Not "More Context," But Better Evidence / 進階 RAG:目標不是「更多上下文」,而是更好的證據¶
Neo4j describes advanced RAG as a way to improve what the model sees and how it reasons, making answers more accurate, explainable, repeatable, and scalable.
Neo4j 將進階 RAG 描述為一種改善模型所看見的內容以及它如何推理的方法,使答案更準確、更可解釋、更可重現,也更具可擴展性。
Redis adds another practical point: you shouldn't just add techniques at random. Instead, start with a baseline, measure with clear metrics, and improve step by step.
Redis 補充了另一個實務重點:你不該隨意堆疊各種技術,而應從一個基準線(baseline)開始,用清楚的指標來衡量,然後一步步改進。
Let's break the most effective techniques into four buckets.
讓我們把最有效的技術分成四大類別。
Bucket 1: Make Retrieval Smarter / 類別一:讓檢索更聰明¶
Hybrid retrieval: combine semantic + lexical search
混合檢索:結合語意搜尋 + 詞彙搜尋
Hybrid search is now a baseline best practice because it catches both:
混合搜尋如今是一項基準的最佳實務,因為它能同時抓到兩種匹配:
· Meaning-based matches (semantic embeddings)
· 基於語意的匹配(語意嵌入向量)
· Exact-term matches (keywords like IDs, codes, proper nouns via BM25/SPLADE)
· 精確詞彙的匹配(透過 BM25/SPLADE 處理的關鍵字,例如識別碼、代碼、專有名詞)
Neo4j specifically calls out Reciprocal Rank Fusion (RRF) as a standard way to merge ranked lists from the two retrievers so results include both "right meaning" and "right tokens."
Neo4j 特別點名倒數排名融合 (Reciprocal Rank Fusion, RRF),作為合併兩個檢索器所產生之排名清單的標準做法,使結果同時涵蓋「正確語意」與「正確詞元(tokens)」。
Why it matters for general users:
為什麼這對一般使用者很重要:
If you ask "what changed in policy 7B?", semantic search might retrieve general policy content, while lexical search ensures you actually get the chunk containing "7B."
如果你問「政策 7B 改了什麼?」,語意搜尋可能會檢索出一般性的政策內容,而詞彙搜尋則能確保你真的取得包含「7B」的那個片段。
Metadata filtering: shrink the search space before the LLM ever sees it / 中繼資料過濾:在 LLM 看到之前就先縮小搜尋空間¶
Filtering uses metadata rules like source, date, author, doc type, or semantic thresholds to remove low-quality hits and reduce prompt bloat.
過濾會運用中繼資料規則,例如來源、日期、作者、文件類型,或語意門檻,來移除低品質的命中結果並減少提示膨脹。
This is especially useful if your data includes repeated templates, outdated versions, or results that are close but not quite right.
如果你的資料含有重複的範本、過時的版本,或是接近但又不完全正確的結果,這特別有用。
Reranking: make top-k actually worth reading / 重新排序:讓前 k 個結果真正值得一讀¶
The first round of retrieval often brings back a lot of noise. Reranking uses a better scoring model, such as a cross-encoder, to sort the results so that the strongest evidence comes first.
第一輪檢索常常會帶回大量雜訊。重新排序會使用一個更好的評分模型(例如交叉編碼器,cross-encoder)來排序結果,好讓最有力的證據排在最前面。
Redis emphasizes reranking when the initial top-k is a "mixed bag," especially in noisy corpora or when combining multiple retrievers.
當最初的前 k 個結果良莠不齊時,Redis 強調重新排序的重要性,尤其是在充滿雜訊的語料庫(corpora)中,或在結合多個檢索器的情況下。
Tune Your Vector Index / 調校你的向量索引¶
Redis points out that HNSW (Hierarchical Navigable Small World) indices can be improved by densifying the internal graph, for example, by tuning parameters such as M and efConstruction. This helps with recall and retrieval consistency, especially when documents are very similar.
Redis 指出,HNSW(階層式可導航小世界,Hierarchical Navigable Small World)索引可以透過讓內部圖更稠密來改善,例如調整 M 與 efConstruction 之類的參數。這有助於提升召回率與檢索一致性,尤其是當文件彼此非常相似時。
Plain-English analogy:
白話比喻:
You can think of your vector index like a city map filled with shortcuts. If there aren't enough shortcuts, the search might miss the best area and just pick something that's close enough.
你可以把向量索引想像成一張佈滿捷徑的城市地圖。如果捷徑不夠多,搜尋可能會錯過最佳區域,而只挑一個「夠接近」的地方。
Chunking and parsing: where accuracy often lives or dies / 切片與剖析:準確度往往在此決定生死¶
Both Neo4j and Redis stress that chunk boundaries strongly influence what gets retrieved.
Neo4j 與 Redis 都強調,片段的邊界會強烈影響到底檢索出什麼。
Neo4j's recommendation: start with fixed-size or sentence-aware splits, add semantic chunking when boundaries are messy, and use document-aware chunkers when structure matters (tables, headers, code).
Neo4j 的建議是:從固定大小或感知句子的切分開始,當邊界凌亂時加入語意切片(semantic chunking),而在結構很重要時(表格、標題、程式碼)則使用感知文件結構的切片器。
Redis also notes that structured documents, such as medical records or policy manuals, benefit from parsing that respects logical boundaries. Random or overly long splits can make the results less relevant.
Redis 也指出,像病歷或政策手冊這類結構化文件,會受益於尊重邏輯邊界的剖析。隨機或過長的切分可能會降低結果的相關性。
Parent retrievers: keep small chunks for searching, but return whole sections to preserve meaning / 父層檢索器:用小片段來搜尋,但回傳整個段落以保留語意¶
Neo4j describes a "parent retriever" approach: retrieve smaller child chunks for precision, but when many children from one section match, swap in the larger parent block to reduce fragmentation.
Neo4j 描述了一種「父層檢索器(parent retriever)」做法:為了精準度而檢索較小的子片段(child chunks),但當同一段落中有許多子片段都匹配時,就換成較大的父層區塊(parent block),以減少資訊的碎片化。
Bucket 2: Make The Context Window Smaller — But More Informative / 類別二:讓上下文視窗更小 —— 但資訊量更高¶
Context distillation: summarize what you retrieved / 上下文蒸餾:總結你所檢索到的內容¶
If your context window is limited, you don't automatically want fewer documents — you want less noise.
如果你的上下文視窗有限,你想要的並不必然是更少的文件 —— 你想要的是更少的雜訊。
Neo4j recommends summarizing retrieved hits so that more relevant information fits, and the model focuses on key facts, noting that GraphRAG uses query-focused summarization and that common frameworks also support compression-style retrievers.
Neo4j 建議對檢索到的命中結果進行摘要,好讓更多相關資訊能塞進來,並使模型聚焦在關鍵事實上;它也指出 GraphRAG 採用以查詢為焦點的摘要(query-focused summarization),而常見的框架也支援壓縮式(compression-style)的檢索器。
Semantic caching: stop regenerating answers that should be stable / 語意快取:別再重複生成那些本應穩定的答案¶
Redis recommends semantic caching for stable knowledge bases like FAQs or product documentation: match similar questions and serve pre-approved answers deterministically.
Redis 建議針對 FAQ 或產品文件這類穩定的知識庫使用語意快取(semantic caching):匹配相似的問題,並以決定性的方式提供事先核可的答案。
This not only reduces latency but also reduces variability and prevents different answers to the same question.
這不僅能降低延遲,也能減少變異性,避免同一個問題出現不同答案。
Long-term memory for multi-turn apps / 為多輪對話應用建立長期記憶¶
For coaching tools, internal copilots, or support agents, long-term memory management helps maintain continuity across sessions by persisting key facts and selectively recalling them.
對於教練輔導工具、內部協作助手(copilots)或客服代理(support agents),長期記憶管理能透過持久保存關鍵事實並有選擇地回想它們,來維持跨工作階段(sessions)的連續性。
Neo4j describes "memory augmentation" as recalling only key information instead of adding full transcripts. This is often combined with dynamic context windowing.
Neo4j 將「記憶增強(memory augmentation)」描述為只回想關鍵資訊,而不是塞入完整的對話逐字稿。這通常會與動態上下文視窗(dynamic context windowing)結合使用。
Bucket 3: Understand The Query Before You Retrieve / 類別三:在檢索之前先理解查詢¶
Query expansion and HyDE-style transforms. / 查詢擴展與 HyDE 式轉換¶
Sometimes users don't ask questions in the same words your documents use. Neo4j suggests adding a small "query understanding" layer to rewrite or expand questions in an inspectable way.
有時使用者提問所用的字詞,和你文件裡所用的字詞並不相同。Neo4j 建議加上一個小型的「查詢理解(query understanding)」層,以一種可檢視的方式來重寫或擴展問題。
They mention:
他們提到:
· Hypothetical questions / HyDE-style approaches (generate representative questions or hypothetical answers and index them)
· 假設性問題 / HyDE 式(Hypothetical Document Embeddings)做法(生成具代表性的問題或假設性答案,並為它們建立索引)
· Query expansion (add synonyms or generate variants)
· 查詢擴展(加入同義詞或生成變體)
Redis also recommends using query transforms for vague or unclear questions, specifically mentioning HyDE and multi-step reformulations.
Redis 也建議針對模糊或不清楚的問題使用查詢轉換,並特別提到 HyDE 與多步驟重新表述(multi-step reformulations)。
Bucket 4: Reliability Isn't A Feeling — Measure It and Add Feedback Loops / 類別四:可靠性不是一種感覺 —— 要去衡量它並加入回饋迴路¶
Use "Corrective RAG" checks before answering.
在回答之前,使用「校正式 RAG」檢查。
Neo4j explains Corrective RAG (CRAG) as a simple feedback loop. Before generating an answer, check whether the retrieved information is sufficient. If it isn't, try retrieving again or use stricter filters. This helps prevent hallucinations by making sure the model only answers when the evidence is strong.
Neo4j 將校正式 RAG (Corrective RAG, CRAG) 解釋為一個簡單的回饋迴路。在生成答案之前,先檢查檢索到的資訊是否足夠。如果不足,就嘗試重新檢索或使用更嚴格的過濾條件。這能確保模型只在證據充分時才回答,從而有助於防止幻覺(hallucinations)。
Use an LLM as a judge. / 使用 LLM 作為評審¶
Redis suggests using an "LLM as judge" to check if a generated answer matches the retrieved context. This is especially useful in high-stakes areas.
Redis 建議使用「LLM 作為評審(LLM as judge)」來檢查生成的答案是否與檢索到的上下文相符。這在高風險領域中特別有用。
Track the right metrics. / 追蹤正確的指標¶
Neo4j suggests evaluating:
Neo4j 建議評估:
· Retrieved-context relevance
· 檢索上下文的相關性
· Groundedness/faithfulness
· 立基性/忠實度(groundedness/faithfulness)
· Answer relevance
· 答案的相關性
· Ranking metrics like MRR/Recall@k and latency
· 排名指標,例如 MRR(平均倒數排名)/ Recall@k(前 k 名召回率)以及延遲
Redis agrees with this approach: begin with a simple baseline, set clear metrics such as recall, F1 score, or human preference, and then improve step by step.
Redis 認同這套做法:從一個簡單的基準線開始,設定清楚的指標,例如召回率、F1 分數或人類偏好,然後一步步改進。
When reasoning matters: why graph-based retrieval is getting so much attention / 當推理變得重要時:為什麼基於圖的檢索備受矚目¶
A key idea across multiple sources is simple:
貫穿多個資料來源的一個核心觀念很簡單:
Vector RAG retrieves what looks similar.
向量 RAG 檢索的是「看起來相似」的東西。
Graph-based retrieval retrieves what is connected.
基於圖的檢索檢索的是「彼此相連」的東西。
DevOpsDigest explains how traditional vector-based RAGs start to crack when users ask relationship-based questions, such as "Why did this happen?" "How do these components depend on each other?" "What changes when condition X is true?" Those are fundamentally about connections, not just similar wording.
DevOpsDigest 說明了當使用者提出基於關係的問題時,傳統的向量式 RAG 如何開始出現裂痕,例如「為什麼會發生這件事?」「這些元件之間如何相互依賴?」「當條件 X 成立時會有什麼改變?」這些問題本質上關乎連結關係,而不只是字詞相似。
Graph-based retrieval views knowledge as a network of entities and relationships, such as services that depend on other services, policies that apply under certain conditions, or changes that spread along paths. Vector search is still useful, often for finding relevant parts of the graph or understanding natural language, but it's not the only tool anymore.
基於圖的檢索把知識看作一個由實體(entities)與關係(relationships)所構成的網路,例如依賴其他服務的服務、在特定條件下適用的政策,或是沿著路徑擴散的變動。向量搜尋依然有用,通常用於找出圖中相關的部分或理解自然語言,但它已不再是唯一的工具。
Meilisearch gives an accessible definition: a knowledge graph models entities (people, places, products, numbers, etc.) and the relationships between them, helping answer complex queries where connections matter.
Meilisearch 給出了一個易懂的定義:知識圖譜 (knowledge graph) 會對實體(人、地點、產品、數字等)以及它們之間的關係進行建模,協助回答那些「連結關係很重要」的複雜查詢。
Graphrag: The "Connected Context" Version Of RAG / GraphRAG:RAG 的「連結式上下文」版本¶
Neo4j's description of GraphRAG is straightforward:
Neo4j 對 GraphRAG 的描述很直接:
· If your content has rich entities and relationships (people, products, cases, citations), a knowledge graph helps you retrieve the context of the data, not just similar text.
· 如果你的內容含有豐富的實體與關係(人物、產品、案件、引用),知識圖譜能幫你檢索出資料的上下文脈絡,而不只是相似的文字。
· You can blend graph traversals with vector search to assemble a connected context for the prompt.
· 你可以把圖遍歷(graph traversals)與向量搜尋融合起來,為提示組裝出一個彼此相連的上下文。
They also highlight two complementary retrieval styles:
他們也強調了兩種互補的檢索風格:
· Local traversals around initial hits (pull related entities/paths)
· 圍繞初始命中結果的局部遍歷(local traversals)(拉取相關的實體/路徑)
· Global community summaries for big-picture questions
· 用於宏觀問題的全域社群摘要(global community summaries)
They also point out a practical benefit: graph-based retrieval makes it easier to explain and debug answers, since you can show the nodes, edges, and passages that supported the response.
他們也指出一個實務上的好處:基於圖的檢索讓答案更容易解釋與除錯,因為你可以展示出支撐該回應的節點(nodes)、邊(edges)與段落。
A Research-Backed View: Graphs Can Enhance Every Stage Of RAG / 一個有研究支撐的觀點:圖能強化 RAG 的每一個階段¶
The arXiv survey "Graph-based Approaches and Functionalities in Retrieval-Augmented Generation" argues that LLMs struggle with two major challenges: factual errors/hallucinations and the difficulty of exploiting naturally structured real-world knowledge.
arXiv 的綜述論文〈Graph-based Approaches and Functionalities in Retrieval-Augmented Generation〉(檢索增強生成中基於圖的方法與功能)主張,LLM 面臨兩大挑戰:事實性錯誤/幻覺,以及難以善用現實世界中天然具結構性的知識。
It positions graphs not as a single trick, but as a toolkit spanning the pipeline. The survey says graph techniques can:
它把圖定位成的不是單一招式,而是一套貫穿整條流程的工具箱。該綜述指出,圖技術可以:
-
Improve knowledge base construction.
-
改善知識庫的建構。
-
Optimize retrieval and prompting (graph indexing/querying/reasoning)
-
優化檢索與提示(圖索引/查詢/推理)
-
Streamline pipelines (graph-structured workflows)
-
精簡流程(圖結構化的工作流程)
-
Support graph-oriented tasks
-
支援以圖為導向的任務
Importantly, it argues for a broader definition of graph-based RAG than "just knowledge-graph traversal," focusing on design trade-offs like accuracy, latency, token budget, freshness, and provenance.
重要的是,它主張對「基於圖的 RAG」採取比「僅是知識圖譜遍歷」更廣義的定義,聚焦於各種設計取捨,例如準確度、延遲、詞元預算(token budget)、資料新鮮度與來源出處(provenance)。
And for future directions, it points to richer graph structures (like hypergraphs), semantic embeddings, dynamically evolving graphs, and hierarchical/adaptive construction methods to better capture real-world complexity.
至於未來方向,它指向了更豐富的圖結構(例如超圖,hypergraphs)、語意嵌入、動態演化的圖,以及階層式/自適應的建構方法,以更好地捕捉現實世界的複雜性。
A concrete GraphRAG example: biomedical Q&A with graphs + neural models / 一個具體的 GraphRAG 範例:結合圖與神經模型的生醫問答¶
The NVIDIA technical blog shows a specific GraphRAG approach built on the G-Retriever architecture. In their framing, GraphRAG combines:
NVIDIA 的技術部落格展示了一種建立在 G-Retriever 架構之上的特定 GraphRAG 做法。在他們的框架中,GraphRAG 結合了:
· Knowledge graph construction (represents domain knowledge as a graph)
· 知識圖譜建構(將領域知識表示為一張圖)
· Intelligent retrieval (graph queries + Prize-Collecting Steiner Tree (PCST) to select a relevant subgraph)
· 智慧檢索(圖查詢 + 獎勵收集斯坦納樹 (Prize-Collecting Steiner Tree, PCST),用以選出一個相關的子圖)
· Neural processing (integrate GNN layers during LLM fine-tuning so the model focuses on the retrieved context)
· 神經處理(在 LLM 微調(fine-tuning)期間整合 GNN 層(圖神經網路,Graph Neural Network),使模型聚焦於檢索到的上下文)
Why This Matters / 為什麼這很重要¶
Instead of retrieving isolated text chunks, the system retrieves a connected subgraph — a small "map" of the most relevant entities and relationships.
這套系統檢索的不是孤立的文字片段,而是一個彼此相連的子圖 —— 也就是一張由最相關的實體與關係所構成的小「地圖」。
The post illustrates a biomedical example question:
該文以一個生醫領域的範例問題來說明:
"What drugs target the CYP3A4 enzyme and are used to treat strongyloidiasis?"
「有哪些藥物以 CYP3A4 酶為標的,並且被用來治療類圓線蟲病(strongyloidiasis)?」
They note that answering correctly (Ivermectin) requires combining direct relationships (drug–enzyme, drug–disease) and node properties (descriptions/classifications).
他們指出,要正確回答(伊維菌素,Ivermectin),需要結合直接關係(藥物—酶、藥物—疾病)與節點屬性(描述/分類)。
Reported Results and Performance Details / 所回報的結果與效能細節¶
On their benchmark, they report results including:
在他們的基準測試上,回報的結果包括:
· Baseline Hits@1: 15.57
· 基準線 Hits@1:15.57
· Pipeline approach Hits@1: 32.09
· 流程化做法 Hits@1:32.09
· They state that this 32% Hits@1 is more than double the baseline.
· 他們表示這 32% 的 Hits@1 是基準線的兩倍以上。
They also provide inference-time breakdowns (median times): Cipher ~0.069s, PCST ~0.166s, GNN+LLM ~0.497s.
他們也提供了推論時間的細分(中位數時間):Cipher 約 0.069 秒、PCST 約 0.166 秒、GNN+LLM 約 0.497 秒。
And they describe implementation details involving Neo4j/Cipher, PyTorch Geometric (PyG), vector similarity for selecting relevant nodes, and then running PCST to prune the subgraph.
他們還描述了實作細節,涉及 Neo4j/Cipher、PyTorch Geometric (PyG),以向量相似度來選出相關節點,接著執行 PCST 來修剪子圖。
Realistic Caveats / 務實的提醒事項¶
They also openly list challenges:
他們也坦率地列出了一些挑戰:
· Hyperparameter complexity (hops, filtering, prize assignments, etc.)
· 超參數(hyperparameter)的複雜度(跳數、過濾、獎勵分配等)
· Benchmark limitations (current benchmarks limited to ≤4 hop questions; assumption answers are nodes rather than subgraphs)
· 基準測試的侷限(目前的基準測試僅限於 ≤4 跳的問題;並假設答案是節點而非子圖)
For general readers, this is a good reminder: graph-powered systems can greatly improve multi-step accuracy, but they also bring new design and tuning challenges.
對一般讀者而言,這是一個很好的提醒:由圖驅動的系統能大幅提升多步驟任務的準確度,但它們也帶來了新的設計與調校挑戰。
Knowledge Graph Vs. Vector Database For RAG: How to Choose Without Religious Wars / RAG 該用知識圖譜還是向量資料庫:如何在不打信仰之戰的情況下抉擇¶
Meilisearch summarizes the core difference cleanly:
Meilisearch 俐落地總結了核心差異:
· Vector databases focus on similarities between vector representations (semantic matching).
· 向量資料庫著重於向量表示之間的相似度(語意匹配)。
· Knowledge graphs focus on relationships between entities (reasoning + traceability).
· 知識圖譜著重於實體之間的關係(推理 + 可追溯性)。
When a vector database is typically better / 什麼時候向量資料庫通常更好¶
A vector database is a strong choice when you have lots of unstructured data (documents, tickets, papers) and meaning matters more than explicit relationships.
當你擁有大量非結構化資料(文件、工單、論文),且語意比明確的關係更重要時,向量資料庫是個有力的選擇。
Meilisearch also points out that a dedicated vector database can improve retrieval precision, but it's not always necessary. Some teams use hybrid engines that combine full-text and vector search.
Meilisearch 也指出,專用的向量資料庫能提升檢索精準度,但並非總是必要。有些團隊會使用結合全文搜尋與向量搜尋的混合引擎。
When A Knowledge Graph Tends To Shine / 什麼時候知識圖譜往往大放異彩¶
Meilisearch says knowledge graphs are ideal when data is structured or interconnected, and you care about the "how" and "why," enabling multi-hop reasoning and helping the LLM trace how an answer was retrieved.
Meilisearch 表示,當資料具結構性或彼此相互關聯,而你又在意「如何」與「為什麼」時,知識圖譜是理想之選;它能實現多跳推理,並協助 LLM 追溯一個答案是如何被檢索出來的。
DevOpsDigest highlights the engineering benefits: having an explicit structure gives you more control and makes debugging easier. If an answer is wrong, you can check the graph paths instead of just looking at a similarity score.
DevOpsDigest 強調了工程上的好處:擁有明確的結構能給你更多掌控力,並讓除錯更容易。如果一個答案是錯的,你可以去檢查圖的路徑,而不是只盯著一個相似度分數看。
The honest limitations on both sides / 兩邊都有的坦白侷限¶
Meilisearch lists downsides to knowledge graphs: they can be hard to develop, degrade performance with many hops, don't handle unstructured text as naturally, and can be expensive to maintain due to schema/versioning.
Meilisearch 列出了知識圖譜的缺點:它們可能難以開發、在跳數很多時效能會下降、處理非結構化文字時不那麼自然,並且由於綱要(schema)與版本控管的緣故,維護起來可能所費不貲。
For vector databases, Meilisearch notes that similarity scores are hard to explain and lack transparency. They also don't handle complex relationships well, and adding retrievers or generators can increase operational complexity with extra "glue code."
至於向量資料庫,Meilisearch 指出相似度分數難以解釋且缺乏透明度。它們也不太擅長處理複雜的關係,而加入檢索器或生成器則可能因額外的「黏合程式碼(glue code)」而增加營運上的複雜度。
Why The "Hybrid Approach" Keeps Winning / 為什麼「混合做法」總是勝出¶
Both Neo4j and Meilisearch recommend hybrid architectures. Use vector or hybrid retrieval for broad discovery, and add a knowledge graph layer to trace relationships and handle multi-hop reasoning.
Neo4j 與 Meilisearch 都推薦混合式架構。用向量或混合檢索來進行廣泛的探索發現,再加上一個知識圖譜層來追溯關係並處理多跳推理。
A Practical Roadmap: How To Go from Demo To "Ship-Ready" RAG / 一份實務路線圖:如何從範例邁向「可上線」的 RAG¶
If you want something actionable, Neo4j offers a sensible sequence:
如果你想要一些可付諸行動的東西,Neo4j 提供了一套合理的步驟順序:
-
Stabilize basic retrieval: good embeddings, sensible chunking, clean metadata, add a reranker, measure baseline.
-
穩定基本檢索:良好的嵌入向量、合理的切片、乾淨的中繼資料、加入重新排序器,並衡量基準線。
-
Add hybrid search (BM25 + vectors, RRF), track precision/recall, and groundedness.
-
加入混合搜尋(BM25 + 向量、RRF),追蹤精準度/召回率以及立基性。
-
Introduce query understanding: query expansion + HyDE-style methods.
-
引入查詢理解:查詢擴展 + HyDE 式方法。
-
Optimize context supply: parent-doc logic + summarization/context distillation.
-
優化上下文供給:父層文件邏輯 + 摘要/上下文蒸餾。
-
Handle complex questions with agentic planning (plan → route → act → verify → stop) and graph-based retrieval for joins/paths.
-
以代理式規劃(agentic planning,規劃 → 路由 → 行動 → 驗證 → 停止)與用於關聯/路徑的基於圖檢索,來處理複雜問題。
Redis supports this disciplined approach: begin with a simple baseline, set clear metrics, and then make targeted improvements step by step.
Redis 支持這種有紀律的做法:從一個簡單的基準線開始,設定清楚的指標,然後一步步進行有針對性的改進。
A quick "sanity checklist" that prevents many failures / 一份能預防諸多失敗的快速「健全性檢查清單」¶
· Can your retrieval handle rare tokens (IDs, acronyms)? → hybrid search + lexical indexing
· 你的檢索能處理罕見詞元(識別碼、縮寫)嗎?→ 混合搜尋 + 詞彙索引
· Are results relevant but poorly ordered? → reranking
· 結果是否相關但排序不佳?→ 重新排序
· Are you retrieving fragments that lose meaning? → better chunking + parent retrieval
· 你是否檢索到了喪失語意的碎片?→ 更好的切片 + 父層檢索
· Are queries vague or mismatched to the doc language? → query transforms (HyDE, expansion)
· 查詢是否模糊不清,或與文件用語不匹配?→ 查詢轉換(HyDE、擴展)
· Are answers risky even with good context? → CRAG checks + "LLM as judge"
· 即使有良好的上下文,答案仍有風險嗎?→ CRAG 檢查 + 「LLM 作為評審」
· Do users ask "how does X relate to Y?" constantly? → consider GraphRAG
· 使用者是否一直在問「X 與 Y 有什麼關聯?」→ 考慮使用 GraphRAG
The Big Takeaway / 重點總結¶
Advanced RAG isn't a single magic upgrade. It's a group of coordinated improvements across several areas:
進階 RAG 不是單一的神奇升級。它是跨越多個領域、彼此協調的一組改進:
· Retrieval quality (hybrid, filtering, reranking, index tuning)
· 檢索品質(混合、過濾、重新排序、索引調校)
· Context management (chunking, parent retrieval, summarization, caching, memory)
· 上下文管理(切片、父層檢索、摘要、快取、記憶)
· Query understanding (HyDE, expansion, reformulation)
· 查詢理解(HyDE、擴展、重新表述)
· Reliability practices (evaluation metrics, CRAG, LLM-as-judge)
· 可靠性實務(評估指標、CRAG、LLM 作為評審)
And when users need to reason about relationships rather than just find similar text, graph-based retrieval becomes essential. It offers a structural solution to a structural problem.
而當使用者需要對關係進行推理,而不僅僅是找出相似文字時,基於圖的檢索就變得不可或缺。它為一個結構性的問題提供了一個結構性的解答。
References / 參考資料¶
https://neo4j.com/blog/genai/advanced-rag-techniques/
https://developer.nvidia.com/blog/boosting-qa-accuracy-with-graphrag-using-pyg-and-graph-databases/
https://arxiv.org/html/2504.10499v2
https://redis.io/blog/10-techniques-to-improve-rag-accuracy/
https://www.meilisearch.com/blog/knowledge-graph-vs-vector-database-for-rag
🔤 關鍵術語¶
| 英文 | 繁中譯名 | 文章中的脈絡 / 簡短說明 |
|---|---|---|
| Retrieval-Augmented Generation (RAG) | 檢索增強生成 | 透過外部資料來「接地」答案,而非僅依賴模型訓練知識的核心架構 |
| GraphRAG | 圖譜檢索增強生成 | 以實體與關係構成的知識圖譜檢索「連接的脈絡」,補足向量檢索只找「相似」的不足 |
| Hybrid retrieval / Hybrid search | 混合檢索 | 結合語意(embeddings)與字面(BM25/SPLADE)兩種檢索,兼顧「對的意思」與「對的詞」 |
| Reciprocal Rank Fusion (RRF) | 倒數排名融合 | Neo4j 提出的標準法,用於合併兩個檢索器的排序清單 |
| Reranking / Cross-encoder | 重排序 / 交叉編碼器 | 用更強的評分模型把 top-k 結果重新排序,讓最佳證據排在前面 |
| HNSW (Hierarchical Navigable Small World) | 階層式可導航小世界 | 一種向量索引,可透過 M、efConstruction 等參數調整以提升召回 |
| Vector embeddings | 向量嵌入 | 將文本轉為向量以做語意相似度比對的表示法 |
| Multi-hop reasoning | 多跳推理 | 需串連多個事實的推理(A 關聯 B,B 解釋 C),向量檢索常難處理 |
| Metadata filtering | 元資料過濾 | 用來源、日期、文件類型等規則先縮小搜尋空間,減少 prompt 膨脹 |
| Semantic chunking | 語意切塊 | 依語意邊界切分文件,相對固定大小切分更能保留意義 |
| Parent retriever | 父區塊檢索 | 以小子區塊做精準檢索,但回傳較大的父段落以保留完整語意 |
| Context distillation / Query-focused summarization | 脈絡蒸餾 / 查詢導向摘要 | 摘要檢索結果以降低雜訊、讓關鍵事實塞進有限的上下文窗 |
| Semantic caching | 語意快取 | 對相似問題比對並回傳預先核可的答案,降低延遲與變異性 |
| HyDE (Hypothetical Document Embeddings) | 假設性文件嵌入 | 產生代表性問題或假設答案並建索引的查詢轉換技巧 |
| Query expansion | 查詢擴展 | 加入同義詞或產生變體以彌補使用者與文件用語落差 |
| Corrective RAG (CRAG) | 修正式 RAG | 生成前先檢查檢索資訊是否充足,不足則重檢索或加嚴過濾以防幻覺 |
| LLM as a judge | 以 LLM 作為評審 | 用另一個 LLM 檢查生成答案是否與檢索脈絡相符 |
| Groundedness / Faithfulness | 接地性 / 忠實度 | 評估答案是否確實依據檢索到的證據之指標 |
| MRR / Recall@k | 平均倒數排名 / 前 k 召回率 | 評估檢索排序品質的常用指標 |
| Knowledge graph | 知識圖譜 | 以實體與關係建模知識的網路,擅長回答「如何/為何」的關聯查詢 |
| Graph traversal (Local / Global community summaries) | 圖譜遍歷(局部遍歷/全域社群摘要) | 圍繞初始命中拉出相關實體路徑,或用社群摘要回答全局性問題 |
| G-Retriever architecture | G-Retriever 架構 | NVIDIA 範例所採用的 GraphRAG 架構基礎 |
| Prize-Collecting Steiner Tree (PCST) | 獎勵收集斯坦納樹 | 用於從圖譜中挑選相關子圖、修剪 subgraph 的演算法 |
| GNN (Graph Neural Network) layers | 圖神經網路層 | 在 LLM 微調時整合,讓模型聚焦於檢索到的圖譜脈絡 |
| Hits@1 | 首位命中率 | NVIDIA 基準的評估指標(基線 15.57 → 管線 32.09) |
| Vector database | 向量資料庫 | 聚焦向量表示間相似度(語意比對)的資料庫,適合大量非結構化資料 |