Fine-Tuning vs RAG vs Prompt Engineering: Which Should You Use?
Decide between prompting, RAG and fine-tuning: what each changes, cost and effort, data needs, and common combinations, with a practical decision guide.
Published December 1, 2026
When an LLM does not behave the way you want, there are three main levers: change the prompt, give it better information at runtime (RAG), or change the model itself (fine-tuning). Teams often jump to fine-tuning when a better prompt or retrieval would have solved the problem faster and cheaper. Each lever fixes a different kind of problem.
The concept
Prompt engineering changes instructions and examples. It is instant, cheap and should always come first. RAG adds relevant knowledge at query time; it is the right tool when the model lacks facts, especially facts that change or need citations. Fine-tuning trains the model further on examples; it changes behaviour, format, tone and narrow skills, and can let a smaller model match a larger one on a specific task.
Fine-tuning is a poor way to teach facts. It is expensive to update, provides no citations and can still hallucinate. Conversely, RAG cannot easily teach a model to always respond in a particular complex format or style. Many production systems combine them: a lightly fine-tuned or well-prompted model for behaviour, plus RAG for knowledge.
Comparison
| Prompting | RAG | Fine-tuning | |
|---|---|---|---|
| Fixes | Instructions, format, tone | Missing or changing knowledge | Consistent behaviour, style, narrow skills |
| Time to try | Minutes | Days | Days to weeks |
| Data needed | A few examples | Your documents | Hundreds-thousands of labelled examples |
| Updating | Edit text | Re-index docs | Retrain |
| Citations | No | Yes | No |
| Ongoing cost | Longer prompts | Retrieval infra + context tokens | Training + hosting custom model |
Decision guide
- Write a clear prompt with examples; measure with evals
- Model lacks facts or facts change? Add RAG
- Still inconsistent format/behaviour after good prompting? Consider fine-tuning
- Need lower cost/latency at scale? Fine-tune a smaller model on outputs that work
- Combine: fine-tuned behaviour + RAG knowledge
Diagnose first
Practical examples
Few-shot prompting before fine-tuning
Examples in the prompt often close the gap.
Classify the commit message into feat, fix, docs, refactor or chore.
"add dark mode toggle" → feat
"fix crash when cart empty" → fix
"update README install steps" → docs
Message: "{message}" →Fine-tuning data format (chat style JSONL)
Each line is one example conversation.
{"messages": [{"role": "system", "content": "You write release notes."},
{"role": "user", "content": "PR: add CSV export to reports"},
{"role": "assistant", "content": "• Reports can now be exported as CSV."}]}LoRA fine-tuning sketch (Hugging Face PEFT)
Train small adapters instead of all weights.
from peft import LoraConfig, get_peft_model
config = LoraConfig(r=16, lora_alpha=32, target_modules=["q_proj", "v_proj"], lora_dropout=0.05)
model = get_peft_model(base_model, config)
model.print_trainable_parameters() # a tiny fraction of total parametersCommon mistakes
- Fine-tuning to add company knowledge that changes monthly.
- Skipping evals, so you cannot tell whether fine-tuning helped.
- Fine-tuning on small, noisy datasets.
- Using RAG to enforce output style instead of prompting or fine-tuning.
Key takeaways
- Prompting first, RAG for knowledge, fine-tuning for behaviour.
- Fine-tuning is poor at teaching facts; RAG is poor at teaching style.
- Diagnose the failure before choosing the lever.
- Measure every change with evals.
FAQ
Is fine-tuning expensive?
Parameter-efficient methods like LoRA make it much cheaper than full training, but data preparation, evaluation and hosting are the real costs.
Can I fine-tune hosted frontier models?
Some providers offer fine-tuning for selected models; others only support prompting and RAG. Check current offerings.
What is distillation?
Training a smaller model on outputs from a larger one, often to cut cost and latency for a specific task.