Skip to main content

Chapter 2: Why RAG? Problems with Pure LLMs

Introduction​

Large Language Models like GPT-4, Claude, and Llama are incredibly powerful, but they have fundamental limitations that make them unsuitable for many enterprise applications without augmentation. This chapter explores these limitations and shows how RAG addresses each one.

The Four Major LLM Limitations​

1. Hallucinations​

The Problem: LLMs can confidently generate false information that sounds plausible. They're trained to predict the next token, not to be factually accurate.

User: "Who won the 2024 Super Bowl?"

LLM (without RAG): "The Kansas City Chiefs won the 2024 Super Bowl,
defeating the San Francisco 49ers 25-22."

But what if this is wrong? The LLM doesn't "know" - it predicts.

Why It Happens:

  • LLMs are probability machines, not fact databases
  • Training data contains errors and contradictions
  • No mechanism to verify generated content

RAG Solution:

# With RAG, we ground the response in retrieved facts
retrieved_doc = "Super Bowl LVIII (2024): Kansas City Chiefs defeated
San Francisco 49ers 25-22 on February 11, 2024."

# LLM now has verified information to reference
response = llm.generate(
f"Based on this fact: {retrieved_doc}, answer the question..."
)

2. Knowledge Cutoff​

The Problem: LLMs have a knowledge cutoff date - they don't know about events after their training data was collected.

ModelKnowledge Cutoff
GPT-4September 2023
Claude 3Early 2024
Llama 2July 2023

Real Impact:

User: "What's the current price of Bitcoin?"

LLM (without RAG): "As of my knowledge cutoff, Bitcoin was trading
around $30,000..."

❌ This could be months or years outdated!

RAG Solution:

# Retrieve current data from live source
current_price = retrieve_from_api("bitcoin_price")
# Result: {"price": 97500, "timestamp": "2024-12-23"}

# Now LLM can provide accurate, real-time information
response = llm.generate(
f"The current Bitcoin price is ${current_price['price']}..."
)

3. No Access to Private Data​

The Problem: LLMs are trained on public data. They have no knowledge of:

  • Your company's internal documents
  • Private customer data
  • Proprietary research
  • Internal policies and procedures

Business Impact:

Employee: "What's our vacation policy for employees with 5+ years?"

LLM (without RAG): "I don't have access to your company's
specific policies..."

❌ The LLM is useless for internal queries!

RAG Solution:

# Index company documents into knowledge base
knowledge_base.add_documents([
"Employee Handbook 2024.pdf",
"HR Policies.docx",
"Benefits Guide.pdf"
])

# Now queries can be answered from private data
retrieved = knowledge_base.search("vacation policy 5 years tenure")
# Returns: "Employees with 5+ years receive 25 days PTO..."

response = llm.generate(f"Based on company policy: {retrieved}...")

4. Token Limits / Context Windows​

The Problem: LLMs have limited context windows. Even GPT-4 with 128K tokens cannot process:

  • A complete legal contract database
  • Years of customer support tickets
  • An entire codebase

Context Window Comparison:

ModelContext Window~Pages of Text
GPT-3.54K tokens~3 pages
GPT-48K-128K tokens6-100 pages
Claude 3200K tokens~150 pages

The Math Problem:

Your knowledge base: 10,000 documents
Average document: 5,000 tokens
Total: 50,000,000 tokens

Even Claude 3's 200K context can only hold 0.4% of your data!

RAG Solution:

# Instead of loading everything, retrieve only relevant docs
def smart_retrieval(query, knowledge_base):
# Only retrieve top 5 most relevant documents
relevant_docs = knowledge_base.similarity_search(
query,
top_k=5 # ~25,000 tokens instead of 50M
)
return relevant_docs

# Now we efficiently use the context window
retrieved = smart_retrieval("vacation policy", kb) # ~5 docs
response = llm.generate(f"Context: {retrieved}\n\nQuestion: ...")

Side-by-Side Comparison​

Without RAG​

Problems:

  • May hallucinate
  • Limited to training data
  • No private data access
  • Context overflow risk

With RAG​

Benefits:

  • Grounded in facts
  • Real-time information
  • Private data access
  • Efficient context use

Cost Comparison​

ApproachMonthly Cost*AccuracyFreshness
Pure LLM$50070-80%Static
RAG$70090-95%Real-time
Fine-tuning$5,000+85-90%Static

*Estimated for enterprise use case with 10K queries/day

When RAG Fails​

RAG isn't perfect. Be aware of these scenarios:

1. Retrieval Failures​

Problem: Retrieved wrong documents
Example: User asks about "Apple stock" but retrieves docs about apples (fruit)

Solution: Better embeddings, metadata filtering, hybrid search

2. Context Misuse​

Problem: LLM ignores or misinterprets retrieved context
Example: Retrieved policy says "30 days" but LLM says "60 days"

Solution: Better prompting, smaller context, explicit instructions

3. Outdated Knowledge Base​

Problem: Knowledge base isn't updated
Example: Documents are 6 months old, information is stale

Solution: Regular sync, automated updates, freshness indicators

Summary Table​

ProblemImpactRAG Solution
HallucinationsFalse informationGround in retrieved facts
Knowledge CutoffOutdated answersConnect to fresh data
No Private DataCan't answer internal queriesIndex company docs
Token LimitsCan't process large datasetsSmart retrieval

Key Takeaways​

  1. LLMs have fundamental limitations that prevent enterprise adoption
  2. RAG solves the biggest problems: hallucinations, knowledge cutoff, private data, scale
  3. RAG is cost-effective compared to fine-tuning
  4. RAG isn't perfect but provides significant improvements
  5. Understanding limitations helps design better systems

Next Steps​

Continue to Chapter 3: RAG Architecture to learn about the three phases of RAG.