Is RAG Still Needed? Choosing the Best Approach for LLMs

Martin Keen compares Retrieval Augmented Generation (RAG) with the emerging long context window approach in LLMs. He analyzes the pros and cons of each, from infrastructure simplicity and retrieval accuracy to computational costs and the 'needle in the haystack' problem, providing guidance on when to use each solution.

4 min read
Is RAG Still Needed? Choosing the Best Approach for LLMs
source: https://www.youtube.com/watch?v=UabBYexBD4k

Large Language Models (LLMs) are inherently static, with knowledge frozen at their last training date. They are unaware of recent events or private, proprietary data. The central challenge is context injection: getting the right data into the model at the right time. Two primary architectural patterns have emerged to solve this problem: Retrieval Augmented Generation (RAG) and large context windows.

Two Approaches to Context Injection

1. Retrieval Augmented Generation (RAG)

RAG is an engineering-centric approach that externalizes knowledge from the LLM. The process involves:

  1. Indexing: Ahead of time, documents (PDFs, code files, etc.) are broken down into smaller pieces or “chunks”.
  2. Embedding: An embedding model converts these chunks into numerical vector representations.
  3. Storage: These vectors are stored in a specialized vector database.
  4. Retrieval: When a user submits a query, the system performs a semantic search on the vector database to find the most relevant chunks.
  5. Augmentation: These retrieved chunks are injected into the LLM’s context window along with the original user prompt, providing the model with the necessary information to form an answer.

The critical dependency of this system is the reliability of the retrieval logic; its effectiveness hinges on the hope that the semantic search finds the correct information.

2. Long Context Windows

This is a more “brute-force,” model-native solution. It bypasses the external infrastructure of RAG (embedding models, vector databases) entirely.

  • The process is simple: take the source documents and place them directly into the context window along with the user’s prompt.
  • The model’s own internal attention mechanism is then responsible for finding the relevant information within the provided text.

This method was historically impractical due to the tiny context windows of early LLMs (e.g., 4,000 tokens). However, modern models now feature massive context windows, some exceeding a million tokens (roughly 700,000 words), making this approach viable and forcing a re-evaluation of LLM architecture.

The Case for Long Context: Is RAG Obsolete?

The primary argument for using long context windows is simplicity. If all necessary data can fit into the prompt, it may eliminate the need for the complex machinery of RAG.

  • Collapsing the Infrastructure: A production RAG system is heavy, involving numerous components: a chunking strategy, an embedding model, a vector database, a reranker, and logic to keep vectors synced with source data. Long context offers a “no-stack stack,” simplifying the architecture to just getting the data and sending it to the model.
  • Avoiding the “Retrieval Lottery”: RAG introduces a critical point of failure at the retrieval step. Semantic search is probabilistic and can suffer from “silent failure”—where the correct answer exists in the database but is not retrieved, so the LLM never sees it. Long context eliminates this risk by providing the model with all the data.
  • Solving the “Whole Book Problem”: RAG is designed to retrieve existing text snippets that semantically match a query. It struggles with questions that require understanding the gap or relationship between different documents. For example, to determine which security requirements from a requirements document were omitted from the final release notes, a model needs to compare both full documents. RAG provides isolated snapshots, but long context provides the full picture, enabling complex, cross-document reasoning.

The Defense of RAG: Why It Still Matters

Despite the advantages of long context, RAG remains essential for several reasons, particularly in enterprise settings.

  • The “Rereading Tax”: Long context can be computationally inefficient. Every time a query is made, the entire corpus of documents must be tokenized and processed by the model. A 500-page manual might represent 250,000 tokens that are re-processed with every request. RAG pays this processing cost only once during the initial indexing. While prompt caching can help with static data, it’s ineffective for dynamic, frequently changing content.
  • The “Needle in the Haystack” Problem: Research shows that a model’s performance can degrade as the context window fills up. The attention mechanism can become diluted, causing the model to miss a specific detail buried in a massive document (“the needle in the haystack”). RAG acts as a pre-filter, removing the “haystack” and presenting the model with only the most relevant “needles,” forcing it to focus on the signal rather than the noise.
  • The Infinite Data Set: Enterprise data lakes are often measured in terabytes or petabytes, far exceeding the capacity of even a million-token context window. For navigating these vast, effectively infinite datasets, a retrieval layer is not just helpful—it’s necessary to filter the information down to a manageable size that can fit within the LLM’s context.

Conclusion: Choosing the Right Approach

The choice between RAG and long context is not a matter of one replacing the other, but of selecting the right tool for the job.

  • Use Long Context for problems involving a bounded, limited data set that requires complex, global reasoning. Examples include analyzing a specific legal contract, comparing a few documents, or summarizing a single book.
  • Use RAG when navigating the “infinite data set” of enterprise knowledge. The vector database remains the only viable warehouse for your data at this scale, making a retrieval layer essential.

Share post

Stay In The Loop! Subscribe to Our Newsletter.

Get updates straight to your inbox. No spam, just useful content.

Recommended for You

Building Advanced Agents Over Complex Data // Jerry Liu

Building Advanced Agents Over Complex Data // Jerry Liu

Jerry from LlamaIndex explains why naive Retrieval-Augmented Generation (RAG) fails in production and dives deep into advanced data quality techniques—from parsing complex documents and hierarchical indexing to chunking best practices—required to build robust, high-quality LLM applications.

Scaling Enterprise-Grade RAG: Lessons from Legal Frontier - Calvin Qi (Harvey), Chang She (Lance)

Scaling Enterprise-Grade RAG: Lessons from Legal Frontier - Calvin Qi (Harvey), Chang She (Lance)

A summary of the talk by Harvey and LanceDB on building a highly optimized retrieval architecture for the legal profession. It covers challenges like query complexity and data scale, the importance of evaluation, and how LanceDB's multimodal lakehouse architecture provides the necessary foundation.