Fine-tuning vs RAG vs prompting: which one to use when
Start with prompting, add RAG when the model lacks your facts, and fine-tune only when behaviour stays inconsistent after both. How to tell which one you need.
Use prompting first, RAG when the model is missing facts it needs, and fine-tuning only when the model has the facts but its behaviour stays inconsistent after a good prompt. RAG fixes what the model knows; fine-tuning fixes how it behaves; prompting is the cheap experiment that tells you which of the two problems you actually have. Most business assistants built on company documents need RAG and never need fine-tuning.
Three tools for two different problems
The three options get compared as if they were rungs on one ladder, each more serious than the last. They are not. Prompting and fine-tuning both change behaviour: one by telling the model what to do at request time, the other by training it on examples until the behaviour is baked into its weights. RAG does something else entirely. It changes what information the model can see when it answers.
OpenAI's guide to optimising LLM accuracy frames this as two axes. Context optimisation (RAG) is for when the model lacks knowledge because it is missing, out of date or proprietary, and it "maximizes response accuracy". LLM optimisation (fine-tuning) is for inconsistent formatting, tone or reasoning, and it "maximizes consistency of behavior". The guide's memory analogy is useful too: fine-tuning builds learned memory from repeated examples, while RAG works like looking something up in reference material at the moment you need it.
The original RAG paper from Lewis and colleagues (2020) made the same split in research terms. Models store factual knowledge in their parameters, but accessing it precisely, showing where an answer came from and updating what the model knows were open problems. Their answer was to pair the model's "parametric" memory with a separate index it could search. That is still the main reason RAG exists, and it is explained in more depth in our RAG explainer.
So the first question is never "which technique is best?". It is "what kind of failure am I looking at?".
Diagnose the failure before choosing the fix
You cannot diagnose anything without a test set. OpenAI's guide suggests building a good prompt and an evaluation set of 20 or more questions with ground-truth answers before adding complexity, and its fine-tuning guide says to "only invest in fine-tuning after setting up evals". Our guide to evaluating LLM applications covers how to build one. Twenty real questions with known answers is enough to start sorting failures.
Then read the wrong answers one by one and put each into one of three piles.
The first pile is knowledge failures. The answer is wrong because the model did not have the fact: last month's price list, an internal policy, a customer's contract terms, anything that changed after the model was trained or was never public. No amount of instruction fixes this. The model needs the document in front of it.
The second pile is instruction failures. The model had what it needed but misunderstood the task, used the wrong format or ignored a rule. Usually the prompt was vague, or the rule was implied rather than written down. These are fixed by rewriting the prompt and adding a few worked examples.
The third pile is the stubborn one: behaviour that stays inconsistent even after the prompt is clear and has examples. The model classifies tickets into your 14 categories correctly most of the time but drifts on the same edge cases, or produces your JSON schema nine times out of ten. This is the pile fine-tuning is for.
When you sort failures this way, you need to see exactly what the model received, including which retrieved passages were in its context. CloudOEngine's AI runtime traces every step and tool call of an agent and makes it inspectable, which is what you need to tell a retrieval miss from a model that ignored a passage it was given.
Prompting goes further than people expect
Prompting is cheap to try, quick to change and easy to roll back, which is why every vendor guide I read puts it first. OpenAI says "prompt engineering is typically the best place to start". Google's Vertex AI tuning guide says to start with prompting to find the best prompt, and recommends it when you have limited labelled data or cannot afford a long fine-tuning process.
A few examples in the prompt often do more than paragraphs of instruction. OpenAI's accuracy guide includes a worked case on correcting Icelandic grammar, scored with BLEU. The base model with no examples scored 62. Adding three examples to the prompt raised it to 70. That is a meaningful jump for the cost of pasting three examples into a prompt.
The limits of prompting are real, though. Every example and rule you add is sent with every request, so long prompts cost more and add latency (prompt caching helps with that, but does not remove it). And some behaviours resist instruction: a model can read "always use exactly these 14 categories" and still drift on the hard cases, because the instruction competes with everything else in the context.
RAG is for facts, and the research agrees
If your failures are in the knowledge pile, fine-tuning is the wrong tool, and two papers explain why.
Ovadia and colleagues compared unsupervised fine-tuning against RAG for injecting knowledge across a range of knowledge-intensive tasks. Fine-tuning helped somewhat, but in their words, "RAG consistently outperforms it, both for existing knowledge encountered during training and entirely new knowledge". They also found models struggle to learn new facts through fine-tuning unless they see many variations of the same fact, which is not how company documents are usually written.
Gekhman and colleagues went further, in a paper accepted at EMNLP 2024. In a controlled question-answering setup, they varied how many fine-tuning examples taught facts the model did not already know. The model learned those examples much more slowly than ones consistent with its existing knowledge, and once it did learn them, its tendency to hallucinate rose roughly linearly. Their conclusion is that models mostly acquire factual knowledge in pre-training, and fine-tuning teaches them to use that knowledge more efficiently.
Put plainly: training a model on your policy manual is a slow way to get a model that is more confident and not more correct. RAG keeps the facts outside the model, where you can update a document on Tuesday and have correct answers on Tuesday, remove a document when it is withdrawn, show the user which passage the answer came from, and check permissions before a passage is ever retrieved.
That last point matters more than it sounds. A fine-tuned model cannot forget a salary table for one user and remember it for another. A retrieval step can filter by who is asking. CloudOEngine connects databases and files to an AI runtime with RAG under one permission model and one audit trail, so the same access rules apply to the data and to the assistant that reads it.
When fine-tuning earns its place
Fine-tuning is the right answer more often than its critics admit, just for a narrower set of problems. The vendor guides agree on the shape of them. OpenAI lists classification, nuanced translation, generating content in a specific format and correcting instruction-following failures. Google lists classification, sentiment analysis and entity extraction, and says it fits best when the output is not complex and is relatively easy to define.
Back to the Icelandic example: after prompting took the score from 62 to 70, fine-tuning a smaller model on 1,000 examples reached 78, and fine-tuning the larger model reached 87. Then the authors added RAG on top of the fine-tuned model, and the score fell four points to 83. The task was about behaviour, not facts, so retrieved context was noise. It is a good reminder that more techniques are not automatically better, and that the eval set has to decide.
There is also an economic reason to fine-tune. A small model fine-tuned on a narrow task can sometimes replace a large general model for that task, at lower cost and latency. Our article on small vs large language models covers when that trade works.
Data requirements are lower than many teams think but higher than a weekend's work. OpenAI's minimum is 10 examples, and it recommends starting with 50 well-crafted ones, then evaluating before adding more; if 50 examples have no effect, it says to rethink the task or prompt before adding data. Google's guide puts the bar at 100 or more and lists hundreds to thousands of labelled examples for supervised fine-tuning. Both stress quality over volume, and OpenAI adds that training examples should look like real production inputs, with a held-out set kept back as a control.
Cost of training is less of a barrier than it was. The LoRA paper (Hu and colleagues) showed that freezing the base model and training small added matrices could cut trainable parameters by 10,000 times and GPU memory by 3 times compared with fully fine-tuning GPT-3 175B, with no added latency at inference. Parameter-efficient methods like this are why fine-tuning open models is now within reach of ordinary engineering teams.
The costs nobody puts in the comparison
The hidden cost of fine-tuning is ownership. A fine-tuned model is a build artefact. When the base model is retired, you retrain. When your categories change, you rebuild the dataset and retrain. When someone asks why the model labelled a ticket a certain way, there is no retrieved passage to point at.
Vendor dependence is the other one. OpenAI's own supervised fine-tuning page now says the company is winding down its fine-tuning platform and that the platform is no longer accessible to new users, with fine-tuned models available for inference until their base model shuts down. Whatever you think of that decision, it shows the risk: a fine-tuned model on a hosted platform lives exactly as long as the provider supports it. If you fine-tune, keep the training data, the eval set and the training recipe in your own hands so you can rebuild on another model.
RAG has its own running costs: an index to keep fresh, chunking and retrieval to tune, and more tokens per request. But those costs sit in your data pipeline, which you control, rather than in a model you may have to rebuild.
| Prompting | RAG | Fine-tuning | |
|---|---|---|---|
| Fixes | Unclear task, format, tone | Missing, private or stale facts | Inconsistent behaviour after a good prompt |
| Data needed | A few examples | Your documents or tables, indexed | Labelled examples (vendor guides: 10 minimum, 50-100+ to start) |
| Time to change | Minutes | Update a document, re-index | Rebuild dataset and retrain |
| Shows its source | No | Yes, the retrieved passage | No |
| Per-user permissions | Through what you put in the prompt | Filter at retrieval | Not possible inside the model |
| Main risk | Long, costly prompts | Retrieval misses the right passage | Stale model, retraining, platform dependence |
The order I would go in
As an illustration, take an insurance claims team that wants an assistant to read incoming claim emails, pull out the policy number, claim type and amount, check the claim against the policy wording and draft a reply. It is a tempting fine-tuning project. I would not start there.
- Build an eval set of 30 to 50 real, anonymised claim emails with the correct extraction and a reviewed reply for each.
- Write a clear prompt with the output schema and three examples, and score it.
- Sort the failures. Wrong policy terms go to the knowledge pile; a malformed amount or wrong claim type goes to the behaviour pile.
- Add RAG over the policy wordings and score again. Most knowledge failures should disappear, and the replies can now cite clauses.
- If extraction still drifts on the same kinds of email, collect a few hundred corrected examples from reviewers and fine-tune a small model for the extraction step only, leaving the reply drafting on RAG.
- Re-run the full eval on the combined system, because each change can break something the other fixed.
The split in step 5 is the pattern I would reach for most: fine-tune the narrow, stable, structured step, and keep the facts in retrieval. OpenAI's guide calls the two methods "additive, not exclusive", and this is what that looks like in practice.
How CloudOEngine helps
CloudOEngine is one platform and console for connecting data (databases, files, camera streams), pipelines, an AI runtime with an LLM gateway, agents with tool access and RAG, and Vision AI with live video. Everything runs under one permission model and one audit trail, which matters for RAG in particular: the documents and tables an assistant retrieves from are governed by the same access rules as the rest of your data.
Governance is included, not upsold: tenant isolation, role-based access, audit logs and per-tenant encrypted secrets.
Agents run real tools, for example filing a ticket, and every step and tool call is traced and inspectable. When an answer is wrong, you can see what the model was given and tell a retrieval problem from a behaviour problem, which is the diagnosis this whole article depends on.
Autopilot runs triggered agents with approval rules, so a person approves an action, in the app or through an email approve link, before it runs. That is a sensible guard while you are still finding out how often a new assistant gets things wrong.
CloudOEngine connects to your sources through 500+ connectors, offers a 99.9% uptime SLA option, and is built in Bengaluru, India.
Book a demo or see the AI runtime.
Frequently asked questions
Should I fine-tune or use RAG to teach a model my company's documents?
Use RAG. In a 2023 comparison, Ovadia and colleagues found RAG consistently beat unsupervised fine-tuning for injecting knowledge, both for facts the model had seen before and for entirely new ones, and RAG lets you update or remove a document without retraining.
When is fine-tuning worth it?
When the model has the facts it needs but its behaviour is inconsistent: a fixed output format, a classification scheme, a tone, or a narrow task it keeps getting slightly wrong after a good prompt with examples. Vendor guides list classification, entity extraction and specific output formats as typical fits.
How many examples do I need to fine-tune a model?
OpenAI's supervised fine-tuning guide sets a minimum of 10 and recommends starting with 50 well-crafted examples; Google's Vertex AI guide puts the bar at 100 or more and lists hundreds to thousands for supervised fine-tuning. Quality matters more than volume in both.
Can fine-tuning make hallucinations worse?
It can. A 2024 study by Gekhman and colleagues found that once a model learns fine-tuning examples containing facts it did not already know, its tendency to hallucinate rises roughly linearly. Fine-tuning is better at shaping how a model uses what it knows than at adding facts.
Can I combine RAG and fine-tuning?
Yes. OpenAI's accuracy guide calls the two methods additive, not exclusive. A common pattern is a model fine-tuned for format or style that answers from retrieved documents, but measure both together, because adding retrieval can also hurt a task that is purely about behaviour.
Sources
- OpenAI: Optimizing LLM accuracy
- OpenAI: Supervised fine-tuning
- Google Cloud: Introduction to tuning (Vertex AI)
- Ovadia et al., Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMs (arXiv 2312.05934)
- Gekhman et al., Does Fine-Tuning LLMs on New Knowledge Encourage Hallucinations? (arXiv 2405.05904, EMNLP 2024)
- Hu et al., LoRA: Low-Rank Adaptation of Large Language Models (arXiv 2106.09685)
- Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (arXiv 2005.11401)
