Open source · Apache 2.0

Develop a RAG technique inside the full pipeline

Lasagna is a framework for retrieval-augmented generation. Write one pipeline stage, sweep it against the built-in components with every other stage held fixed, and read a significance-tested verdict.

pip install lasagna-rag
Code Docs

The paper · arXiv 2610.29722

Retrieval Augmented Generation Compositionality

  • 1IBM
  • 2Weizmann Institute of Science

Gains measured one technique at a time do not carry over: three retrieval techniques predicted a +47% NDCG@10 improvement together and delivered +17%.

Develop a technique

Write one stage. Test it in the full pipeline.

  1. Write one stage

    A technique can be a plain Python function. One decorator registers it as a component of its stage, interchangeable with every built-in. Decorators exist for rerankers, query enhancers, chunkers, embedders, retrievers, document processors and generators.

    Install
    pip install lasagna-rag
    my_ideas.py
    import lasagna
    
    @lasagna.reranker("keyword_overlap")
    def keyword_overlap(query, text):
        shared = set(query.split()) & set(text.split())
        return len(shared)  # score one passage
  2. Sweep it in a full pipeline

    Name your component next to a built-in in a sweep file. Each arm runs through the same pipeline with only that stage changed, and the run records what reached every stage. This sweep uses the speed profile, which needs no API key.

    sweep.yaml
    name: does keyword_overlap help
    benchmarks: [{name: smoke}]
    tracks: [retrieval]
    pipeline:
      base_profile: speed
      rerankers: [cross_encoder, "my_ideas:keyword_overlap"]
    n_runs: 1  # retrieval does not sample
  3. Read the verdict

    Run the sweep, then compare the arms on a benchmark. Each comparison gets a paired sign-flip test, with Holm correction across the sweep. An arm whose ranked lists never moved is flagged as inert.

    Run
    lasagna benchmark experiment sweep.yaml
    lasagna results significance "<output>/results.json" -m ndcg@10 --all
A real run with the idle waits cut: write a reranker, sweep it against a built-in, and get a Holm-corrected verdict.

In short

TL;DR

We pre-declare three hypotheses and test 450 configurations across eight benchmarks and corpora from 5K to 200K documents with LASAGNA, an open-source framework for controlled RAG evaluation.

  • Predicted +47%, realized +17%

    Retrieval gain (NDCG@10) predicted from the three strongest single techniques, versus what the combined pipeline delivers

  • Predicted +28%, realized +32%

    Faithfulness gain predicted one factor at a time, versus the best full pipeline: faithfulness gains carry over

  • 13.7%

    NDCG@10 gap at 200K documents for the design that leads at small corpora; the rank flip is visible from 25K

  • 450

    Configurations across eight benchmarks and corpora from 5K to 200K documents

Listen

Podcast

Two AI hosts talk through the study and the LASAGNA framework in 25 minutes. Below are the chapters, a full transcript, and the places where the episode differs from the paper.

Audio overview

Why Stacked RAG Components Fail

25 min 34 s · M4A, 12 MB · English

Made from the paper with NotebookLM. The hosts are AI voices and they paraphrase; where they differ from the paper, the paper is right. Speaker labels in the transcript were assigned automatically.

Chapters

Where the episode differs from the paper

The hosts get the main results right: 450 configurations, eight benchmarks, retrieval gains predicted at +47% that deliver +17%, faithfulness gains that carry over (+28% predicted, +32% realized), the four profiles, and the rank flip as the corpus grows. These are the places where they simplify or overstate.

  • "A mechanical conflict the paper calls functional duplication" ... "they just destroy each other's work."

    The paper uses "functional duplication" for HyDE combined with reranking. For MMR, it reports that MMR lowers NDCG@10 by 3.6% on these focused corpora, and that reranking already gives part of the benefit of turning MMR off. That is a partial overlap, not two methods canceling each other out. The hosts' account of why MMR hurts here matches the paper's hypothesis.

  • "About nine distinct stages" (and "the other eight stages", "nine-stage pipeline").

    LASAGNA has eight stages, so a swap holds the other seven fixed.

  • "It caches the exact intermediate outputs" ... "It guarantees at a mathematical level..."

    Each stage sits behind a fixed interface, and five automated isolation tests check that toggling one component does not change another. The ingested corpus is cached and reused when its settings match, so a retriever swap does not re-parse or re-chunk. This is tested, not proven mathematically.

  • "Paired statistical tests to prove..." ... "It mathematically verifies..."

    LASAGNA runs a paired sign-flip test, with Holm correction across a sweep. The test estimates how likely a gain is to be noise; it does not prove that a gain is real.

  • Agentic loops are "incredible for pushing that faithfulness score up."

    On a strong retrieval stack, the paper finds that adding an agentic loop gives only a negligible faithfulness gain, while retrieval quality and latency get worse.

  • "A snappy two-second response to a 14-second delay."

    Mean latencies in the paper: Speed 0.70 s, Standard 5.30 s, Balanced 12.25 s, Max-Reliable 14.16 s.

  • "A near 14% drop in search quality" (and "the system breaks", "plummets").

    13.7% is how far Balanced leads Standard at 200K documents (p = 0.003), as the hosts say correctly at 20:19. Standard declines gradually as the corpus grows (log-linearly); it does not break.

  • Post-retrieval merging "looks at multiple different search strategies like keyword matching and semantic vector similarity and mathematically fuses the results."

    Balanced adds a structured-graph merge after retrieval. Combining keyword and vector search (hybrid retrieval) is a separate setting that Balanced and Standard share, so it does not explain the gap between them.

The hosts also speak more strongly than the paper in general. Its results come from one constructed English multi-domain test bed, and every headline result uses proprietary generators.

Transcript

Also as plain text and captions (VTT). Speaker labels were assigned automatically from the audio and may be wrong on short replies. Select a chapter heading to play from there.

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.

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.

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.

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?

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.

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.

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.

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.

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.

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?

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.

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.

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?

Paper

Abstract

Retrieval Augmented Generation (RAG) grounds large language models in external knowledge. Modern pipelines combine embedding, chunking, retrieval, reranking, query augmentation, context compression, and agentic verification, yet these techniques are typically evaluated one at a time. It remains unclear whether their isolated gains survive composition, whether retrieval quality and answer faithfulness favor the same design choices, and whether conclusions from small corpora hold at large scale. We pre-declare three hypotheses and introduce Lasagna, an open-source framework for controlled RAG evaluation. We test 450 configurations across eight benchmarks and corpora ranging from 5K to 200K documents. Three findings emerge. First, individually strong techniques from different phases of a RAG pipeline do not necessarily compose: three retrieval techniques predict a +47% combined improvement but deliver only +17% when used together. Second, component gains stack differently for retrieval and faithfulness, and optimizing one can hurt the other. Third, the best composition changes as the corpus grows: the combination that wins on a small corpus may not remain best at large scale. These findings show that gains measured in isolation are not reliable predictors of realistic performance, and that new RAG techniques should be tested with the full surrounding stack. We call on researchers to do so and supply Lasagna to simplify these experiments.

Overview

The question

Modern RAG pipelines combine embedding, chunking, retrieval, reranking, query augmentation, context compression, and agentic verification, yet these techniques are typically evaluated one at a time. It remains unclear whether their isolated gains survive composition, whether retrieval quality and answer faithfulness favor the same design choices, and whether conclusions from small corpora hold at large scale.

The framework

LASAGNA

LASAGNA is an open-source framework for controlled RAG evaluation. Each stage sits behind a fixed interface, so swapping one method cannot silently change the implementation at another. Adding a new technique is a single line of code; the framework tests it inside a complete modern pipeline without reimplementing the surrounding stack. The release has eight swappable stages, from document processing to answer generation, and 55 built-in components.

LASAGNA overview: (a) seven functional blocks, (b) eight dimensions in a 167-configuration D-optimal design, (c) faithfulness versus latency for four operational profiles.
LASAGNA overview. (a) Seven functional blocks. (b) Eight dimensions in a 167-configuration D-optimal design. (c) Faithfulness versus latency for four operational profiles; faded points show other configurations.

Findings

Three findings

  1. Gains do not simply add up.

    Three retrieval techniques predict a +47% combined improvement but deliver only +17% together. Across 17 tested combinations the shortfall ranges from 7% to 72%, with a median of 41%.

  2. Retrieval and faithfulness favor different choices.

    Embedding, enrichment, and reranking dominate retrieval quality, whereas query augmentation and agentic gating dominate answer faithfulness, so optimizing one metric can hurt the other.

  3. The best composition changes with corpus size.

    The design leading at small corpora trails by 13.7% NDCG@10 at 200K, with a rank flip visible from 25K.

Composition

Predicted versus realized gains

Gain predicted by adding up separately measured improvements, versus the gain the combined pipeline delivers. Retrieval is NDCG@10 over the stock pipeline; faithfulness is relative to a reference configuration.

ComparisonMetricPredictedRealized
Three strongest retrieval techniques NDCG@10 +47% +17%
Best faithfulness components Faithfulness +28% +32%

Figures

Interactions and corpus scale

Heatmap of main effects and pairwise interactions across eight RAG pipeline factors, retrieval in the upper triangle and faithfulness in the lower triangle.
Main effects and pairwise interactions across eight RAG pipeline factors: retrieval (167 configurations, NDCG@10) in the upper triangle, faithfulness (122 configurations, RAGAS) in the lower triangle. Embedding and enrichment matter most for retrieval, whereas query augmentation and agentic gating matter most for faithfulness.
Retrieval NDCG@10 versus corpus size from 5K to 200K documents for four profiles.
Retrieval NDCG@10 versus corpus size (log scale), four profiles, 3 seeds per size. The design leading at small corpora trails by 13.7% NDCG@10 at 200K, with a rank flip visible from 25K.

Takeaway

What to do with it

New techniques should be tested in representative complete pipelines, on both metrics, and at the intended scale.

LASAGNA is released to make such studies practical and reproducible.

Release

What ships in Lasagna

The framework and evaluation harness from the paper, released under Apache 2.0.

In the release

Eight swappable stages
Document processing, chunking, embedding, query enhancement, retrieval, reranking, an agentic loop and answer generation. Swap one and the other seven stay fixed.
55 built-in components
Dense, BM25, SPLADE and hybrid retrievers. Cross-encoder, ColBERT, monoT5 and RankGPT rerankers. HyDE, Query2doc, step-back and RAG-Fusion. Self-Ask, IRCoT, FLARE, Adaptive-RAG and Self-RAG loops. Cited (ALCE) and chain-of-note answers. Plus chunkers, embedders and document processors. Each one that implements a published method names its paper.
Fair arms for chunkers and embedders
A chunker or embedder under test gets a corpus of its own, chunked or embedded by that component, so the comparison measures the component and not a shared index.
Stage isolation, checked
Each run records what reached every stage. If two arms differ at a stage neither of them names, the run says so. An arm whose ranked lists never moved is flagged as inert.
Paired significance tests
A paired sign-flip test with a t interval for each comparison, Holm correction across a sweep, and a 2×2 test of whether two techniques compound or overlap.
Serve it to your agent
An MCP server for Claude Code, Claude Desktop and Cursor (22 tools by default, none that deletes; 29 with --tools all), a REST API with an OpenAI-compatible chat endpoint, so any OpenAI client can answer from your documents, and a Docker stack for production on any of the six vector backends. The pipeline you measure is the pipeline you serve.
32 benchmarks, four metric families
BEIR, HotpotQA, SQuAD v2, MuSiQue, Natural Questions, MS MARCO and more, with 2WikiMultihopQA for multi-hop retrieval among distractors. Retrieval metrics; answer metrics with and without an LLM judge, including ALCE citation scores; and latency, tokens and LLM calls per query.

It reproduces published numbers

Before you trust a harness with your component, check it on methods whose numbers are already known. On the full SciFact and NFCorpus test sets, with nothing tuned, the dense models land within 0.002 NDCG@10 of MTEB, and BM25 followed by a cross-encoder within 0.004 of the BEIR paper. BM25 alone is within 0.008 of BEIR's multifield run, and 0.015 and 0.005 below its single-field run, which is how Lasagna indexes.

MethodSciFact, publishedSciFact, LasagnaNFCorpus, publishedNFCorpus, Lasagna
BM25 (k1 0.9, b 0.4)0.6650.6640.3250.317
all-MiniLM-L6-v20.6450.6450.3160.317
bge-small-en-v1.50.7130.7130.3430.344
BM25 + MiniLM-L6 cross-encoder0.6880.6850.3500.351

NDCG@10. Published: BEIR (Thakur et al., NeurIPS 2021, Table 2) and the MTEB results repository.

Rerun it in about half an hour, with no API key

Glossary

Terms

LASAGNA
An open-source framework for controlled RAG evaluation, in which each pipeline stage sits behind a fixed interface.
Answer faithfulness
Measures whether generated claims are supported by the retrieved context.
NDCG@10
The retrieval-quality metric; it follows the BEIR convention, with retrieved chunks de-duplicated by parent document ID before scoring.
Composition shortfall
How far a combined pipeline’s gain falls below the gain predicted from its techniques measured one at a time: a 63% shortfall for the three strongest retrieval techniques.

FAQ

Questions

Do RAG improvements measured one component at a time hold when the components are combined?

Not reliably. In a study of 450 configurations across eight benchmarks, three retrieval techniques that each helped on their own predict a +47% NDCG@10 improvement but deliver +17% when combined. Across 17 tested combinations the shortfall ranges from 7% to 72%, with a median of 41%. Faithfulness gains behave differently and transfer near-additively: +28% predicted, +32% realized. The study uses LASAGNA, an open-source framework for controlled RAG evaluation.

What is LASAGNA?

LASAGNA is an open-source framework for controlled evaluation of retrieval-augmented generation. Each pipeline stage sits behind a fixed interface, so swapping one method cannot silently change the implementation at another. Adding a new technique is a single line of code, and the framework tests it inside a complete modern pipeline without reimplementing the surrounding stack. The release has eight swappable stages and 55 built-in components. A sweep checks that its arms differ only in the stage they name, and it reports a paired significance test for each comparison. LASAGNA was used to test 450 configurations across eight benchmarks and corpora from 5K to 200K documents.

Which RAG methods does LASAGNA include?

The release ships 55 built-in components across eight stages, and each one that implements a published method names its paper. Retrievers: dense, BM25, SPLADE, and hybrid fusion by reciprocal rank or by normalized scores. Rerankers include cross-encoders, ColBERT, monoT5 and RankGPT. Query enhancers include HyDE, Query2doc, step-back prompting and RAG-Fusion. Agentic loops: Self-Ask, IRCoT, FLARE, Adaptive-RAG and Self-RAG; the last two prompt a general LLM where their papers train a model. Generators write concise, cited (ALCE), chain-of-thought or chain-of-note answers. Chunkers, embedders and document processors complete the set.

Does the best RAG pipeline on a small corpus stay the best at large scale?

Not necessarily. In a corpus-scaling sweep from 5K to 200K documents, the design leading at small corpora trails by 13.7% NDCG@10 at 200K, with a rank flip visible from 25K documents. Rankings from small-corpus ablations should therefore be rechecked at the intended corpus scale before a pipeline is chosen.

Do retrieval quality and answer faithfulness favor the same RAG design choices?

No. Across the factorial study, embedding, enrichment, and reranking dominate the retrieval-quality metric (NDCG@10), whereas query augmentation and agentic gating dominate answer faithfulness, which measures whether generated claims are supported by the retrieved context. Optimizing one metric can hurt the other, so new RAG components should be evaluated on both.

Which benchmarks does the study use?

Eight benchmarks unified into one multi-domain corpus: five BEIR sets for retrieval (NFCorpus, FiQA, SciFact, ArguAna, HotpotQA) and three question-answering sets for generation (SQuAD v2, HotpotQA, MuSiQue). Each configuration is evaluated on a retrieval track and an end-to-end generation track, with corpora scaled from 5K to 200K documents in the scaling study.

Cite

Citation

BibTeX
@misc{levy2026retrieval,
  title         = {Retrieval Augmented Generation Compositionality},
  author        = {Levy, Ido and Shlomov, Segev and Choshen, Leshem},
  year          = {2026},
  eprint        = {2610.29722},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CL},
  url           = {https://arxiv.org/abs/2610.29722}
}