Recommended resources
The freely available resources this lesson will direct you to.
Introduction
Welcome to the final lesson in our first module on the core AI components for agentic systems. Over the past three lessons, we have built a solid foundation. We began with text embeddings, the mechanism for translating meaning into a machine-readable format. We then analyzed the LLM context window as a finite workspace and, in our last lesson, designed a complete Retrieval-Augmented Generation (RAG) pipeline to populate that workspace with relevant, external knowledge.
You now have a deep understanding of RAG as one powerful method to enhance a model's capabilities. However, it is not the only method. As an AI architect, your effectiveness hinges on selecting the right tool for the job.
Today's learning outcome is to differentiate between prompting, RAG, and fine-tuning for modifying model behavior. We will construct a strategic decision framework to help you determine when to use each technique—or, more powerfully, how to combine them. This lesson moves from understanding individual components to making architectural trade-offs, a crucial skill for designing robust and cost-effective AI systems.
The Core Distinction: Knowledge vs. Behavior
The most critical first step in choosing a customization method is to diagnose the problem correctly. Nearly every issue you encounter with a base LLM falls into one of two categories: a knowledge deficit or a behavioral deficit.
- Knowledge Deficit: The model lacks specific information. It doesn't know your company's latest financial results, the details of a particular client's portfolio, or the terms of a new regulatory policy. The core problem is that the model is factually uninformed.
- Behavioral Deficit: The model knows the facts (or doesn't need any) but fails to act, reason, or communicate in the desired way. It might produce answers in the wrong format, adopt an inappropriate tone, or fail to follow a complex, multi-step instruction. The core problem is that the model's process is flawed.
This distinction is paramount. As the article from Karen Pfeifer, which we'll review shortly, states: "If you try to solve a Knowledge Deficit with Fine-Tuning, you will fail. If you try to solve a complex Behavioral Deficit with Prompt Engineering, you will break."
To begin building our framework, let's watch a video that introduces all three concepts and their primary roles.
RAG vs Fine-Tuning vs Prompt Engineering: Optimizing AI Models
This video from IBM Technology, 'RAG vs Fine-Tuning vs Prompt Engineering', provides a concise and clear overview of the three main techniques for optimizing LLM outputs. It will serve as an excellent mental anchor for our deep dive.
Please watch from the beginning to 11:28. The video will cover: An introduction to the three methods. A clear explanation of RAG, which will serve as a good recap. A description of Fine-Tuning, including the concept of updating model weights. An overview of Prompt Engineering and how it activates a model's existing capabilities.
Now, let's use this overview as a foundation to build a more detailed, executive-level decision framework. We'll analyze each technique through the lens of cost, complexity, and strategic application.
A Three-Tiered Framework for Model Customization
Think of these methods as lying on a curve of increasing complexity and cost. A prudent architect always seeks to solve the problem at the lowest, most efficient point on this curve.
Tier 1: Prompt Engineering (The Instruction Manual)
Prompt engineering is the art and science of designing inputs to guide an LLM toward a desired output without altering the model itself. It is the most direct, immediate, and least costly way to influence a model's behavior.
- What it is: You are providing detailed instructions, context, and examples within the prompt itself—a technique known as In-Context Learning (ICL).
- Analogy: Think of a base LLM as a brilliant but inexperienced consultant. Prompt engineering is like handing them a clear, detailed project brief with examples of what "good" looks like.
- Best for:
- Controlling output format (e.g., "Respond in JSON," "Use bullet points").
- Setting the tone or persona ("Act as a senior risk analyst...").
- Simple reasoning tasks, often guided by patterns like "Chain-of-Thought" ("Think step-by-step...").
- Teaching by example using Few-Shot Prompting, where you provide input/output pairs in the prompt.
- Pros: Zero infrastructure cost, immediate feedback loop, high flexibility.
- Cons: Limited by the model's context window, can become complex and "brittle" for highly nuanced tasks, and cannot teach the model genuinely new, persistent knowledge.
To understand how to frame this from an executive and technical perspective, let's read the first parts of a highly practical article.
RAG vs. Fine-Tuning vs. Prompt Engineering
The article 'RAG vs. Fine-Tuning vs. Prompt Engineering: A CAIO’s Technical Decision Framework' by Karen Pfeifer provides an excellent, no-fluff executive summary of these trade-offs. It introduces the 'Context-Cost Curve' and the 'Knowledge vs. Behavior' distinction we've discussed.
Please read from the beginning down to the heading 'Tier 2: RAG (Retrieval-Augmented Generation)'. Pay close attention to the framing of Prompt Engineering as the 'Instruction Manual' and the practical example of using 'Few-Shot Prompting' to solve a formatting problem without any training.
Tier 2: Retrieval-Augmented Generation (RAG) (The Open-Book Exam)
As we covered extensively in the previous lesson, RAG addresses the knowledge deficit. It gives the model access to external information at query time.
- What it is: A system that retrieves relevant data from a knowledge base (like a vector database) and adds it to the prompt as context for the LLM.
- Analogy: Instead of trying to make the consultant memorize everything, you give them access to the company's secure filing cabinet and teach them how to look things up.
- Best for:
- Answering questions based on proprietary, dynamic, or recent data.
- Minimizing factual hallucinations by grounding the model in verifiable sources.
- Providing auditability and citations for responses.
- Pros: Knowledge is always fresh and up-to-date, separates knowledge management from model management, and is highly auditable.
- Cons: Introduces architectural complexity (data ingestion pipelines, vector databases), adds latency to each query, and retrieval quality is critical ("garbage in, garbage out").
The article we just started provides an excellent summary of RAG's role.
RAG vs. Fine-Tuning vs. Prompt Engineering
Let's continue with the Pfeifer article to see how RAG fits into this tiered framework.
Please read the section titled 'Tier 2: RAG (Retrieval-Augmented Generation) — The “Open Book Exam”'. Note how it positions RAG as the standard solution for 90% of enterprise use cases involving internal knowledge.
Tier 3: Fine-Tuning (The Medical Residency)
Fine-tuning is the most powerful and most expensive method. It is reserved for addressing deep-seated behavioral deficits by modifying the model's fundamental parameters.
- What it is: The process of taking a pre-trained model and continuing its training on a smaller, specialized dataset. This process adjusts the model's internal weights, effectively creating a new, specialized model.
- Analogy: The consultant is sent to medical school for several years to become a neurosurgeon. They internalize a new, complex skill and way of thinking.
- Best for:
- Teaching the model a highly specialized skill (e.g., writing in a rare programming language like COBOL).
- Adapting the model to understand niche industry jargon (e.g., complex legal or medical terminology).
- Forcing a highly consistent style or voice that is difficult to maintain with prompting alone.
- Improving complex reasoning or classification abilities beyond what prompting can achieve.
- Common Misconception: Fine-tuning is not for memorizing facts. It is notoriously bad at this and can lead to "catastrophic forgetting," where the model learns new behaviors but forgets its general knowledge.
- Pros: Can achieve state-of-the-art performance on specific tasks, knowledge is "baked in" leading to low latency at inference time, can allow for the use of smaller, cheaper models for specific tasks.
- Cons: Extremely high cost and complexity (data curation, GPU compute, MLOps), risk of catastrophic forgetting, and the resulting model is a static artifact that requires retraining to be updated.
Let's complete our reading to understand the high bar for using this technique.
RAG vs. Fine-Tuning vs. Prompt Engineering
Finally, let's read the section on Fine-Tuning to understand its specific, narrow use cases and significant costs.
Read the section 'Tier 3: Fine-Tuning — The “Medical Residency”'. Focus on the critical distinction that fine-tuning is for behavior, not knowledge, and the 10x-50x higher Total Cost of Ownership (TCO) compared to RAG.
The Decision Framework Summarized
We can now synthesize this information into a clear decision-making framework. The following images provide excellent visual summaries of the trade-offs.


For a more detailed breakdown, another excellent resource provides a comparative table.
Fine-Tuning, RAG, or Prompt Engineering? LLM Decision Guide
The article 'Fine-Tuning, RAG, or Prompt Engineering? LLM Decision Guide' from Moveo.AI offers another high-signal perspective and a very useful decision table.
Please read the introductory section ('Start with the right question...'), the section on 'The lightweight alternatives...', and focus on the 'Decision Table' which compares the three methods across cost, performance, overhead, and core use case.
Based on all these resources, here is the strategic order of operations for any new AI project:
- Start with Prompt Engineering: Always begin here. Can you solve your problem with a clearer instruction, a better persona, or a few well-chosen examples (few-shot)? This is the cheapest and fastest approach.
- Add RAG for Knowledge: If the model's failure is due to a lack of access to specific, dynamic, or proprietary information, implement a RAG pipeline. This solves the knowledge deficit without the complexity of training.
- Use Fine-Tuning as a Last Resort: Only when both Prompt Engineering and RAG fail to produce the required behavioral outcome should you consider fine-tuning. This is for deeply embedding a specific skill, style, or complex reasoning pattern that is mission-critical and must be highly reliable.
The Synthesis: Compound AI Systems
The most sophisticated systems do not treat these as mutually exclusive choices. Instead, they are components to be combined into a Compound AI System.
Imagine an agentic workflow for underwriting, a core interest of yours:
- Prompt Engineering: An "Orchestrator Agent" is governed by a master prompt that defines its goal: to assess credit risk for a loan application. This prompt tells it to follow a sequence of steps.
- RAG: In step one, the agent uses a tool that triggers a RAG pipeline. It retrieves the applicant's financial statements from an internal document store, their transaction history from a database, and the bank's current underwriting policies.
- Fine-Tuning: The retrieved context is then passed not to a massive general-purpose model, but to a smaller, fine-tuned model. This model has been specifically trained on thousands of examples to do one thing exceptionally well: identify covenants, calculate debt-service coverage ratios, and flag risk factors in financial documents, outputting its analysis in a precise, structured format required by the bank's core risk system.
In this scenario, each technique is used for its specific strength, creating a system that is knowledgeable, well-behaved, efficient, and auditable.
Conclusion
In this lesson, we have constructed a robust framework for differentiating between and strategically applying prompt engineering, RAG, and fine-tuning.
Key Takeaways:
- The primary decision gate is diagnosing the problem: is it a Knowledge Deficit (use RAG) or a Behavioral Deficit (use Prompt Engineering or Fine-Tuning)?
- These methods exist on a cost and complexity curve. Always start with the simplest approach: Prompt Engineering, then scale with RAG, and only specialize with Fine-Tuning when absolutely necessary.
- Prompt Engineering instructs the model, RAG informs the model, and Fine-Tuning fundamentally changes the model.
- The most powerful architectures are Compound AI Systems that leverage all three techniques in concert to build sophisticated, multi-step agentic workflows.
Preview of the Next Module:
This lesson concludes our module on the fundamental AI components. You now have the "what"—the building blocks of an agent. In Module 2, "Conceptual Frameworks of Agentic AI," we will turn to the "how." Our first lesson will define agentic AI using the Observe-Orient-Decide-Act (OODA) loop as an execution model. This will provide a mental model for how an agent perceives its environment, processes information (using components like RAG), and takes action to achieve its goals.