Fine-Tuning vs Prompt Engineering vs RAG: Which Approach for Which Need
Three ways to adapt a generic LLM to your use case, three very different costs and trade-offs. Here is how to choose without getting it wrong.
Facing a specific need, three levers let you adapt a generic LLM: prompt engineering changes the question, RAG changes the context you give the model, fine-tuning changes the model itself. They are not competitors. Each solves a different problem, and a production system often uses all three. This is how to tell which problem you actually have.
The three approaches at a glance
| Aspect | Prompt engineering | RAG | Fine-tuning |
|---|---|---|---|
| What it changes | The instruction | The context given to the model | The model weights |
| Solves | Output shape, one-off quality | Missing or private knowledge | Consistent behaviour, tone, format |
| Cost to start | Near zero | Moderate: a vector store and a pipeline | High: labelled data plus a training run |
| Time to iterate | Minutes | Reindex, minutes to hours | A new training run, hours to days |
| Freshness | Not applicable | Instant, reindex the document | Stale, needs retraining |
| Traceability | None | Cite the exact source | None |
| Best for | Prototyping, quick wins | Q&A over your data, support, search | Brand voice, strict format, a narrow task |
Read the table as a shortlist tool. The sections below explain when each row actually matters.
Prompt engineering: the cheapest lever, try it first
Rewording the instruction, giving worked examples (few-shot), structuring the expected output as a JSON schema or tagged sections, asking the model to reason step by step, framing a role. None of this needs code or extra infrastructure, and modern models follow instructions well enough that a careful prompt often removes the need for anything heavier. It is always the first thing to try.
- ✓Does well: shaping the output, improving a specific answer, enforcing a format on a small scale.
- ✓Limit: it gives no access to knowledge the model was never trained on.
- ✓Limit: a long prompt stuffed with context to compensate becomes expensive on every call and fragile across model versions.
RAG: when the need is knowledge, not behaviour
Retrieval-Augmented Generation embeds your documents, stores them in a vector database, retrieves the most relevant chunks at query time, and injects them into the prompt as context. It answers a lack of factual, private or fresh knowledge: your documentation, your catalog, your internal data. It trains nothing. The model stays generic; you change what it sees. See the full RAG guide for the pipeline in detail.
- ✓Advantage: updates are instant, you reindex the changed document and the next answer reflects it.
- ✓Advantage: traceability, each answer can cite the exact source it came from.
- ✓Advantage: no training data to build, and the underlying model stays swappable.
- ✓Limit: it does not change how the model writes or reasons. Retrieval quality caps answer quality.
- ✓Limit: it adds a vector store and a pipeline to operate.
Large context windows do not remove the need for RAG. You can fit more documents in the prompt now, but stuffing everything in still costs money on every call, dilutes the model's attention across irrelevant text, and gives you no way to say which document an answer came from. RAG is about retrieving the right context, not about working around a small window.
Fine-tuning: when the need is behaviour, not knowledge
Fine-tuning continues training the model on your own examples to durably change its behaviour: a specific brand voice, a rigid output format, a narrow specialised task such as classification or structured extraction, or simply shorter prompts because the behaviour is now baked in. It needs a curated dataset of input and output pairs, typically hundreds to thousands. LoRA and QLoRA make it far cheaper than full fine-tuning by training a small set of adapter weights.
// Fine-tuning data: input/output pairs, one JSON object per line (JSONL)
{"messages": [
{"role": "system", "content": "You are the support assistant for Acme."},
{"role": "user", "content": "How do I reset my password?"},
{"role": "assistant", "content": "Open Settings, then Security, then Reset password. A link is emailed to you."}
]}
{"messages": [ /* ... */ ]} // hundreds to thousands more, all in the target styleThe classic mistake is fine-tuning a model to teach it facts, like your refund policy or your price list. It is the wrong tool: those facts change, and every change needs a new training run. Facts belong in RAG. Fine-tuning is for how the model behaves, not what it knows.
Fine-tuning is not the same as embeddings
A frequent confusion. An embedding model turns text into a vector so you can search by similarity. It is the retrieval half of RAG, and it never generates an answer. Fine-tuning changes the weights of a generative model so it writes differently. You can fine-tune an embedding model to improve retrieval on your domain, but that is a separate task from fine-tuning the LLM that produces the response. Different model, different job.
How to choose: a decision path
- ✓The output is wrong in shape or quality, on a one-off basis: prompt engineering.
- ✓The model lacks facts it was never trained on, or that change often: RAG.
- ✓The model knows the facts but writes them in the wrong tone, format or level of detail, consistently: fine-tuning.
- ✓Your prompt is getting huge just to enforce a style: fine-tuning, to move that style into the model and shrink the prompt.
- ✓You need to show where an answer came from: RAG, never fine-tuning.
Combining them
The three approaches stack. A production assistant often uses all of them: a fine-tuned model for tone and format, RAG for the facts, and a carefully engineered prompt to wire the retrieved context and the task together. The order to add them is the order of cost: start with prompt engineering, add RAG when knowledge is the gap, and reach for fine-tuning last, once behaviour is still off after the first two.
A concrete example: an internal support assistant. Prompt engineering sets the task and the answer structure. RAG pulls the relevant help-center articles and internal runbooks for each question. Fine-tuning, added only after the first version is live, teaches the model to answer in short numbered steps and to always end with a link to the source, so the prompt no longer has to spell that out every time.
Cost and effort, in order
- ✓Prompt engineering: hours, no infrastructure, iterate in minutes.
- ✓RAG: days to weeks to build the pipeline, an ongoing cost for the vector store and the embedding calls, iterate by reindexing.
- ✓Fine-tuning: weeks to assemble and label the data, a training run, and a new run for every behaviour change. Highest fixed cost, lowest marginal cost once it is trained.
FAQ
What is the difference between RAG and fine-tuning?
RAG gives the model information at query time without changing the model; fine-tuning changes the model's weights before any query. RAG is for knowledge that is private, large, or changes often. Fine-tuning is for behaviour that must be consistent. A RAG answer can cite its source; a fine-tuned answer cannot.
RAG or fine-tuning for a chatbot on my documentation?
RAG. The chatbot needs your documentation as knowledge, and that documentation changes. Fine-tuning would bake a snapshot of it into the model and go stale on the next update. Add light fine-tuning on top only if you also need a very specific answer style that prompting cannot hold.
Is fine-tuning an LLM the same as training an embedding model?
No. Embedding models are trained for similarity search and feed the retrieval step of RAG. Fine-tuning an LLM changes how it generates text. They are different models doing different jobs, and improving one does not improve the other.
Can prompt engineering replace RAG?
Only up to a point. You can paste a few documents into the prompt, but it does not scale: the context window fills up, the cost rises on every call, and you have no retrieval step to pick the relevant parts. Past a handful of documents, RAG is the right tool.
The question is never which approach is best. It is what problem you have. A knowledge gap is a RAG problem. A behaviour gap is a fine-tuning problem. A phrasing gap is a prompt problem. Most real systems have more than one, and use more than one.
Want to add AI to your application?
AI & RAG Integration →