Back to home

Compare

Comparing: RAG Retrieval Floods Context with 'Noise' — One Parameter Fix, No Model Swap & RAG检索把上下文塞满「废话」 — 改一行参数即可,不必换模型

AEN
RAGMMRLangChain·

RAG Retrieval Floods Context with 'Noise' — One Parameter Fix, No Model Swap

We noticed one detail: traditional retrieval in RAG systems (a technical architecture that lets AI answer questions based on an enterprise's internal documents) typically feeds all 5 "most similar" documents to the LLM at once—and those 5 documents all say the same thing. This is an old problem generating fresh buzz in the Chinese tech community: highly homogeneous retrieval results (essentially duplicated content) crowd out the context window (the hard cap on how much text the AI can process in a single pass), producing answers that are one-sided and hollow.

What this is

The core logic of RAG is "retrieve first, then answer": enterprise documents are chunked and stored in a vector database (a system that quickly finds documents by semantic similarity). At query time, the system retrieves the most similar chunks and hands them to the LLM, along with the question, to generate a response.

The trouble sits in those two words, "most similar." Top-K ranking (taking the top K results by similarity score) compares similarity scores only—not whether the documents duplicate each other. The result: the context window gets stuffed with information from a single dimension, while other dimensions never make it in. The original piece gives a blunt example: a user asks "how to pick a laptop," and traditional retrieval returns 5 documents, every one of which talks about the CPU.

MMR (Maximal Marginal Relevance) is the engineering community's answer. Its scoring is direct: relevance score minus redundancy score, with a λ parameter balancing the two. Setting λ to 0.5 is the industry's default sweet spot. Using mainstream frameworks like LangChain, developers can change three lines of configuration—enable mmr search, set fetch_k=20, lambda_mult=0.5—and achieve cross-dimensional coverage in the retrieval results. No need to swap embedding models or re-chunk documents.

Industry view

The supporting case is blunt: MMR is a high-ROI, low-cost optimization. The original author writes, "just turning on MMR and tuning parameters sensibly optimizes generation quality at the root."

But there are reservations. First, λ has no universal value. The same parameters that work perfectly in a customer support scenario can miss key evidence in contract review; LangChain's official documentation cautions: "MMR is not a replacement—it's a supplement. Using it for single-point fact queries actually hurts precision." Second, higher retrieval diversity doesn't automatically translate to better final answer quality—the downstream LLM's own integration capability sets the ceiling on MMR's returns. Third, the article's example is "picking a laptop," which is far simpler than real business scenarios; parameter tuning still requires domain-expert involvement.

In other words: MMR solves a class of problems, but it doesn't replace understanding the business.

Impact on regular people

For enterprise IT: If you're planning or have already launched a knowledge-base Q&A AI product, retrieval quality is a more common bottleneck than your model choice. We recommend first auditing whether your retrieval results are heavily redundant—don't rush to swap in a more expensive LLM.

For individual professionals: When using AI to read reports or look up information, if it feels "too narrow," the problem may not be that the AI isn't smart—it's that the materials it received are narrow. Rephrasing the question or adding "please analyze from multiple angles" is a low-cost user-side workaround.

For the consumer market: MMR is the "underwater iceberg"—the optimization happens on the retrieval backend, invisible in the UI. Still, enterprise AI customer service and advisory bots will become more accurate and comprehensive as a result, and that dividend ultimately flows back to consumers.

Source: juejin.cn
BZH
RAGMMRLangChain·

RAG检索把上下文塞满「废话」 — 改一行参数即可,不必换模型

我们注意到一个细节:RAG系统(让AI基于企业内部文档回答问题的一种技术架构)的传统检索方式,常把5条「最相关」的文档一并喂给大模型——结果这5条全在讲同一件事。这是中文技术社区最近讨论得热闹的一个老问题:检索结果高度同质化(彼此内容雷同),挤占上下文窗口(AI每次能处理的文本长度有上限),让AI回答片面、空洞。

这是什么

RAG的核心逻辑是「先检索、再回答」:企业文档被切片后存入向量数据库(一套按语义相似度快速查找文档的系统),提问时系统找出最相似的几段,连同问题一起交给大模型生成答案。

问题出在「最相似」三个字上。Top-K排序(按相似度从高到低取前K条)只比相似度分数,不比文档之间是否重复。结果上下文窗口被同一维度信息塞满,其他维度反而进不来。原文给了一个直白例子:用户问「怎么挑笔记本」,传统检索返回的5条文档,条条都在聊CPU。

MMR(最大边际相关性)是工程界给出的答案。它的打分很直接:相关分减重复分,配合一个λ参数平衡两者。λ调到0.5,是业界默认最优点。用LangChain这类主流框架,开发者改三行配置——开启mmr搜索、设fetch_k=20、lambda_mult=0.5——就能让检索结果跨维度覆盖,不必换嵌入模型、不必重新切片。

行业怎么看

赞成的声音很直白:MMR是低成本高收益的优化。原作者写道,「只开MMR、合理调参,就能从根源上优化生成效果」。

但也有保留意见。第一,λ没有万能值。同样参数在客户支持场景恰好,在合同核验场景就可能漏掉关键证据;LangChain官方文档提醒:「MMR不是替代品,是补充品,单点事实查询用它反而拖累精度」。第二,检索多样性提升,不必然带来最终答案质量提升——下游大模型本身的整合能力,决定了MMR收益的天花板。第三,文章举例是「选笔记本电脑」,现实业务场景远比这复杂,参数调优仍需业务专家介入。

换句话说:MMR能解决一类问题,但不能替代对业务的理解。

对普通人的影响

对企业IT:若正打算或已上线知识库问答类AI产品,检索质量是比模型选型更常见的瓶颈。建议优先排查检索结果是否大量重复,不必急着更换更贵的大模型。

对职场个人:用AI读报告、查资料时若觉得「答得太窄」,问题未必是AI不聪明,而是它拿到的资料本身就窄。换个问法、补一句「请从多个角度分析」,是用户侧的低成本补救。

对消费市场:MMR是「水下冰山」,优化发生在检索后端,用户界面无感。但企业用的AI客服、咨询机器人,会因此变得更准确、更全面,这股红利最终会回流到消费端。

Source: juejin.cn