Articles

RAG vs Long-Context LLMs: Do You Still Need It?

Retrieval-augmented generation and long context windows both feed an LLM more information — but they solve different problems and cost differently.

Chisato Chisato · · 4 min read
Abstract purple neural network fiber visualization

Retrieval-augmented generation (RAG) and long-context large language models both aim to give a model access to information beyond what it memorized during training, but they get there through opposite mechanisms — RAG fetches only the relevant slice of a much larger corpus at query time, while a long-context model simply accepts more raw text in a single prompt. Growing context windows have raised a real question: if a model can now read hundreds of thousands of tokens at once, do you still need retrieval at all?

What each approach actually does

Retrieval-augmented generation keeps your source material — documents, tickets, code, transcripts — outside the model, indexed in a vector database or search index. At query time, it retrieves the handful of passages most relevant to the question and inserts only those into the prompt. The model never sees the full corpus, just a curated excerpt of it.

A long-context model instead widens the context window itself — the total number of tokens the model can attend to in one call — and lets you paste in far more raw material directly, skipping the retrieval step entirely. Instead of choosing what’s relevant ahead of time, you hand the model everything and let its attention mechanism figure out what matters.

Where long context wins

Long context is genuinely simpler when the corpus is small enough to fit and the question benefits from seeing everything at once. Summarizing a single long document, reasoning across a handful of related files, or asking a question that requires connecting facts scattered non-locally through one continuous text — long context handles these well because nothing gets left out by an imperfect retrieval step. There’s no chunking to get wrong, no embedding model to choose, no risk that the one passage that actually answers the question scored just below the retrieval cutoff.

It also removes an entire subsystem: no vector store to maintain, no chunking strategy to tune, no re-indexing pipeline to keep in sync with source updates. For a prototype, an internal tool, or any corpus that changes rarely and fits comfortably in a single prompt, that simplicity is a real engineering win.

Where RAG still wins

Long context has three costs that don’t disappear as windows grow: money, latency, and precision.

Cost and latency scale with input size — a prompt with hundreds of thousands of tokens costs proportionally more per call and takes measurably longer to process than one with a few thousand, even before generation starts. Run the numbers for your own workload with a token cost calculator and the gap is usually stark once a corpus grows past what a handful of documents cover. RAG’s retrieval step keeps the actual prompt small regardless of how large the underlying corpus gets, because the corpus lives outside the context window entirely.

Precision degrades with scale in a way that isn’t obvious from benchmark scores alone: models attend less reliably to information buried in the middle of a very long context than to the same information near the start or end, an effect sometimes called “lost in the middle.” A well-tuned retrieval step, by contrast, puts only the relevant passages in front of the model, sidestepping the problem by never asking it to find a needle in a haystack it was handed whole.

Corpora that don’t fit at all — a company’s entire documentation set, a codebase with millions of lines, years of support tickets — are the clearest case: no context window, however large, holds all of it, so retrieval isn’t optional. RAG also updates cheaply: re-index a changed document and the next query sees it immediately, without re-sending the whole corpus. A reranker sitting after initial retrieval sharpens precision further by re-scoring the top candidates before they reach the model.

RAG vs long context

RAGLong context
Corpus size limitEffectively unboundedBounded by the context window
Per-query costLow — only relevant passages sentScales with total input size
LatencyLowerHigher on large inputs
Precision on scattered factsDepends on retrieval qualityDegrades toward the middle of very long inputs
Update costRe-index the changed documentRe-send the full corpus each time
Engineering overheadVector store, chunking, retrieval tuningNone beyond prompt construction
Best fitLarge, changing, or unbounded corporaSmall, static corpora; single-document tasks

They’re not actually mutually exclusive

In practice, many production systems use both: retrieval narrows an enormous corpus down to a candidate set, and a long context window gives the model room to consider more of those candidates at once than a tightly chunked RAG pipeline would allow — trading some of RAG’s cost savings for less brittle chunking. This differs from choosing RAG over fine-tuning, which is a separate decision about whether to bake knowledge into model weights at all versus keeping it external.

The takeaway

Long context windows have genuinely shrunk the set of problems that need retrieval — small, static corpora and single-document tasks are often simpler without a RAG pipeline at all. But they haven’t eliminated the need for it: corpora that don’t fit in any context window, workloads sensitive to per-query cost and latency, and frequently updated knowledge bases all still favor retrieval. Size your corpus, price out both options with real token costs, and let those numbers, not the size of the latest context window announcement, decide.

Chisato Chisato · · 4 min read

LangChain vs LlamaIndex: Choosing an AI Framework

LangChain is a general-purpose toolkit for chaining LLM calls and building agents; LlamaIndex is focused specifically on indexing and retrieving data for RAG.

#AI #LLMs #Developer Tools
Chisato Chisato · · 4 min read

What Is Prompt Chaining? Multi-Step LLM Pipelines

Prompt chaining splits a task into a sequence of smaller LLM calls, each one feeding the next, instead of asking one giant prompt to do everything.

#AI #LLMs #Developer Tools