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

PromptingRAGFine-tuning
FixesInstructions, format, toneMissing or changing knowledgeConsistent behaviour, style, narrow skills
Time to tryMinutesDaysDays to weeks
Data neededA few examplesYour documentsHundreds-thousands of labelled examples
UpdatingEdit textRe-index docsRetrain
CitationsNoYesNo
Ongoing costLonger promptsRetrieval infra + context tokensTraining + hosting custom model

Decision guide

  1. Write a clear prompt with examples; measure with evals
  2. Model lacks facts or facts change? Add RAG
  3. Still inconsistent format/behaviour after good prompting? Consider fine-tuning
  4. Need lower cost/latency at scale? Fine-tune a smaller model on outputs that work
  5. Combine: fine-tuned behaviour + RAG knowledge
A pragmatic order of operations.

Diagnose first

ProblemDiagnosewhat is actually wrong?Wrong facts→ RAGWrong format/tone→ prompt, then fine-tuneToo slow/expensive→ smaller fine-tuned modelUnclear task→ better instructions
Match the lever to the failure.

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 parameters

Common 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.

More AI articles