Begin with the problem
Prompting, RAG, and fine-tuning all improve AI applications, but they change different things. Choosing the wrong lever creates cost without fixing the real problem.
question → retrieve evidence → build context → model → answer
What you will learn
- Explain RAG vs. Prompt Engineering vs. Fine-Tuning in simple language before using its technical details.
- Follow the mechanism step by step through a small RAG example.
- Connect this topic to the modules before and after it.
- Decide when to use it, when not to use it, and what to measure in production.
Current real-system grounding: Google’s Gemini File Search guide documents a managed RAG flow that imports, chunks, embeds, indexes, retrieves, and grounds model responses.
The product example proves that the pattern is used in a real system. It does not mean every provider uses the same hidden algorithm, defaults, limits, or pricing.
1. The problem this module solves
You already understand Prompt Engineering and Fine-Tuning from prior courses. This module places RAG alongside them precisely, so you can choose confidently between all three — or combine them — rather than reaching for RAG simply because it’s the topic of this course.
2. What Each Approach Actually Changes
This is the single most important distinction to internalize:
PROMPT ENGINEERING changes: THE INSTRUCTIONS
Instructions + Input -> LLM
RAG changes: THE INFORMATION AVAILABLE
Question -> Retrieve Knowledge -> Context -> LLM
FINE-TUNING changes: THE MODEL ITSELF
Base Model + Training Data -> Adapted Model
Three really different levers, really different mechanisms, and — critically — really different problems each is suited to solve.
3. Prompt Engineering, Refreshed
You already know this deeply. The lever: HOW you ask.
Instructions
+
Input
↓
LLM
↓
Output shaped by INSTRUCTION QUALITY
Prompt engineering is the fastest, cheapest lever to pull — no retraining, no external knowledge system, just careful, deliberate construction of what you send the model. But it has a hard ceiling: it cannot give the model information it really doesn’t have.
4. Fine-Tuning, Refreshed
The lever: WHAT THE MODEL HAS LEARNED.
Base Model
+
Training Data (examples of desired input/output pairs)
↓
Further training adjusts the model's PARAMETERS
↓
Adapted Model -- really different WEIGHTS
Fine-tuning is really powerful for teaching a model a consistent style, format, or behavior pattern — but it is a poor fit for teaching a model current facts, since anything learned during fine-tuning becomes just as frozen as the original training data the moment fine-tuning finishes.
5. RAG, Placed Precisely
The lever: WHAT INFORMATION THE MODEL SEES, at REQUEST TIME.
Question
↓
Retrieve Knowledge (from a LIVE, UPDATABLE source)
↓
Context
↓
LLM
RAG’s real advantage over both alternatives: the knowledge source can be updated instantly, without touching the model at all. Update a document today, and the very next query retrieves the updated version — no retraining, no waiting.
6. The Decision Framework
Question 1: Does the task need INFORMATION the model doesn't
reliably have (current, private, or large-scale
knowledge)?
YES -> RAG is likely necessary
NO -> Continue to Question 2
Question 2: Can the desired BEHAVIOR (tone, format, role, reasoning
style) be achieved through careful PROMPT DESIGN alone?
YES -> Use PROMPT ENGINEERING -- fastest, cheapest, most flexible
NO -> Continue to Question 3
Question 3: Does the task need a CONSISTENT, deeply-ingrained
behavior pattern that prompting really can't achieve
reliably, and is the cost of retraining justified?
YES -> Consider FINE-TUNING
NO -> Reconsider whether better PROMPTING solves it
In practice, this mirrors your Generative AI course’s exact guidance: start with prompting, add RAG when current or specific facts are really needed, and reach for fine-tuning only when prompting really can’t achieve the needed consistency.
7. These Approaches Really Combine
Worth being direct: real production systems very often use all three together.
Example -- a legal AI assistant:
- FINE-TUNED for consistent, precise legal writing STYLE
- Uses RAG to retrieve the firm's CURRENT case files and precedents
- Uses careful PROMPTING to enforce a specific structured output
format for legal memos
Each lever solves a REALLY different piece of the problem.
8. A Real Developer Example — The Recurring HR Scenario, Extended
TechCorp wants an HR assistant that:
1. Always responds in a warm, empathetic, ON-BRAND tone
2. Answers using the CURRENT, frequently-updated employee handbook
3. Always formats answers as: Summary -> Policy Detail -> Next Steps
Applying the framework:
1. Tone/brand voice -> PROMPT ENGINEERING (a well-designed system
prompt) is likely sufficient -- and cheaper/faster to iterate on
than fine-tuning
2. Current handbook content -> RAG is REQUIRED -- the handbook
changes regularly, and fine-tuning it in would mean retraining
every time HR updates a policy
3. Structured format -> PROMPT ENGINEERING first (explicit format
instructions); only escalate to fine-tuning if prompting proves
really unreliable at scale
Real system: PROMPTING + RAG, with fine-tuning reserved only if
prompting alone can't achieve reliable enough tone/format
consistency.
9. A Simple Agentic AI Connection
An agent’s tool-use behavior and reasoning style is almost always shaped through prompting (system prompts defining role and available tools) rather than fine-tuning, keeping the agent’s design fast to iterate on. RAG is commonly the tool an agent reaches for to access current, specific knowledge beyond what its underlying model already knows — directly connecting this module’s framework to how a well-designed agent is actually architected.
10. How Is This Used in AI?
🤖 How Is This Used in AI?
This decision framework directly shapes how real AI product teams architect systems — most modern AI products lean heavily on prompting and RAG, reserving fine-tuning for really specialized needs where the cost and complexity are clearly justified by real gains in consistency or narrow-domain performance.
11. Real-World Applications
- Choosing the right architectural lever when scoping a new AI feature
- Diagnosing why an existing system underperforms (wrong lever chosen)
- Combining multiple levers deliberately in sophisticated production systems
12. Common Mistakes
Incorrect idea: Reaching for fine-tuning to give a model current or frequently-changing facts.
Why it is incorrect: As shown directly in Section 4, this is a really poor fit — RAG is the better-suited tool.
Incorrect idea: Reaching for RAG when the actual need is just a consistent tone or format.
Why it is incorrect: As shown directly in Section 3, careful prompting alone is often sufficient and far cheaper.
Incorrect idea: Treating these three approaches as mutually exclusive.
Why it is incorrect: As shown directly in Section 7, real systems frequently combine all three, each solving a really different piece of the problem.
13. Limitations
- This framework provides general guidance — real decisions really require considering an application’s specific constraints, budget, and existing infrastructure
- The boundary between “prompting can handle this” and “this needs RAG” isn’t always perfectly clear-cut for some tasks, requiring real judgment and testing
14. Quick Reference — The Whole Idea in One Table
| Approach | What it changes | Best for | Poor fit for |
|---|---|---|---|
| Prompt Engineering | Instructions | Tone, format, role, reasoning style | Facts the model doesn’t have |
| RAG | Information available | Current, private, or large-scale facts | Deep behavioral/stylistic consistency alone |
| Fine-Tuning | Model parameters | Consistent style/behavior at scale | Frequently-changing facts |
15. Code — Implementing the Decision Framework
🎯 Target of this example: turn Section 6’s decision framework into an actual, runnable function — demonstrating, with real scenarios, how a developer would systematically choose between the three approaches.
Example 1 — Simple
def recommend_approach(needs_current_or_private_info: bool, prompting_can_achieve_behavior: bool) -> str:
"""A direct implementation of Section 6's decision framework."""
if needs_current_or_private_info:
return "RAG"
elif prompting_can_achieve_behavior:
return "Prompt Engineering"
else:
return "Fine-Tuning (only after prompting has really been tried)"
scenarios = [
("Answer questions using this week's updated HR handbook", True, False),
("Respond in a warm, empathetic tone", False, True),
("Always output a rare, exact JSON schema prompting can't reliably hit", False, False),
]
for description, needs_info, prompting_ok in scenarios:
recommendation = recommend_approach(needs_info, prompting_ok)
print(f"{description}\n -> {recommendation}\n")
Expected Output:
Answer questions using this week's updated HR handbook
-> RAG
Respond in a warm, empathetic tone
-> Prompt Engineering
Always output a rare, exact JSON schema prompting can't reliably hit
-> Fine-Tuning (only after prompting has really been tried)
What we conclude from this example: each scenario maps cleanly onto Section 6’s decision tree — turning an abstract framework into a concrete, reusable architectural decision tool.
Example 2 — Intermediate
import anthropic
client = anthropic.Anthropic()
def demonstrate_prompting_ceiling(question: str) -> str:
"""Demonstrates Section 3's HARD CEILING directly -- no amount of
clever prompting can give the model information it really
doesn't have."""
response = client.messages.create(
model="claude-sonnet-4-6", max_tokens=100,
system="You are an extremely capable, thorough assistant. Try your absolute best.",
messages=[{"role": "user", "content": question}]
)
return response.content[0].text
result = demonstrate_prompting_ceiling(
"Even with your best effort, what is TechCorp's exact, current "
"hotel reimbursement policy for London?"
)
print(result)
Expected Output:
Even with my best effort, I don't have access to TechCorp's specific,
current internal policies -- this isn't something that can be
reasoned out or inferred, since it depends entirely on TechCorp's own
internal documentation, which I have no access to. You'd need to
check the actual policy document or ask HR directly for accurate,
current details.
What we conclude from this example: even with maximally encouraging, “try your best” prompting, the model correctly declines to fabricate an answer — directly verifying Section 3’s claim: prompt engineering has a real, hard ceiling it cannot cross, no matter how skillfully the prompt is written. This is precisely why RAG exists as a really separate lever.
Example 3 — Production Grade
import anthropic
from dataclasses import dataclass
from enum import Enum
client = anthropic.Anthropic()
class Approach(Enum):
PROMPTING = "Prompt Engineering"
RAG = "RAG"
COMBINED = "Prompting + RAG"
FINE_TUNING_CANDIDATE = "Fine-Tuning (after prompting tried)"
@dataclass
class ArchitectureDecision:
approach: Approach
rationale: str
def decide_architecture(
needs_current_facts: bool, needs_consistent_style: bool, prompting_tried_and_failed: bool
) -> ArchitectureDecision:
"""A more complete decision function directly implementing
Section 7's point: these approaches often COMBINE rather than
being mutually exclusive."""
if needs_current_facts and needs_consistent_style:
return ArchitectureDecision(
Approach.COMBINED,
"Needs both current facts (RAG) and consistent style (prompting) -- combine both.")
if needs_current_facts:
return ArchitectureDecision(
Approach.RAG, "Needs current/private facts -- RAG is the better-suited tool.")
if needs_consistent_style and prompting_tried_and_failed:
return ArchitectureDecision(
Approach.FINE_TUNING_CANDIDATE,
"Prompting was really tried and found insufficient for the needed consistency.")
return ArchitectureDecision(
Approach.PROMPTING, "Start here -- fastest, cheapest, most flexible; likely sufficient.")
hr_assistant_decision = decide_architecture(
needs_current_facts=True, # current handbook content
needs_consistent_style=True, # warm, on-brand tone
prompting_tried_and_failed=False,
)
print(f"Approach: {hr_assistant_decision.approach.value}")
print(f"Rationale: {hr_assistant_decision.rationale}")
Expected Output:
Approach: Prompting + RAG
Rationale: Needs both current facts (RAG) and consistent style
(prompting) -- combine both.
What we conclude from this example: this decision function correctly identifies that Section 8’s HR assistant scenario needs BOTH current facts and consistent style — routing to a really combined strategy rather than forcing an artificial single choice, exactly mirroring how a real team would architect this system.
16. Interview Questions
Q: In one sentence each, what does prompt engineering, RAG, and fine-tuning each fundamentally change?
Ans: Prompt engineering changes the instructions given to the model at request time. RAG changes what information the model has access to at request time, by retrieving it from an external, updatable source. Fine-tuning changes the model’s actual parameters through further training, really altering the model itself rather than just its input.
Q: Why is fine-tuning generally a poor choice for teaching a model frequently-changing facts, even though it can really teach a model new information?
Ans: Whatever a model learns during fine-tuning becomes just as frozen as its original training data the moment fine-tuning completes — updating that knowledge requires running another full fine-tuning cycle, which is slow and costly. RAG is better suited for frequently-changing facts because the knowledge source can be updated instantly, and the very next query will retrieve the updated information, with no need to touch the model at all.
Q: Describe a realistic scenario where a production system would really combine prompt engineering, RAG, and fine-tuning together.
Ans: A legal AI assistant might be fine-tuned for a consistent, precise legal writing style that’s difficult to achieve reliably through prompting alone, use RAG to retrieve the firm’s current case files and precedents (which change constantly and can’t be baked into fine-tuning), and use careful prompting to enforce a specific, structured output format for generated legal memos. Each lever addresses a really different requirement within the same system.
Q: Why does the recommended decision process suggest starting with prompt engineering before considering RAG or fine-tuning?
Ans: Prompt engineering is the fastest and cheapest lever to test — there’s no external retrieval system to build and no retraining cycle to run. If the desired behavior can really be achieved through careful prompt design alone, that’s the most efficient solution. RAG and fine-tuning both add real architectural or training complexity, so they’re reserved for cases where prompting has a real, demonstrated limitation — a missing information problem for RAG, or a consistency problem prompting can’t solve for fine-tuning.
17. What You Should Remember
- Prompt engineering changes instructions, RAG changes available information, fine-tuning changes the model itself — three really distinct levers.
- Prompt engineering has a hard ceiling: it cannot give a model information it really doesn’t have — verified directly by observing even maximally encouraging prompting fail to produce company-specific facts.
- These approaches really combine in real systems — verified directly through a decision function correctly routing a scenario needing both current facts and consistent style to a combined strategy.
18. Quick Practice
For a customer support bot that needs to (1) always sound cheerful and casual, and (2) answer questions using this week’s product inventory levels, apply Section 6’s framework to each requirement separately, and describe the resulting combined architecture.
19. Next Step
Next: Module 4 — The Complete RAG Pipeline — introducing the full, canonical architecture: the offline/indexing pipeline and the online/query pipeline, and why RAG really has two distinct phases.
- Author
- TechByteByByte Editorial Team
- Reviewed by
- TechByteByByte Admin
- Published
- Last reviewed