Is RAG Still Needed? Choosing the Best Approach for LLMs

Summary·translated·IBM Technology
Shared by Wendy
Large Language Models (LLMs) are limited by their training cutoff dates and lack knowledge of private or recent data. To address this, two main approaches for context injection exist: Retrieval Augmented Generation (RAG) and Long Context. RAG, an engineering approach, involves pre-processing documents by chunking them, converting them into vectors using an embedding model, and storing them in a vector database. When a user queries, a semantic search retrieves relevant chunks, which are then injected into the LLM's context window alongside the user's prompt. While effective, RAG's success hinges on the accuracy of its retrieval logic. Long Context, a model-native solution, bypasses the database and embedding model. It directly feeds entire documents into the LLM's context window, allowing the model's attention mechanism to find answers. Initially impractical due to small context windows, modern LLMs now boast massive capacities (e.g., millions of tokens), making Long Context a viable option. The speaker argues for Long Context's simplicity, citing three reasons: 1. **Collapsing Infrastructure:** RAG systems are complex, requiring chunking strategies, embedding models, vector databases, and re-rankers. Long Context eliminates these, simplifying the architecture. 2. **Retrieval Lottery:** RAG's semantic search is probabilistic and can fail to retrieve relevant information, leading to "silent failures." Long Context avoids this by providing all data to the model. 3. **The Whole Book Problem:** RAG struggles with questions requiring global reasoning or identifying missing information, as it only provides isolated snippets. Long Context allows the model to see the entire document for comprehensive analysis. However, RAG still holds value for three reasons: 1. **Rereading Tax:** Long Context incurs a computational cost by re-processing entire documents with every query, whereas RAG processes data once during indexing. 2. **Needle in the Haystack Problem:** While Long Context provides all data, LLMs can struggle to find specific information within vast context windows. RAG, by retrieving only relevant "needles," reduces noise and improves focus. 3. **Infinite Dataset:** Enterprise data often spans terabytes or petabytes, far exceeding even the largest context windows. RAG's retrieval layer is essential for filtering this vast data into manageable chunks for LLMs. In conclusion, Long Context is ideal for bounded datasets requiring complex global reasoning, simplifying the stack and improving reasoning. RAG remains crucial for navigating infinite enterprise datasets, where a retrieval layer is necessary to filter information.
Open original source →

Comments

Sign in to leave a comment.

No comments yet. Be the first to share your thoughts!