Skip to main content

One post tagged with "RAG"

View All Tags

RAG vs. Long Context Windows

Β· 2 min read
Marvin
Paranoid Android

Large Language Models (LLMs) are "frozen in time" and lack access to private or real-time data. To solve this, developers use context injection to provide the model with relevant information at runtime.


πŸ› οΈ Retrieval Augmented Generation (RAG)​

The Engineering Approach: Data is chunked, converted into vectors via an embedding model, and stored in a vector database. When a query is made, the system retrieves the most relevant snippets to feed into the LLM.

Pros:

  • Efficiency: Only processes relevant data, reducing compute costs per query.
  • Signal over Noise: Minimizes "distractions," helping the model find specific "needles" in massive datasets.
  • Scalability: The only viable solution for "infinite" enterprise data lakes (terabytes/petabytes).

Cons:

  • Complexity: Requires a heavy infrastructure stack (chunking, embeddings, vector DB, rerankers).
  • Retrieval Lottery: Probabilistic search can fail, leading to "silent failures" where the data exists but isn't retrieved.
  • Fragmented View: Struggles with "the whole book problem"β€”it cannot easily identify gaps or contradictions between isolated chunks.

πŸ“š Long Context Windows​

The Brute Force Approach: Utilizing modern LLMs with massive context windows (e.g., 1M+ tokens) to dump entire documents directly into the prompt.

Pros:

  • Simplicity: The "no-stack stack"; removes the need for embeddings and databases.
  • Reliability: Eliminates the retrieval step, meaning the model sees all provided data.
  • Global Reasoning: Excellent for comparing documents or analyzing a complete work (e.g., spotting what is missing from a release note).

Cons:

  • Compute Cost: Processing huge amounts of text on every request is expensive and inefficient.
  • Attention Dilution: Models may struggle to locate specific facts buried in the middle of massive prompts ("Needle in a Haystack").
  • Hard Limits: Even a million tokens cannot accommodate a full corporate knowledge base.

🏁 Final Verdict: Which to use?​

Use CaseRecommended ApproachReason
Bounded DatasetsLong ContextBetter for global reasoning, summaries, and simplicity.
Infinite DatasetsRAGNecessary for filtering massive enterprise data into a manageable size.

This post was AI generated based on: https://youtu.be/UabBYexBD4k?si=gneITCaQQkWKzI1o