# Fine-tuning vs RAG vs prompt engineering: which should you use? · AI in Bed

https://www.aiinbed.com/blog/fine-tuning-vs-rag-vs-prompt-engineering · Published 2026-11-25

**Short answer:** Start with prompt engineering, add RAG when the model needs facts it doesn't have, and fine-tune only when you need to change how the model behaves. Prompting changes the instructions, RAG changes what the model can read when it answers, and fine-tuning changes the model's weights by training it on examples. LoRA is a cheap way to fine-tune that trains a small add-on instead of the whole model.

### The short version

Think of a new employee. **Prompting** is giving them clear instructions. **RAG** is handing them the right binder before each question. **Fine-tuning** is sending them on a training course so the skill sticks.

- **Prompt engineering** changes: the instructions. Cost: minutes. Good for: almost everything, first.
- **RAG** changes: what the model reads when it answers. Cost: some setup and a search index. Good for: private, changing or citable facts.
- **Fine-tuning** changes: the model's weights. Cost: example data, a training run and evaluation. Good for: consistent style, strict formats, specialist tasks, smaller cheaper models.

### 1. Prompt engineering: always try this first

A clear [prompt](https://www.aiinbed.com/glossary/prompt) with a role, context, the exact output format and a couple of examples ([few-shot prompting](https://www.aiinbed.com/glossary/few-shot-prompting)) solves more problems than people expect. It costs nothing, you can change it in seconds, and it works with any model.

Its limit: the model still only knows what it learned in training, and long, complicated prompts get expensive and fragile. Our [prompt engineering guide](https://www.aiinbed.com/blog/prompt-engineering-for-beginners) has templates to start from.

### 2. RAG: when the model needs your facts

If the answer lives in documents the model has never seen, such as your product manual, last week's prices or internal policies, use retrieval-augmented generation. The system searches your documents and puts the best passages in the prompt. You can update the knowledge just by adding a file, and answers can cite their sources.

RAG doesn't teach the model new habits, though. If it writes in the wrong tone or ignores your format, more documents won't fix that. Full explanation: [what is RAG](https://www.aiinbed.com/blog/what-is-rag).

### 3. Fine-tuning: when you need new behaviour

[Fine-tuning](https://www.aiinbed.com/glossary/fine-tuning) continues training a model on your own examples, usually hundreds to thousands of input and ideal-output pairs. The model's [parameters](https://www.aiinbed.com/glossary/parameters-weights) shift so the behaviour becomes the default, without long instructions.

Fine-tuning is worth it when you need:

- A **consistent voice or format**, every time, such as a strict JSON layout or a house style.
- A **narrow skill** done well, like classifying support tickets or extracting fields from invoices.
- A **smaller, cheaper model** that matches a big one on your one task. This is related to [knowledge distillation](https://www.aiinbed.com/glossary/knowledge-distillation).

It's a poor way to add facts. Models learn facts from fine-tuning unreliably and can mix them up, and you'd have to retrain every time something changes. It can also make a model worse at things you didn't train on, so you need an [eval](https://www.aiinbed.com/glossary/eval) to check.

### What is LoRA? Fine-tuning on a budget

Fully fine-tuning a model with billions of parameters needs lots of GPU memory. [LoRA](https://www.aiinbed.com/glossary/lora) (low-rank adaptation, from a 2021 Microsoft paper) freezes the original model and trains a pair of small extra matrices next to some of its layers. Those adapters are often well under 1% of the model's size, so training is far cheaper and the result is a small file you can swap in and out.

**QLoRA** (2023) goes further: it stores the frozen model in 4-bit [quantisation](https://www.aiinbed.com/glossary/quantisation) and trains LoRA adapters on top, which made it possible to fine-tune large models on a single GPU. The [efficient fine-tuning lesson](https://www.aiinbed.com/learn/advanced/efficient-finetuning) walks through both.

> Fine-tuning tools are free and open: Hugging Face's PEFT and TRL libraries support LoRA and QLoRA, and many cloud AI providers offer fine-tuning through their APIs.

### Using them together

These aren't rivals. A strong production system often uses all three: a fine-tuned model that reliably follows the format, RAG to supply current facts, and a carefully written prompt holding it together. Build in that order, and measure at each step whether the next one is worth it.

### Key takeaways

- Prompt engineering: change the instructions. Fastest and free.
- RAG: give the model the right documents at answer time. Best for facts.
- Fine-tuning: train the model on examples. Best for style, format and narrow skills.
- LoRA and QLoRA make fine-tuning affordable on a single GPU.

### Questions

**What is the difference between fine-tuning and RAG?**

RAG gives a model relevant documents to read at the moment it answers, without changing the model. Fine-tuning trains the model on examples, changing its weights so it behaves differently. RAG is better for facts; fine-tuning is better for style, format and narrow skills.

**When should I fine-tune an LLM?**

Fine-tune when good prompts and RAG still don't give consistent results: you need a fixed format or voice every time, a specialist task done reliably, or a smaller, cheaper model that matches a bigger one on one job.

**What is LoRA in AI?**

LoRA (low-rank adaptation) is a cheap way to fine-tune a large model. It freezes the original weights and trains small add-on matrices, so it needs much less memory and produces a small adapter file.

**Is prompt engineering enough?**

Often, yes. Clear instructions, context and a few examples solve many tasks. Add RAG when the model needs information it doesn't have, and fine-tuning only when behaviour still isn't consistent.

### Sources

- [LoRA: Low-Rank Adaptation of Large Language Models](https://arxiv.org/abs/2106.09685) by Hu et al. (Microsoft), 2021
- [QLoRA: Efficient Finetuning of Quantized LLMs](https://arxiv.org/abs/2305.14314) by Dettmers et al., 2023
- [Hugging Face LLM Course](https://huggingface.co/learn/llm-course) by Hugging Face
