DEV Community

Zaima Sohail
Zaima Sohail

Posted on Originally published at Medium on

Is RAG Dead? Long Context vs Retrieval in Real Projects

Short answer: no. But the RAG most of us learned back in 2023, where you chunk everything, embed it, grab the top five chunks and hope, isn’t the automatic choice it used to be.

Every few months a model ships with a bigger context window and my feed fills up with “RAG is dead” posts. It happened when Gemini 1.5 Pro hit a million tokens. It happens again every time someone announces two million. And honestly, I get the appeal. No vector database, no chunking strategy to argue about, no reranker. Just paste the whole knowledge base into the prompt and let the model deal with it.

I’ve been building retrieval pipelines for my own projects, so I wanted to know if I was wasting my time. I went through the recent research (mostly 2025 and 2026), and this post is what I found: where each approach falls apart, what it actually costs, and how I now decide between them.

They’re not solving the same problem

I think a lot of the confusion comes from treating long context and RAG as two answers to one question. They aren’t.

A long context window is about how much the model can hold in its head at once. Basically working memory. RAG is about finding the right material before the model reads anything. That’s search.

Giving a model a bigger window doesn’t make it better at searching. You’ve just handed it a bigger haystack. Can it still find the needle? And can you afford to hand over that haystack on every single query? Those are the two questions that ended up shaping every design decision I made.

Where long context falls apart

The window size on the model card and the amount of context a model can actually use well are two different numbers. Three bits of research keep coming up.

Lost in the middle

This one is from 2023, by a Stanford team (Liu et al., later published in TACL). They found models pay attention to the start and end of a long prompt and tend to skip what’s in the middle. Plot accuracy against position and you get a U shape. The part that surprised me: in some multi-document tests, GPT-3.5-Turbo did worse with the documents than with no documents at all. Models built specifically for long context had the same problem.

Context rot

In 2025, Chroma ran a study on 18 frontier models, including GPT-4.1, Claude 4, Gemini 2.5 and Qwen3. All 18 got worse as the input got longer, even on simple tasks. Text that looked relevant but wasn’t made things worse still. So you can see a model with a 200K window start slipping at 50K. You don’t have to fill the window for it to happen.

Needle tests make models look better than they are

The classic needle-in-a-haystack test hides one fact in a long document and asks the model to find it. Models score close to 100%, and that’s the number you see in launch posts. NVIDIA’s RULER benchmark made the test harder, with multiple needles, tracing and aggregation, and only about half the models held up at 32K tokens, even though they claimed much more. Real questions look a lot more like RULER than like one planted fact.

So a bigger window is a limit, not a target. If you fill it up, you’re swapping a retrieval problem you can measure for an attention problem you mostly can’t.

The money and the waiting

I’ll be fair to long context here. If you can afford it, it often wins on accuracy. A controlled comparison from June 2026 (Hamilton et al.) had long-context prompting at 73.1% correct, against 65.4% for semantic RAG. The catch is that it cost 26 times more per query.

That 26x is what stops “just stuff it all in” from working in production. Here are some of the reported numbers in one place:

That last row comes from a vendor’s own benchmark, so take it with some salt. Still, the failure it describes is the one that worries me most. When the model read the PDFs directly, it often made up an answer if the information wasn’t there. The RAG setup just said “not found”. I’d much rather get that.

Prompt caching does close some of the gap if your documents don’t change much. You pay full price once and reuse the cached part cheaply after that. But any change to the knowledge base breaks the cache, so if your data updates every hour, caching won’t save you much.

When long context is the right call

RAG has a real weak spot: questions that need the whole document at once. Chunking chops the reasoning into pieces, and top-k retrieval only brings back the pieces that happen to look like the question. In these cases I’d reach for long context:

• One document, or a handful. Summarising a paper, reviewing a single contract, explaining one module of a codebase. If it fits easily, a retrieval layer just gives you more things that can go wrong.

• The answer is spread across the text. Something like “how does the argument shift between chapter 2 and chapter 7?”, or following a contract clause through every amendment. Chunk retrieval can’t see that kind of structure.

• Most of the corpus matters for most questions. One practitioner puts the tipping point at roughly 20%. If a typical query needs less than that share of your data, RAG usually wins. Above it, sending everything starts to make sense.

• You’re still prototyping. Pasting the documents in is the quickest way to find out what people actually ask, before you spend time building an index.

To be fair to the other side, a January 2025 paper (Li et al.) found long context generally beat chunk-based RAG on question answering. RAG still did better on dialogue-style and general questions, though, and retrieving summaries instead of raw chunks came out roughly even with long context.

How I decide now

These days I skip the big philosophical debate. I just go through a few questions about the data and the queries, and see which way each one points.

If the answers point in different directions, that usually means you want a mix of both. In my experience that’s most projects.

One more thing I’d pass on: test before you try anything clever. A 2026 study compared ten retrieval strategies on 23,088 financial queries. Plain BM25 keyword search beat state-of-the-art dense retrieval on that data, and tricks like HyDE query expansion barely helped with precise numerical questions (HackerNoon summary). An evaluation set built from your own queries will tell you more than any leaderboard.

What I actually build: retrieve first, then reason

Most of the setups I’d actually ship use retrieval to pick what goes into the context, and a long-context model to think about it. That way you keep RAG’s precision and low cost, and the model still gets to read whole sections instead of scraps.


hybrid RAG + long-context architecture

Here’s what each piece is for:

  1. Router. A cheap classifier, or one small LLM call, works out what kind of question came in. Precise lookups go to search. Questions that need a whole document go straight to the full text.

  2. Hybrid search. Use BM25 keyword search and dense embeddings together. Keywords catch exact names, codes and numbers, and embeddings catch paraphrases. Each one finds things the other misses.

  3. Rerank and order. A cross-encoder reranker picks the best few chunks. Then, because of the lost-in-the-middle problem, I put the strongest ones at the start and end of the prompt rather than in the middle.

  4. Cached core. The small, stable part of the knowledge base (policies, a syllabus, an API spec) can sit in a cached prompt prefix. You pay full price once, and after that it’s cheap.

  5. Bigger units. When a chunk matches, think about sending its whole section or parent document. Long context makes that affordable, and it fixes the annoying case where the answer was split across two chunks.

An example

Say you’re building a Q&A assistant for students over a course’s lecture notes, slides and assignment briefs. Plenty of us end up building something like this for a thesis or a portfolio.

• “When is assignment 3 due?” is a straight lookup. Hybrid search finds the brief almost instantly. If you sent the whole course instead, it would be slow and expensive, and the model would be more likely to mix up dates between assignments.

• “How does lecture 6’s explanation of attention build on lecture 2?” needs two full documents. Pull both lectures in completely and let the long-context model compare them.

• The syllabus and grading policy are short, rarely change and come up all the time. Keep them cached as a fixed prefix on every query.

None of these routes handles all three questions well by itself. Put together, they do, and the model only ever sees what that question needs.

So, is RAG dead?

No. The naive version might be, but the idea behind it is doing fine. What took its place is probably better called context engineering: for each query, deciding what the model should see and in what order.

If I had to boil it down: the context window is a limit, not something to fill. Long context can beat RAG on accuracy, but at around 26 times the token cost and with much slower responses, so do that math before you ship. RAG is search and long context is memory, and the systems I trust most use both. Most of the time the real bottleneck is retrieval quality, and a decent hybrid search with a reranker will usually do more for you than a bigger window.

And please build an evaluation set from your own users’ questions and test both approaches on it. The benchmarks I’ve cited here are only a starting point.

So the question I ask at the start of a project isn’t “RAG or long context?” anymore. It’s “what’s the smallest, cleanest context that can answer this?” Sometimes that’s the whole document. Usually it isn’t.

References

• Liu et al., Lost in the Middle: How Language Models Use Long Contexts, TACL 2024

• Chroma Research, Context Rot: How Increasing Input Tokens Impacts LLM Performance

• Hsieh et al. (NVIDIA), RULER: What’s the Real Context Size of Your Long-Context Language Models?

• Hamilton et al., The Token Tax of Epistemic Accuracy, June 2026

• Li et al., Long Context vs. RAG for LLMs: An Evaluation and Revisits, January 2025

• IntuitionLabs, Long-Context AI vs. RAG for Document Analysis Compared, September 2026

• Towards AI, RAG vs. Long Context in 2026: When Retrieval Still Wins

• Tian Pan, Long-Context Models vs. RAG: When the 1M-Token Window Is the Wrong Tool

• HackerNoon, Long Context Beats RAG on Accuracy — So Why Keep Retrieval?

• Algeria Tech News, The No-Stack Stack: Long-Context AI Architecture in 2026

• Poll the People, Is RAG Better Than a Large Context Window? (CustomGPT.ai benchmark)

Top comments (0)