Why Stacked RAG Components Fail An AI-generated conversation about the paper "Retrieval Augmented Generation Compositionality" and the Lasagna framework. Made with NotebookLM. It paraphrases the paper; where they differ, the paper is right. Paper: https://arxiv.org/abs/2610.29722 Code: https://github.com/dolev31/lasagna Speaker labels were assigned automatically from the audio and may be wrong on short replies. [00:00] The gains that vanish Host 1: So imagine you add three brand new upgrades to a piece of software you're building. Host 2: Right. Host 1: You know, you read the documentation, you look at all the industry benchmarks, and, well, each individual upgrade promises this massive boost in capability. Host 2: Oh, yeah. They always do on paper. Host 1: Right. On paper. If you add their individual scores together, they should equal like a 47% improvement in performance. Host 2: A huge jump. Host 1: Exactly. So you compile the code, you turn the system on, and you only get a 17% boost. I mean, almost two-thirds of the expected performance just completely vanished. Where did it actually go? Host 2: It is honestly a developer's absolute worst nightmare. Host 1: Yeah, I bet. Host 2: You know, you source the absolute best components available, you verify them individually, you string them all together, and the final math simply refuses to add up. Host 1: Like 1 plus 1 equals 1.5. Host 2: Exactly. This system somehow becomes like less than the sum of its parts. Host 1: And that disappearing math problem is really the core of our deep dive today. We are looking at this heavily discussed new paper. It's titled Retrieval Augmented Generation Compositionality. Host 2: Such a mouthful. Host 1: It is, yeah. And we're also looking at its companion, which is this brand new open source framework called Lasagna. Host 2: Which is a much better name. Host 1: Way better name. So our mission today, for you listening, is to pull back the curtain on how developers are currently building AI systems. Explore why the tech industry's standard method of testing these setups is, well, fundamentally broken. Host 2: Completely broken, yeah. Host 1: And break down how this Lasagna framework can prevent some truly catastrophic failures before an AI application ever reaches the public. Host 2: Yeah, because the findings in this study, they really require a massive shift in how we approach reliable AI. Host 1: It's not just a small tweak. Host 2: No, not at all. The researchers didn't just run a handful of quick isolated tests. They engineered an incredible 450 unique configurations. Host 1: 450. That's a lot of testing. Host 2: Right. And they did it across eight different benchmarks and then scaled those tests from a baseline of 5,000 documents all the way up to 200,000 documents. Host 1: Okay, wow. Before we jump into those massive numbers, though, we should probably set the table for anyone listening who might be checking out this project for the first time. Host 2: Good idea. [02:09] What RAG is Host 1: Because we are talking about RAG today, Retrieval Augmented Generation. Let's make sure we clearly define the mechanics of what that actually is. Host 2: Yeah, keep it simple. Host 1: Right. So the simplest mental model is that it's like giving an AI an open book test. Host 2: I love that analogy. Host 1: Thanks. Because, you know, if you ask a standard language model a really highly specific question, it might confidently hallucinate and just completely make up a fake answer. Host 2: Right. It just guesses based on vibes, basically. Host 1: Exactly. RAG prevents that by, well, bolting a search engine onto the AI. You ask a question, the system searches a private, trusted database, retrieves the relevant documents, hands them to the AI, and basically says, answer the user's question using only the information in these specific pages. Host 2: Right. So it forces the language model to ground its response in external verified reality. Host 1: Instead of just making things up. Host 2: Exactly. Rather than relying on the statistical guesswork of its training data. And the ultimate takeaway from this massive study is that building a successful RAG pipeline is not about stacking the, quote unquote, best individual components on top of each other. Host 1: Right, which is what everyone tries to do. Host 2: Right. But it's actually entirely about the specific interactions between those components. Host 1: Okay, let's unpack that. Host 2: Okay. [03:25] Testing one component at a time Host 1: Because that specific problem that is actively breaking RAG pipelines today, the paper gives it a very specific name. Host 2: Yeah, the isolated testing problem. Host 1: The isolated testing problem, right. Right. Because from what I gather, the current culture of AI development treats every new upgrade like it exists in a total vacuum. Host 2: A hundred percent. Host 1: Like a researcher invents a new way to chunk text into smaller pieces or, you know, a new reranking algorithm to sort search results. They plug their one new invention into a bare bones basic pipeline, measure it, and then they publish a paper saying, hey, performance went up 10 percent. Host 2: Right. And then a second researcher builds a completely different component, tests it in their own isolated basic pipeline, and they claim like a 15% increase. Host 1: Okay, so it's like a general manager trying to build a championship football team by just buying five-star quarterbacks. Host 2: That is exactly what it's like. Host 1: Because individually on their own practice fields, they all throw perfect spirals. They have amazing stats, but you put all five of them on the field at the exact same time and they literally trip over each other. Host 2: Because nobody is playing receiver. Host 1: Exactly. The playbook shatters because nobody is blocking the line. [04:29] Two metrics: retrieval and faithfulness Host 2: That sports analogy maps perfectly to the paper's first major hypothesis, actually. When the researchers looked at the data, they separated the performance of these pipelines into two primary metrics. Host 1: Okay, what are the two metrics? Host 2: So the first metric is retrieval. Basically, did the search engine side of the system actually find the correct document in the database? Host 1: Got it. Host 2: Did we find the needle in the haystack? Host 1: Right. Host 2: And the second metric is faithfulness. Did the text generation side of the AI actually answer honestly based only on the facts in that specific document without hallucinating? Host 1: So it breaks down into finding the truth and then strictly adhering to the truth. Host 2: Beautifully said, yes. And the researchers dropped some specific numbers here that made the entire AI community just like double take. Host 1: This is the math problem from earlier, right? Host 2: Exactly. They took the three strongest single retrieval improvements they could find. Measured in isolation, these three upgrades predicted a massive 47% gain in retrieval quality. Host 1: 47%, which is huge. Host 2: Massive. And they measured this using a metric called NDCG@10, which essentially scores a system based on whether the absolute most relevant documents show up in the top 10 search results. Host 1: Kind of like page one of Google? Host 2: Yeah, exactly. Giving way more weight to the number one spot. But when they compiled those three specific improvements into the exact same pipeline, Host 1: Let me guess. It didn't equal 47%. Host 2: Not even close. The combined system only realized a 17% gain. Host 1: Wow. So that is that 63% shortfall we talked about at the start. The performance gains just completely evaporated? Host 2: Just poof. Gone. Host 1: But, you know, the twist in the paper is that this evaporation didn't happen everywhere, right? Host 2: Right. Host 1: Because when they looked at the other metric, faithfulness, the gains mostly did add up. Host 2: They did, yeah. Host 1: Separately measured faithfulness upgrades predicted a 28% gain. And when combined, the pipeline actually secured a 32% gain. Host 2: Yeah, they overperformed on that side. Host 1: I have to pause and challenge the mechanics of that, though. Why would one metric stack beautifully, but the other metric just completely cannibalize itself? Host 2: It's a great question. Host 1: Like, if the retrieval parts trip over each other, why do the faithfulness parts cooperate so perfectly well? [06:46] Why retrieval gains overlap Host 2: So it comes down to a mechanical conflict the paper calls functional duplication. Host 1: Functional duplication. Okay, what does that mean? Host 2: Think about what happens mathematically when you combine two really advanced retrieval techniques. Let's say a developer uses a cross-encoder reranker. Host 1: Okay. Host 2: Its entire function is to act as a strict quality filter. It takes the initial search results, analyzes the really complex semantic relationship between the user's question and each document, and aggressively filters for pure, absolute relevance. Host 1: So it's pushing the very best matches to the top. Host 2: Exactly. Host 1: So it's like a sniper rifle for relevance. Host 2: That's a great way to put it. But then that same developer reads an article suggesting they also activate a technique called MMR, which stands for maximal marginal relevance. Host 1: Okay. What does MMR do? Host 2: MMR's mathematical function is to force diversity in the search results. Host 1: Oh. Oh, I see where this is going. Host 2: Yeah. It calculates a penalty based on how similar a document is to the ones already retrieved, ensuring you don't just get 10 documents saying the exact same thing. Host 1: Right. So I see the collision happening here. You ask the system a highly specific, complex question. The initial search finds five excellent documents that all contain the exact right answer. Host 2: Right. And the cross-encoder analyzes them and says, these five are perfectly relevant. Put them in spots one through five. Host 1: But then the MMR kicks in. Host 2: Exactly. The MMR algorithm immediately kicks in and applies a mathematical penalty. It basically says, no, no, documents 2, 3, 4, and 5 look too statistically similar to document 1. Host 1: Wow. Host 2: We are going to demote them and replace them with wildly different topics just for the sake of variety. Host 1: That is wild. Host 2: Right. The MMR accidentally hides the exact corroborating evidence you desperately need. because it literally punishes documents for agreeing with each other. Host 1: So by adding a so-called best practice component, developers are actively breaking their own systems because the underlying algorithms just have completely conflicting goals. The cross-encoder is optimizing for pure relevance while the MMR is optimizing for diversity, and they just destroy each other's work. Host 2: They directly interfere. On the faithfulness side, however, like adding a step that prompts the AI to verify facts before generating the final text, those components operate at entirely different stages of the pipeline. Host 1: Oh, I see. Host 2: Yeah, one might check the formatting, another might check the source citations. They don't mathematically overlap, so their benefits are actually allowed to compound. [09:26] Lasagna and stage isolation Host 1: Okay, so if combining these best parts blindly just cannibalizes performance on the retrieval side, developers are essentially flying blind. How do we actually isolate the variables to see what's actually causing the failure? Host 2: Well, you need a framework that can test the entire system holistically, but with strict mathematical controls over every single variable. Host 1: And that is the motivation behind the Lasagna framework introduced in the paper. Host 2: Exactly. Host 1: But, you know, if I'm a developer listening to this or someone managing an AI project, I might be pushing back a little. I might be thinking, hey, I already used orchestrators like LangChain or LlamaIndex to build my applications. Why do I need to integrate this entirely new Lasagna tool? Host 2: It's a fair question, but Lasagna is not an orchestrator trying to replace LangChain or LlamaIndex. Host 1: Okay, so what is it? Host 2: It functions as a diagnostic and evaluation layer. Its primary superpower is a mechanism called stage isolation. Host 1: Stage isolation. Let's break down the mechanics of that, because a standard modern RAG pipeline has about nine distinct stages, right? Host 2: Roughly, yeah. Host 1: You parse the document, you chunk the text into smaller pieces, you embed those chunks into mathematical vectors, you retrieve them, you rerank them, and so on. Host 2: Right. And typically, if you change a component early in that pipeline, the data outputs change completely, cascading down and suddenly altering how every subsequent stage performs. Host 1: Which ruins the test. Host 2: Exactly. Lasagna stops that cascade. It lets you swap out exactly one pipeline stage, say you want to test a brand new retrieval algorithm, while strictly holding the other eight stages completely fixed. Host 1: But how does it actually hold them fixed? Like, does it just save the outputs? Host 2: Exactly. It caches the exact intermediate outputs. Host 1: Oh, wow. Host 2: Yeah, it saves the specific mathematical vectors, the precise chunk boundaries, literally everything into a database. Host 1: So it's basically freezing time for the rest of the pipeline. Host 2: Yes. When you run your test on the new retriever, Lasagna doesn't rerun the document parser or the chunker. It feeds the new retriever the exact same cached data bytes that the old retriever used. Host 1: That's brilliant. Host 2: It guarantees at a mathematical level that swapping one method cannot silently change the implementation of another stage downstream. You know for a fact whether your new component actually caused the improvement or if it was just, you know, a fluke in the pipeline's overall machinery. Host 1: It eliminates the guesswork entirely. [11:50] Cost, configurator, significance tests and MCP Host 1: And what really stands out in the paper is how accessible this level of rigorous testing is for production teams. Host 2: Oh, absolutely. Host 1: Like the researchers noted that running their massive experimental sweep, evaluating 450 different configurations and mapping out all those complex interactions, cost them about $5,200 in cloud compute. Host 2: Which is nothing, really. Host 1: And it took around 310 hours. I mean, $5,200 is a rounding error for an enterprise deployment. Host 2: A completely lean development team can utilize this framework to scientifically validate their bespoke pipeline before they ever expose it to real customers. Host 1: Let's walk through some of the practical features the framework offers, because for anyone building these systems, this just seems like an essential toolkit. First, they built a RAG configurator UI, right? Host 2: Yes, the UI is great. Host 1: So instead of writing endless lines of complex YAML configuration files to test every single hypothesis, developers can build and tune the entire nine-stage pipeline visually. Host 2: Directly in a browser window. Host 1: That saves so much time. Host 2: It really does. And beyond the visual interface, Lasagna includes built-in significance testing. Host 1: Oh, nice. Host 2: Yeah, when you run an evaluation, it doesn't just output a new score and leave you to interpret it. It runs paired statistical tests to prove that, say, a 3% gain in performance isn't just random statistical noise. Host 1: It mathematically verifies if the improvement is real and repeatable. Host 2: Exactly. Host 1: But the feature that really, I think, changes the deployment game is the MCP server integration. Host 2: Oh, for sure. Host 1: Because MCP stands for Model Context Protocol. And from what I understand, this allows you to hook your perfectly tuned Lasagna tested knowledge base directly into an AI agent. Host 2: Immediately. Yeah. Host 1: So that agent can then use your validated database as a tool instantly. You don't have to write custom API bridges or, you know, complex integration code. Host 2: No, you just point the agent at the Lasagna server. Host 1: And your agent immediately has access to flawless, thoroughly tested recall capabilities. Host 2: It really just removes the friction between evaluating a theoretical pipeline and actually deploying it into a real production environment. [13:53] No best configuration: the four profiles Host 1: So with this Lasagna tool built, the researchers unleashed it on all those configurations. And the obvious question anyone reading the paper wants answered is, well, what is the ultimate, objective, best configuration they discovered? Host 2: And that's the kicker. The paper's second major hypothesis reveals that an objective best configuration does not exist. Host 1: It just doesn't exist. Host 2: No. RAG pipelines are bound by a brutal Pareto tradeoff. Host 1: Okay, a Pareto tradeoff, meaning you are forced to make a sacrifice somewhere. You cannot optimize every metric simultaneously. Host 2: Exactly. You absolutely cannot have the fastest processing speed, the highest retrieval quality, and the most rigorous faithfulness all at the exact same time. Host 1: You have to choose. Host 2: You are forced to pick your priorities based on the specific use case of your application. Host 1: And to help navigate that tradeoff, the framework provides four out-of-the-box profiles, right? The researchers essentially did all the heavy lifting to find the optimal points on that Pareto curve. Host 2: They did, yeah. Host 1: So let's go through them. The first is the Speed profile. Host 2: Right. Host 1: And this strips out the heavy machinery, from what I understand. It uses smaller vector embeddings, drops the complex reranking stages entirely. It is lightning fast. We're talking processing queries in about 0.7 seconds. Host 2: Super fast. Host 1: But it takes a noticeable hit on complex retrieval quality. Host 2: Right. Now, on the other end of the baseline spectrum is the Standard profile. This uses a very direct traditional retrieval route, and surprisingly on smaller data sets, it actually wins at pure retrieval quality. Host 1: Oh, really? Host 2: Yeah. It excels at finding the exact right documents efficiently without overcomplicating the search. Host 1: Okay. Moving up the complexity curve is the Balanced profile. This acts as the sweet spot for most production environments. It introduces some advanced techniques to maintain accuracy as the system scales up, which we will detail in just a moment. Host 2: Yeah, that one is key. And finally, we have the Max-Reliable profile. Host 1: The heavy hitter. Host 2: Exactly. This profile utilizes extreme verification to ensure very high faithfulness. It aggressively double checks its own work, often making multiple calls to the language model just to verify claims and prevent hallucinations. Host 1: But there's a cost, right? Host 2: A massive latency hit, averaging around 14 seconds per single query. Host 1: Wow. 14 seconds of waiting for an answer is, I mean, that's an eternity in software. Host 2: It really is. [16:16] The cost of agentic loops Host 1: And that actually brings up a critical production tip we need to discuss for you guys listening. Because a lot of developers right now are currently obsessed with integrating agentic loops into their systems. Host 2: Oh, yeah. The current hype. Host 1: Architectures like CRAG, which stands for Corrective RAG, or Self-RAG, the concept is that the AI acts like an autonomous agent. It retrieves a document, grades the relevance of that document, and if it decides the information is insufficient, it loops back, rewrites its own search query, and tries again. Host 2: I mean, the theory sounds flawless, right? Host 1: It does. But the paper raises a vital warning about the hidden costs of these agentic loops. While they are incredible for pushing that faithfulness score up, the tradeoff is just severe. Host 2: You absorb that massive latency cost. Host 1: You're jumping from a snappy two-second response to a 14-second delay while the AI, like, argues with itself in the background. Host 2: But the delay is one thing. Host 1: The paper implies it gets worse than just being slow. Agentic loops can actually reduce the overall quality of the information retrieved, which I struggle to understand. How does double-checking your work mathematically make you worse at finding the right information? Host 2: It is entirely due to how aggressively these agentic systems filter the context. Host 1: Okay, how so? Host 2: In an effort to be perfectly faithful, an agentic loop will look at a retrieved chunk of text and ask a binary question, like, does this fully answer the user's query? Host 1: Just yes or no. Host 2: Right. Right. So if the user asks a complex multi-step question, a single chunk of text might only contain a partial clue, perhaps just a bridge fact needed to connect two larger ideas. Host 1: Okay, I see. Host 2: The strict agentic gate will often label that partial clue as irrelevant and just throw it away. It aggressively filters out the necessary context chunks, effectively starving the final generator of the nuances it needs to construct a complete comprehensive answer. Host 1: Wow. So it's analogous to like a strict editor going through a mystery novel and deleting all the subtle setup and character motives just because they aren't the final clue that solves the murder. Host 2: Exactly. Host 1: By the time you get to the end, the solution makes absolutely no sense because all the bridging context was just thrown out. Host 2: Exactly. You really only implement these heavy agentic loops if your specific application demands absolute baseline factual accuracy at the expense of speed and comprehensive nuance. Host 1: Good to know. [18:45] Corpus size and the rank flip Host 1: So let's assume a development team has weighed these tradeoffs. They review the four profiles and decide to go with the Standard profile. It's fast, and on their initial test data set of, say, 5,000 documents, it achieved the absolute best retrieval score. Host 2: Makes sense. Host 1: They test it, it works beautifully, and they prepare to deploy. But what happens when that company actually scales their application up? Like, they move from the 5,000 document test database to a massive 200,000 document enterprise deployment. Host 2: And this brings us to the third major hypothesis of the paper. And it is where a significant number of teams encounter catastrophic surprises in production environments. Host 1: Because most RAG testing out there today is done on what the industry calls toy benchmarks, right? Host 2: Toy benchmarks. Host 1: These are small, pristine data sets of 5,000, maybe 10,000 documents. But real enterprise businesses have hundreds of thousands or millions of interconnected documents. When we push that winning Standard profile into a database of 200,000 documents, the system breaks. Host 2: Completely. A complete rank flip occurs. Host 1: A rank flip. Host 2: Yeah, the performance rankings literally invert as the corpus size grows. At 5,000 documents and even scaling up to 15,000 documents, the Standard profile is the undeniable winner. It finds the needle in the haystack with extreme efficiency. Host 1: Right. Host 2: But right around 25,000 documents, a crossover begins. Host 1: The Standard profile starts choking on the volume. Host 2: By the time the database expands to 200,000 documents, the Balanced profile completely takes over the leaderboard. It outperforms the Standard profile by a massive 13.7% in pure retrieval quality. Host 1: Wait, a near 14% drop in search quality? That is a massive degradation. What specific mechanism is breaking inside the Standard profile at that scale? [20:36] Distractors, hierarchical chunking and merging Host 2: It fundamentally comes down to distractors. Host 1: Distractors. Host 2: Yeah. In a small database, finding the right document is relatively straightforward because there are just fewer competing concepts. But at 200,000 documents, you introduce a massive pool of distractors. Host 1: Irrelevant stuff. Host 2: Thousands of completely irrelevant documents that happen to use the exact same keywords sound highly relevant to the basic algorithm, but are actually discussing something else entirely. Host 1: So they are mathematically tricking the basic search engine. Host 2: Precisely. The Standard profile relies on a simpler, more direct retrieval mechanism, and it just gets overwhelmed by this ocean of noise. Its accuracy plummets as the database grows. The Balanced profile, however, maintains a flat, robust trajectory. Host 1: But if the noise is tricking the system, how does the Balanced profile survive it? It must be filtering the noise in a way the Standard profile is incapable of, right? Host 2: It survives because it utilizes advanced scale-resistant architectural techniques. Specifically, it employs post-retrieval merging and hierarchical chunking. Host 1: Okay, let's break those down. Post-retrieval merging. Host 2: With post-retrieval merging, it doesn't just rely on one search method. It looks at multiple different search strategies like keyword matching and semantic vector similarity and mathematically fuses the results together, basically cross-referencing them to weed out the distractors. Host 1: That makes a lot of sense. And what about the hierarchical chunking? Host 2: So hierarchical chunking fundamentally changes how the AI understands context. Normally, if you chunk a document into single paragraphs, the AI might retrieve a paragraph that says the company saw a 20% drop. Host 1: Right, but out of context, that is totally meaningless. Which company, which quarter? Host 2: Exactly. Hierarchical chunking keeps track of the parent-child relationships in the data. If the AI flags that small paragraph as relevant, the system retrieves the entire parent section or chapter and feeds that larger context to the language model. Host 1: I see. Host 2: These mechanisms act as a heavy anchor, preventing the system from being swept away by irrelevant distractors. Host 1: So the takeaway for anyone interacting with this project is critical. Never trust a small-scale benchmark if you are architecting a large-scale application. Host 2: Never. Host 1: The pipeline that appears to be your objective best on a toy data set might actually be incredibly fragile when exposed to real-world scale. Your absolute winner at 5,000 documents will likely become your biggest liability at 200,000. Host 2: It invalidates a significant portion of how the industry is currently choosing AI architectures. Validating at your target scale is not optional. It is an engineering requirement. [23:15] Three lessons Host 1: Okay, so to pull all of these insights together, for anyone building, managing, or utilizing AI systems, the lessons from the RAG compositionality paper and the Lasagna framework are essential. Host 2: Let's summarize. Host 1: First, you must test your systems end-to-end, holding variables strictly isolated, because gains do not automatically stack. Functional duplication will actively cannibalize your performance. Host 2: Right. Host 1: Second, you have to balance your metrics. You are operating on a strict Pareto curve, and you must choose your tradeoff between retrieval quality, faithfulness, and latency based on your actual real-world use case. Host 2: No magic bullets. Host 1: And finally, always validate your pipeline at the massive scale you actually intend to deploy it at. Host 2: The overarching theme here is the necessary transition from educated guesswork to rigorous, mathematically accountable engineering. Host 1: Absolutely. [24:09] Stronger generators and lighter pipelines Host 2: Now, before we close out this deep dive, there is one final really thought-provoking observation from the researchers that we need to address. Host 1: Yes. Host 2: During the massive sweep of tests, the study documented a fascinating pattern regarding the language models themselves. Host 1: Okay, what was it? Host 2: They found that utilizing a stronger, vastly more advanced underlying LLM generator, like a smarter core AI, can actually partially substitute for a heavy, complex RAG pipeline. Host 1: Really? Host 2: Yeah. If the underlying model possesses stronger reasoning and processing capabilities, it requires significantly less hand-holding from the complex retrieval machinery. Host 1: Man, that presents a massive architectural question for the future of AI development. Host 2: It really does. Host 1: Because as raw models continue to evolve, becoming vastly more intelligent, capable of reasoning through noise and holding massive context windows, will all of this intricate RAG machinery eventually become obsolete? Host 2: It's the big question. Host 1: Or regardless of how intelligent the raw AI becomes, will we always require strict diagnostic frameworks like Lasagna to act as the ultimate librarians, forcing the AI to prove its work and remain grounded in verified truth? Host 2: It highlights the ongoing tension between raw computational intelligence and the strict necessity of factual verification. Host 1: It is definitely something to keep in mind the next time you ask an AI a question and have to wonder, how exactly did it arrive at that answer?