Advanced RAG

What is Advanced RAG?

Advanced RAG (Advanced Retrieval-Augmented Generation) is an evolutionary upgrade over the basic “Naive RAG” pipeline. It adds a suite of optimization techniques at every stage of the RAG workflow — pre-retrieval, retrieval, post-retrieval, and evaluation — to systematically improve retrieval precision, recall, and generation quality.

Naive RAG is like sending a junior intern to the library with a single, vague question, grabbing the first 5 books they find, and copying paragraphs directly. Advanced RAG is like sending a team of expert researchers who:

  • Rephrase the question in 5 different ways (Query Rewrite)
  • Write a fake “perfect answer” first to know exactly what to look for (HyDE)
  • Search both the card catalog AND the full-text index (Hybrid Search)
  • Have a senior editor re-rank the top results (Reranker)
  • Summarize and compress the findings before presenting them (Context Compression)
  • And finally, run a quality check on the entire process (Evaluation)

CN: 朴素 RAG 就像派一个初级实习生去图书馆,带着一个模糊的问题,抓起前5本书,直接抄段落。Advanced RAG 就像派一队专家研究员:

  • 把问题用5种不同方式重新表述(查询重写)
  • 先写一篇“完美的假答案”来明确要找什么(HyDE)
  • 同时搜索卡片目录和全文索引(混合检索)
  • 让高级编辑对结果重新排名(重排序器)
  • 在呈现之前总结和压缩发现(上下文压缩)
  • 最后对整个流程做质量检查(评估)

What does Advanced RAG include?

Layer 1: Chunking Strategies

Chunking 策略

ENCN
Recursive Chunking: Split text by paragraphs/sentences with overlap递归分块:按段落/句子分割,带重叠
Semantic Chunking: Split by semantic boundaries using embedding similarity语义分块:用嵌入相似度按语义边界分割
Parent-Child Retrieval: Retrieve child chunks, return parent chunks for context父子检索:检索子块,返回父块作为上下文

Layer 2:Retrieval Strategies

检索策略

ENCN
Hybrid Search: Combine dense (vector) + sparse (BM25) retrieval混合检索:结合稠密(向量)+ 稀疏(BM25)检索
RRF (Reciprocal Rank Fusion): Merge multi-strategy results by rankRRF(倒数排名融合):按排名位置合并多路结果
Vector DB Selection: Chroma, Pinecone, Milvus, Azure AI Search向量数据库选型:Chroma, Pinecone, Milvus, Azure AI Search

Layer 3: Post-Retrieval Optimization

检索后优化

ENCN
Reranker: Cross-encoder models to re-score retrieved documents重排序器:用交叉编码器模型重新给检索文档打分
Query Rewrite: Rephrase queries for better embedding alignment查询重写:改写查询以更好地对齐嵌入
HyDE: Generate hypothetical answer → embed that → retrieveHyDE:生成假设答案 → 嵌入假设答案 → 检索
Multi-Query Retrieval: Generate multiple query variants, search in parallel多查询检索:生成多个查询变体,并行搜索
Context Compression: Summarize or filter retrieved docs to fit context window上下文压缩:总结或过滤检索文档以适应上下文窗口

Layer 4: Evaluation

评估体系

ENCN
RAG Eval Metrics (ragas): Context Relevancy, Answer Relevancy, FaithfulnessRAG评估指标(ragas):上下文相关性、答案相关性、忠实度
Golden Dataset: Human-annotated Q&A pairs for regression testing黄金数据集:人工标注的问答对,用于回归测试

Advanced RAG differences from Naive RAG

维度ENCN
检索次数Naive: 1 single retrieval call. Advanced: Multiple parallel retrievals + reranking.朴素:单次检索调用。Advanced:多次并行检索 + 重排序。
查询处理Naive: Embed query directly. Advanced: Query Rewrite / HyDE / Multi-Query.朴素:直接嵌入查询。Advanced:查询重写 / HyDE / 多查询。
检索类型Naive: Vector search only. Advanced: Hybrid (Vector + BM25 + RRF).朴素:仅向量搜索。Advanced:混合(向量 + BM25 + RRF)。
排序Naive: Raw similarity scores. Advanced: Cross-encoder reranker (more accurate).朴素:原始相似度分数。Advanced:交叉编码器重排序器(更精确)。
分块Naive: Fixed-size chunking (e.g., 512 tokens). Advanced: Semantic / Parent-Child.朴素:固定大小分块(如512 token)。Advanced:语义 / 父子分块。
上下文窗口利用Naive: Dump all retrieved chunks into prompt. Advanced: Compress / filter / summarize.朴素:把所有检索块塞进提示词。Advanced:压缩 / 过滤 / 总结。
评估Naive: None or manual. Advanced: Automated Eval with ragas + Golden Dataset.朴素:无或手动。Advanced:用 ragas + 黄金数据集自动评估。
失败处理Naive: If retrieval fails, LLM hallucinates. Advanced: Query rewrite retries, multi-query fallback.朴素:检索失败则LLM幻觉。Advanced:查询重写重试、多查询降级。

Example: You’re building a customer support RAG for a cloud provider’s documentation.

阶段Naive RAGAdvanced RAG
用户查询“how fix 503 error”“how fix 503 error”
处理直接嵌入查询Query Rewrite → “how to troubleshoot HTTP 503 service unavailable error”, “503 error resolution steps”
检索向量搜索返回5个块,其中3个是关于”503″但不相关的(如负载均衡器通用文档)混合检索(BM25+向量) + RRF,返回15个候选
重排Cross-encoder reranker 重新打分,选出最相关的3个块
上下文5个块全部塞入(可能超过窗口)Context compression 总结每个块,只保留关键步骤
生成答案可能泛泛而谈答案精确指出: “检查service mesh sidecar, 重启x, 检查Y”