做 RAG 系统的团队终于有了解决检索错配的实用方案——CRAG 在检索后加一道评估关卡,直接过滤掉相似但不相关的文档。做知识库问答或搜索增强应用的开发者,值得看看这个改进管道的方法。
RAG 管道常犯一个错误:把语义相似度当成相关性,导致返回主题相近但实际不匹配的结果。CRAG(Corrective RAG)通过引入评估步骤,在检索后对文档进行相关性评分,并分三条路径处理:正确则精炼使用,模糊则补充网络搜索,错误则丢弃并回退搜索。评估器使用微调后的 T5-Large 模型,比通用 LLM 更快更精准。CRAG 能有效拦截 Apache 指南回答 Nginx 配置这类错误,确保生成只基于真正相关的内容。
𝗧𝗵𝗲𝗿𝗲'𝘀 𝗽𝗿𝗼𝗯𝗮𝗯𝗹𝘆 𝗮 𝗯𝗹𝗶𝗻𝗱 𝘀𝗽𝗼𝘁 𝗶𝗻 𝘆𝗼𝘂𝗿 𝗥𝗔𝗚 𝗽𝗶𝗽𝗲𝗹𝗶𝗻𝗲: 𝗶𝘁 ...
𝗧𝗵𝗲𝗿𝗲'𝘀 𝗽𝗿𝗼𝗯𝗮𝗯𝗹𝘆 𝗮 𝗯𝗹𝗶𝗻𝗱 𝘀𝗽𝗼𝘁 𝗶𝗻 𝘆𝗼𝘂𝗿 𝗥𝗔𝗚 𝗽𝗶𝗽𝗲𝗹𝗶𝗻𝗲: 𝗶𝘁 𝘁𝗿𝗲𝗮𝘁𝘀 𝘀𝗶𝗺𝗶𝗹𝗮𝗿𝗶𝘁𝘆 𝗮𝘀 𝗿𝗲𝗹𝗲𝘃𝗮𝗻𝗰𝗲, 𝗮𝗻𝗱 𝗵𝗮𝗻𝗱𝘀 𝗯𝗮𝗰𝗸 𝗿𝗲𝘀𝘂𝗹𝘁𝘀 𝘆𝗼𝘂 𝘄𝗲𝗿𝗲𝗻'𝘁 𝗮𝗰𝘁𝘂𝗮𝗹𝗹𝘆 𝗹𝗼𝗼𝗸𝗶𝗻𝗴 𝗳𝗼𝗿. A document can score 95% similarity to your query and still be the wrong answer. 𝗖𝗥𝗔𝗚 (𝗖𝗼𝗿𝗿𝗲𝗰𝘁𝗶𝘃𝗲 𝗥𝗔𝗚) 𝗶𝘀 𝗯𝘂𝗶𝗹𝘁 𝘁𝗼 𝗰𝗹𝗼𝘀𝗲 𝘁𝗵𝗮𝘁 𝗴𝗮𝗽. The gap is a common retrieval mismatch — the document is topically close, but doesn't answer the question. Say you ask how to configure an HTTPS certificate in Nginx. Vector search returns a polished guide for HTTPS on Apache. It's on the same topic with the same keywords — TLS, certificates, web servers — so the embedding distance is tiny. However, it's not what you asked for. 𝗖𝗥𝗔𝗚 𝗳𝗶𝘅𝗲𝘀 𝘁𝗵𝗶𝘀 𝗯𝘆 𝗰𝗵𝗮𝗻𝗴𝗶𝗻𝗴 𝘁𝗵𝗲 𝗽𝗶𝗽𝗲𝗹𝗶𝗻𝗲 𝗶𝘁𝘀𝗲𝗹𝗳: 𝗿𝗲𝘁𝗿𝗶𝗲𝘃𝗲 → 𝗴𝗲𝗻𝗲𝗿𝗮𝘁𝗲 𝗯𝗲𝗰𝗼𝗺𝗲𝘀 𝗿𝗲𝘁𝗿𝗶𝗲𝘃𝗲 → 𝗲𝘃𝗮𝗹𝘂𝗮𝘁𝗲 → 𝗰𝗼𝗿𝗿𝗲𝗰𝘁 → 𝗴𝗲𝗻𝗲𝗿𝗮𝘁𝗲. 𝗧𝗵𝗲 𝗻𝗲𝘄 𝗲𝘃𝗮𝗹𝘂𝗮𝘁𝗲 𝘀𝘁𝗲𝗽 𝗶𝘀 𝘁𝗵𝗲 𝗰𝗼𝗿𝗲 𝗼𝗳 𝗖𝗥𝗔𝗚. It's run by an evaluator: a small, specialized model that scores how relevant each retrieved document is to the query, instead of generating text. The original paper uses a fine-tuned T5-Large here, not a general LLM — for a check that runs on every query, that's faster and more precise. Based on that score, it routes each document down one of three paths: ✓ 𝗖𝗼𝗿𝗿𝗲𝗰𝘁 → 𝗿𝗲𝗳𝗶𝗻𝗲 𝗶𝘁 𝗮𝗻𝗱 𝘂𝘀𝗲 𝗶𝘁 ~ 𝗔𝗺𝗯𝗶𝗴𝘂𝗼𝘂𝘀 → 𝗿𝗲𝗳𝗶𝗻𝗲 𝗶𝘁 + 𝘀𝘂𝗽𝗽𝗹𝗲𝗺𝗲𝗻𝘁 𝘄𝗶𝘁𝗵 𝘄𝗲𝗯 𝘀𝗲𝗮𝗿𝗰𝗵 ✗ 𝗜𝗻𝗰𝗼𝗿𝗿𝗲𝗰𝘁 → 𝗱𝗶𝘀𝗰𝗮𝗿𝗱 𝗶𝘁, 𝗳𝗮𝗹𝗹 𝗯𝗮𝗰𝗸 𝘁𝗼 𝘄𝗲𝗯 𝘀𝗲𝗮𝗿𝗰𝗵 With CRAG, the aforementioned Apache guide gets caught a milvus.io/blog/fix-rag-r… ted before it ever reaches the model — so generation only happens on context that fits the question. 𝗖𝗥𝗔𝗚'𝘀 𝗿𝗲𝘁𝗿𝗶𝗲𝘃𝗮𝗹 𝘀𝘁𝗲𝗽 𝗵𝗮𝘀 𝗮 𝗿𝗲𝗾𝘂𝗶𝗿𝗲𝗺𝗲𝗻𝘁 𝗼𝗳 𝗶𝘁𝘀 𝗼𝘄𝗻: 𝗶𝗻 𝗮𝗴𝗲𝗻𝘁 𝘀𝘆𝘀𝘁𝗲𝗺𝘀, 𝗲𝗮𝗰𝗵 𝘂𝘀𝗲𝗿 𝗼𝗿 𝘀𝗲𝘀𝘀𝗶𝗼𝗻 𝗻𝗲𝗲𝗱𝘀 𝗶𝘁𝘀 𝗼𝘄𝗻 𝗶𝘀𝗼𝗹𝗮𝘁𝗲𝗱 𝗺𝗲𝗺𝗼𝗿𝘆. 𝗠𝗶𝗹𝘃𝘂𝘀 𝗽𝗿𝗼𝘃𝗶𝗱𝗲𝘀 𝗲𝘅𝗮𝗰𝘁𝗹𝘆 𝘁𝗵𝗮𝘁 — 𝗶𝘁𝘀 𝗽𝗮𝗿𝘁𝗶𝘁𝗶𝗼𝗻 𝗸𝗲𝘆𝘀 𝗸𝗲𝗲𝗽 𝗲𝘃𝗲𝗿𝘆 𝘁𝗲𝗻𝗮𝗻𝘁'𝘀 𝗺𝗲𝗺𝗼𝗿𝘆 𝘀𝗲𝗽𝗮𝗿𝗮𝘁𝗲, 𝗮𝘂𝘁𝗼𝗺𝗮𝘁𝗶𝗰𝗮𝗹𝗹𝘆. 𝗟𝗲𝗮𝗿𝗻 𝗵𝗼𝘄 𝘁𝗼 𝘀𝗲𝘁 𝘂𝗽 𝗖𝗥𝗔𝗚 𝗵𝗲𝗿𝗲: https://t.co/iebI7W1lc6 💬 0 🔄 0 ❤️ 0 👀 35 ⚡