When an AI system performs poorly, teams often jump to the most complicated remedy.
They consider fine-tuning before the instructions are clear, build retrieval before identifying the missing knowledge, or keep editing prompts when the real problem is inconsistent source data.
Prompt engineering, retrieval-augmented generation, and fine-tuning solve different failure modes. The right sequence is usually prompt, evaluate, retrieve, evaluate again, and fine-tune only when the evidence supports it.
The short answer: Use prompt engineering to define the task and output. Use RAG when the model needs private, current, or source-grounded knowledge. Use fine-tuning when you need consistent behavior that is difficult to produce through instructions and examples alone. Build an evaluation set before choosing any of them.
The three techniques at a glance
| Technique | What changes | Best for | Does not fix |
|---|---|---|---|
| Prompt engineering | Instructions and context sent with each request | Task definition, format, constraints, examples | Missing knowledge, bad source data, impossible tasks |
| RAG | Relevant external information supplied at runtime | Private knowledge, changing facts, citations, large document sets | Weak reasoning, inconsistent style by itself |
| Fine-tuning | Model behavior learned from training examples | Repeated task patterns, style, format, specialized behavior | Current facts unless included at runtime |
These methods can be combined. A fine-tuned model can use retrieval. A RAG system still needs a good prompt. The decision is about which layer contains the problem.
Start with the failure, not the technique
Before changing the system, classify the error.
Instruction failure
The model does not understand the task, constraints, audience, or output format. Improve the prompt and examples.
Knowledge failure
The model lacks private information or current facts. Add retrieval or another approved data source.
Retrieval failure
The relevant information exists but the system does not find it, ranks it poorly, or passes too much irrelevant context. Improve document structure, chunking, metadata, search, and reranking.
Behavior failure
The model understands the task and has the knowledge, but it remains inconsistent across many examples. Fine-tuning may help.
Process failure
The AI output is acceptable, but the surrounding workflow does not validate, route, approve, or record it correctly. Fix the system architecture.
Data failure
The source material is contradictory, stale, incomplete, or poorly organized. No model technique can reliably repair an undefined source of truth.
This diagnosis prevents expensive work on the wrong layer.
Prompt engineering: define the job clearly
A prompt is the operating brief for a model call. It should make the task, context, constraints, and expected output unambiguous.
Strong prompts commonly include:
- The role of the system in this specific task.
- The goal and definition of success.
- The authoritative context it may use.
- Rules and boundaries.
- The required output structure.
- Examples of acceptable and unacceptable results.
- A fallback when information is missing.
OpenAI’s prompt engineering guidance recommends placing instructions clearly, being specific about the desired result, showing the output format with examples, and moving from zero-shot to few-shot patterns before considering fine-tuning.
What prompt engineering is good at
It is effective for:
- Returning valid structured data.
- Adapting tone and reading level.
- Following a decision rubric.
- Classifying text into known categories.
- Extracting specified fields.
- Producing a draft in a repeatable format.
- Refusing unsupported conclusions.
It is fast to change and easy to compare in an evaluation set.
What prompt engineering cannot do
A prompt cannot provide information it does not contain. It cannot make stale knowledge current, turn inconsistent policies into a clear rule, or guarantee that a probabilistic model always follows instructions.
Long prompts also create their own problems. Important rules can become diluted by irrelevant context, conflicting examples, and repeated boilerplate.
RAG: give the model the right evidence at runtime
Retrieval-augmented generation adds a search layer between the user’s request and the model’s answer.
A basic RAG flow looks like this:
- The system receives a question or task.
- It searches an approved knowledge source.
- It selects the most relevant passages or records.
- It provides that evidence to the model.
- The model answers under instructions to use and cite the supplied material.
RAG is useful when knowledge is private, changes often, is too large to place in every prompt, or must be attributed to a source.
Common business uses include:
- Customer support grounded in current documentation.
- Internal policy and procedure assistants.
- Proposal generation from approved product and case-study material.
- Contract review against a company playbook.
- Account briefs assembled from CRM and support records.
- Research systems that cite an approved source set.
OpenAI’s vector store search API is one implementation path for semantic and hybrid search over uploaded content. Other systems use PostgreSQL extensions, dedicated vector databases, or conventional search engines.
RAG quality depends on the retrieval system
Calling a vector database does not guarantee grounded answers. The system must retrieve evidence that is relevant, authoritative, current, and appropriately scoped.
Document preparation
Remove duplicates and stale versions. Preserve useful headings and metadata. Split content around meaningful sections, not arbitrary character counts alone.
Access control
Filter retrieval by user and account permissions before the model sees the content. Do not retrieve everything and ask the model to hide what the user should not access.
Search strategy
Semantic search helps with conceptual similarity. Keyword search helps with exact names, codes, and phrases. Hybrid search often performs better than either alone.
Ranking and context assembly
The first search results are not always the best evidence. Rerank when needed, remove redundant passages, and place the strongest sources where the model can use them.
Citation and abstention
Require the answer to distinguish sourced facts from interpretation. If no adequate evidence is found, the correct output may be “I do not have enough approved information.”
RAG failures should be measurable. Evaluate whether the right document was retrieved, whether the answer used it correctly, and whether the citation supports the claim.
Fine-tuning: teach a repeatable behavior
Fine-tuning trains a model on examples of the behavior you want. It can make a model more consistent at a narrow task, reduce the amount of instruction needed in each prompt, or adapt output style and structure.
Good fine-tuning candidates include:
- A high-volume classification task with stable labels.
- Consistent extraction from a recurring document family.
- A specialized response format with many nuanced examples.
- Brand voice that is difficult to express as a short rule set.
- Tool selection behavior with a strong record of correct trajectories.
Fine-tuning is not a knowledge management system. Facts embedded in training examples can become stale, and the model cannot cite the training row it learned from. Use retrieval for changing knowledge.
OpenAI’s fine-tuning guidance emphasizes representative examples, consistent formatting, and a separate test set. Training data quality matters more than collecting a large pile of unreviewed outputs.
When fine-tuning is premature
Do not fine-tune when:
- The task definition is still changing.
- The team cannot agree on what a correct answer looks like.
- Only a small number of examples exist.
- Most failures come from missing information.
- Source data changes frequently.
- A strong prompt with a few examples already works.
- There is no evaluation set to measure improvement.
Fine-tuning a vague process can make the model consistently vague.
A decision sequence that works
Step 1: Define the measurable task
Avoid goals such as “make the assistant smarter.” Define the input, expected output, acceptable variability, and business result.
Step 2: Build an evaluation set
Collect representative cases, edge cases, and failures. Write or review the expected result. Decide which criteria can be checked automatically and which require human judgment.
Step 3: Establish a prompt baseline
Use clear instructions, structured outputs, and a few high-quality examples. Measure the result before adding infrastructure.
Step 4: Add retrieval if knowledge is missing
Evaluate retrieval separately from generation. If the right evidence is not found, changing the final prompt will not solve the problem.
Step 5: Add deterministic validation
Check schemas, required fields, permissions, dates, calculations, and business rules with conventional code wherever possible.
Step 6: Consider fine-tuning
Fine-tune only if a meaningful gap remains and the team has enough reviewed examples to represent the task.
Step 7: Re-run the same evaluation set
Compare quality, latency, cost, and failure distribution. Keep the simpler architecture if the improvement is marginal.
How the techniques combine
Prompt plus RAG
This is the most common production combination. The prompt defines how to answer, while retrieval supplies current and private evidence.
Prompt plus fine-tuning
Fine-tuning establishes a strong default behavior. The prompt still provides the current task, constraints, and user context.
RAG plus fine-tuning
Retrieval provides facts. Fine-tuning improves how the system uses those facts, follows a specialized format, or selects tools.
All three inside a workflow or agent
A production agent may use a fine-tuned model, retrieve approved knowledge, and receive task-specific instructions. The surrounding agent harness still controls permissions, tools, approvals, traces, and recovery.
Business examples
Support response assistant
Start with a prompt that defines tone, policy, and answer structure. Add RAG for current product documentation and account-specific data. Fine-tune only if reviewed responses reveal a stable behavior gap that examples in the prompt cannot solve.
Invoice extraction
Start with structured output and deterministic validation. If document layouts vary but labels are stable, fine-tuning may improve consistency. RAG is usually not the central technique because the required facts are in the current document.
Internal policy assistant
Use RAG because policies change and answers need citations. Prompt the system to abstain when evidence is missing. Fine-tuning is unlikely to be the first priority.
Sales call analysis
Use a prompt and schema for the desired fields. Add examples for nuanced qualification. Fine-tuning may help at high volume if categories are stable and the organization has enough reviewed calls.
Supporting video: OpenAI presents a practical progression across prompt engineering, retrieval, and fine-tuning, with an emphasis on measuring performance instead of guessing.
Frequently asked questions
Is RAG better than fine-tuning?
They solve different problems. RAG is better for supplying current or private knowledge. Fine-tuning is better for teaching repeatable behavior. A system may use both.
Does fine-tuning teach a model company knowledge?
It can influence behavior based on training examples, but it is a poor substitute for a maintained knowledge source. Use retrieval when facts change, require access controls, or need citations.
How much data is needed for fine-tuning?
There is no universal number. Start with a smaller set of consistent, representative, expert-reviewed examples and measure performance on a separate test set. Quality and coverage matter more than raw volume.
What is the difference between RAG and a long prompt?
A long prompt sends a fixed body of context every time. RAG searches a larger source and supplies only the passages relevant to the current task. RAG adds retrieval complexity but can improve freshness, relevance, and scale.
Should we fine-tune before building an AI agent?
Usually not. First prove that the task, tools, permissions, and evaluation criteria are sound. Fine-tune only when measured agent behavior shows a consistent gap that training examples can address.
Sources and methodology
This guide uses current primary guidance from OpenAI on prompt engineering, OpenAI vector store search, OpenAI fine-tuning, and Anthropic on context engineering. The decision framework reflects Friday Labs’ approach of starting with a measurable process and adding complexity only when the evidence supports it.



