Fine-tuning vs RAG vs prompting
Three ways to make a language model do better on your job. They are not rungs on a ladder; they fix different problems. The quickest way to choose is to ask what is going wrong: is the model missing knowledge, or is it not behaving the way you need?
The short answer
- Prompting first, always. It is fast to try and sets the baseline you measure everything else against.
- RAG when the model lacks knowledge: your private documents, facts newer than its training, details it can’t be expected to know.
- Fine-tuning when the model has what it needs but behaves inconsistently, or when you want a smaller, faster, cheaper model to do one job.
- Combine them when you have both problems. They stack rather than compete.
Two different problems
OpenAI’s guide to LLM accuracy frames this as two separate axes. Context problems happen when the model lacks information because it was never in its training data, is out of date, or is private to you; retrieval and better prompts address them. Behavior problems happen when the model has the information but doesn’t act on it the way you need, such as the wrong format, inconsistent answers or the wrong judgment; prompting and fine-tuning address them. The guide also notes that many of OpenAI’s largest customer deployments use only prompt engineering and retrieval.
How they compare
| Prompting | RAG | Fine-tuning | |
|---|---|---|---|
| What it changes | The instructions and examples sent with each call | The information sent with each call, fetched for that input | The model’s weights |
| Fixes | Unclear instructions, missing examples | Missing, private or out-of-date knowledge | Inconsistent behavior, format, tone; cost and speed via a smaller model |
| Time to try | Minutes | Days, to build and tune retrieval | Hours to days, once you have examples |
| Data needed | A few examples to put in the prompt | A searchable collection of your documents | Dozens to thousands of input and answer pairs |
| Keeps knowledge current | Only what you paste in | Yes: update the documents, not the model | No: facts learned in training go stale |
| Cost per call | Rises as prompts grow | Adds retrieval and longer prompts | Can fall a lot, with a small model and short prompts |
Prompting: start here
- Write the job down clearly: the input, the possible answers, the rules.
- Add a few examples of good answers, including tricky cases.
- Measure on a set of inputs with known answers, so changes are judged by results, not impressions.
- Watch prompt length. Long-context models let prompts grow, but OpenAI’s guide cautions that models can struggle to keep attention across very large prompts, and every token is paid for on every call.
RAG: when the model needs knowledge
Retrieval-augmented generation, named in a 2020 paper from Facebook AI Research, pairs a model with a searchable store of documents: for each input, the most relevant passages are fetched and given to the model with the question. Because the knowledge lives outside the model, you can update it by updating the documents.
A RAG system can fail in two places: retrieval can fetch the wrong passages, or the model can misuse the right ones. Measure both. If retrieval is right and answers are still off, that is a behavior problem, which is where fine-tuning comes in.
Fine-tuning: when behavior is the problem
Fine-tuning trains a model on examples of inputs and the answers you want. It is the right tool for consistent format and judgment on a repeated job, and for moving that job to a small model that is cheaper and faster on every call. OpenAI’s accuracy guide fine-tunes on a dataset of 50 or more examples to raise consistency in its worked example. See how to fine-tune without an ML team, and when a small model beats a large one.
Using them together
The methods stack. A common pattern retrieves the context, then fine-tunes a model on examples that include it, so the model learns to use your documents the way you want. Another distills a large model that works well with a long prompt into a small fine-tuned one that needs only a short prompt, which cuts cost on every call. See LLM distillation explained.
A quick checklist
- Do you have a set of inputs with known answers to measure against? If not, build that first.
- Are failures caused by missing or stale knowledge? Add retrieval.
- Does the model have the right context but still answer inconsistently? Fine-tune.
- Is the job working but too slow or costly at your volume? Fine-tune a smaller model on the good answers.
- Is the job open-ended, with no checkable answer? Stay with prompting and a large model.
Questions people ask
Is RAG better than fine-tuning?
They fix different problems. RAG gives a model knowledge it lacks, such as your documents or recent facts. Fine-tuning changes how it behaves, such as format, consistency and judgment on a job. Many systems use both.
Should I start with prompting, RAG or fine-tuning?
Start with a prompt and a way to measure results. Add retrieval if failures come from missing knowledge, and fine-tune if a good prompt with the right context still gives inconsistent answers, or if you want a smaller, cheaper model.
Can fine-tuning teach a model new facts?
Some, but it is a poor way to keep facts current, because they are frozen at training time. Retrieval lets you update knowledge by updating documents.
Can you use RAG and fine-tuning together?
Yes. A common pattern fine-tunes a model on examples that include the retrieved context, so it learns to use that context the way you want.