"Let's fine-tune a model on our documents" is one of the most common lines in AI projects, and the real request is almost always something else. The team wants the model to know the company's rules, and RAG handles that better and cheaper. Fine-tuning shines somewhere else: when the problem isn't what the model knows, but how it behaves.
This article breaks the term down from start to finish: what it is, when it's worth it, each kind of tuning, how LoRA and QLoRA work under the hood, the steps of a project and where to do it in 2026. Each part has an animation, so the idea gets in through your eyes before the formula does.
An Analogy to Start
Think of the model as a doctor fresh out of medical school. They studied for years (the pre-training, on trillions of tokens) and know a lot of general things.
- Prompt is the instruction for the shift: "today, prioritize the pediatric cases and answer in bullet points".
- RAG is handing over the patient's chart during the appointment: they read it and answer based on what's in there.
- Fine-tuning is residency: months practicing one kind of case until the way they work changes. After it, they no longer need the instruction every shift.
Residency changes habits. It isn't meant for memorizing every patient's chart, and that's where the most common mistake lives.

Prompt, RAG or Fine-tuning: What Solves What
The question that decides it: what is the model missing?
| What's missing | Example | Best path | Why |
|---|---|---|---|
| A clear instruction | "Answer in JSON with these fields" | Prompt, structured output | Solved in minutes, and you can change it whenever you want |
| Knowledge that changes | Prices, policies, help center | RAG | You update the document, not the model, and it cites the source |
| Repeated behavior | Classifying tickets the house way, brand voice, rigid format | Fine-tuning | Examples teach what's hard to describe in text |
| Cost and latency | A narrow task running millions of times | Fine-tuning a smaller model, or distillation | A small tuned model can replace a large one |
OpenAI itself writes in its optimization guide that the prompt engineering process "may be all you need", and Anthropic points out that not every failure is fixed with a prompt: sometimes switching models improves cost and latency with less effort. The article on RAG vs CAG goes deeper on the knowledge side, and the one on RAG techniques shows how to get the most out of it before you think about training.
The Kinds of Tuning, One by One
"Fine-tuning" is an umbrella term. Under it sit techniques with different goals.
| Kind | The data that goes in | What changes in the model | When it makes sense |
|---|---|---|---|
| Continued pre-training | Lots of raw domain text | Vocabulary and familiarity with the subject | A very specific domain (legal, medical) with plenty of text available |
| Supervised (SFT) | Pairs of question and ideal answer | Format, tone, a specific task | The starting point of almost every project |
| Preference-based (RLHF, DPO) | Pairs of a good answer and a bad answer | What "better" means between similar options | Tuning style, safety, helpfulness |
| Reinforcement for reasoning (GRPO) | Problems with a verifiable answer | The ability to reason in steps | Math, code, tasks with automatic checks |
| Distillation | Answers from a large model | A small model imitating the large one | Cutting cost and latency while keeping quality on one task |
Supervised: Learning by Example
This is the most common one. You build examples in conversation format, with the question and the answer you'd like to see, and the model learns to imitate them. At OpenAI the format is JSONL, one conversation per line, with a messages list of roles and contents. The minimum accepted is 10 examples, and the guide says improvements show up with 50 to 100.
{"messages": [
{"role": "system", "content": "Classify the ticket."},
{"role": "user", "content": "My bill is past due and I can't generate a new one."},
{"role": "assistant", "content": "{\"category\": \"billing\", \"urgency\": \"high\"}"}
]}One detail that sinks a lot of projects: the chat template. Each open model was trained with its own control tokens that mark where each message starts and ends. The Hugging Face docs warn that with the wrong control tokens, these models perform "drastically worse". Always train with the same template the model uses. If the idea of a token is still fuzzy, the article on tokens explains it with measured examples.
Preference-based: Learning by Comparing
Sometimes it's easy to say which answer is better and hard to write the perfect one. Preference tuning uses pairs: for the same question, a chosen answer and a rejected one.
Classic RLHF first trains a reward model and then optimizes the main model against it, with reinforcement learning. The article on reinforcement learning and RLHF tells that story at a slower pace. In 2023, the DPO (Direct Preference Optimization) paper showed a shortcut: by rewriting the math, you can solve the same problem "with only a simple classification loss". In practice, it's simpler and more stable to train, which is why it became the default in libraries like TRL and Axolotl.
Reinforcement for Reasoning: Learning by Checking
On tasks with a verifiable answer (the math works out, the test passes), you can let the model try several times and reward the attempts that get it right. GRPO, introduced in the DeepSeekMath paper in 2024, is a variant of PPO that compares answers within the same group against each other and saves the memory PPO used to spend. DeepSeek-R1, published in Nature in 2025, showed that reasoning ability "can be incentivized through pure reinforcement learning", without relying on reasoning traces written by humans.
It's the most expensive and most delicate technique on the list. For most company projects, SFT and DPO get the job done.
Distillation: The Big One Teaches the Small One
The idea dates back to 2015, from Hinton and coauthors: compress the knowledge of a large model (or an ensemble of models) into a smaller one. With LLMsAI model trained on large amounts of text to predict the next word, which lets it chat, summarize, translate and write code., the typical playbook is to generate high-quality answers for your task with a large model and use them for SFT on a small model. It works well when the task is narrow and the volume is high. Before you start, check whether the large model's license allows using its outputs to train another one.
Full Tuning or Just a Piece
In full fine-tuning, every weight in the model changes. It gives you the most freedom, but it needs memory to hold the weights, gradients and optimizer states of billions of parameters, and it produces a whole copy of the model for each tuning run.
PEFT (Parameter-Efficient Fine-Tuning) is the family of techniques that tune only a small part, "a small number of (extra) model parameters instead of all the model's parameters", in the words of the PEFT library. The most widely used one is LoRA.
LoRA: Two Small Matrices Next to the Model
A model is, for the most part, a pile of weight matrices. Tuning means adding a correction to each of them. LoRA's insight (Low-Rank Adaptation, 2021) is that this correction can be written as the product of two thin matrices, called A and B. The original model stays frozen, and only A and B learn.
An example with round numbers helps show how big the savings are. A 4,096 by 4,096 matrix has about 16.8 million weights. With a LoRA of rank 8, the two strips have 4,096 × 8 + 8 × 4,096 = 65,536 weights. That's less than 0.4% of the original, and the rank is the knob you turn: higher means more capacity and more memory.
In the original paper, compared with full fine-tuning of GPT-3 175B, LoRA cut "the number of trainable parameters by 10,000 times and the GPU memory requirement by 3 times". And since the result is a small file (the adapter), you can keep dozens of specializations on top of the same base model.
There's a price. The study "LoRA Learns Less and Forgets Less" (2024) measured that, at the common low-rank settings, LoRA "substantially underperforms full finetuning" on new and hard tasks such as code and math. In exchange, it better preserves what the model already knew outside the tuning domain. For changing format and tone, that's usually an advantage.
QLoRA: The Base Model Compressed to 4 Bits
LoRA saves on what gets trained, but the base model still has to fit on the GPU. QLoRA (2023) goes after that part: it stores the base model in 4 bits instead of 16 and trains the LoRA adapters on top. The paper fine-tuned a 65-billion-parameter model "on a single 48GB GPU" while matching the performance of 16-bit tuning.
There are three tricks: a 4-bit format designed for how weights are distributed (NF4), double quantization (it even compresses the compression constants) and paged optimizers, which move data to regular memory during spikes so the GPU doesn't overflow.
How much memory does that come to in practice? The Unsloth docs publish the absolute minimums:
| Model | QLoRA (4 bits) | LoRA (16 bits) |
|---|---|---|
| 7B | 5 GB | 19 GB |
| 8B | 6 GB | 22 GB |
| 70B | 41 GB | 164 GB |
In other words: with QLoRA, an 8B model fits for training on a consumer graphics card, and a 70B model fits on a single data center GPU.
The Steps of a Project
- Define the task and the metric. "Getting better" isn't a metric. "Getting the category right on 95% of the tickets in the test set" is.
- Measure the baseline. Run the task with a good prompt, with and without RAG. That's the number the tuning has to beat.
- Build the data. Start with 50 well-made examples, as OpenAI recommends. Quality beats volume: a wrong example teaches the mistake. Set aside a test set that never goes into training.
- Pick the model and the method. For most people: SFT with LoRA or QLoRA on an open 7B to 8B model. Use the model's chat template.
- Train. The most used tools are in the table below. Start with few epochs and watch the loss on the validation set.
- Evaluate. On your test set first. Then on general benchmarks, to see whether the model forgot something important. EleutherAI's lm-evaluation-harness has "over 60 standard academic benchmarks".
- Serve. vLLM loads LoRA adapters on top of the base model with
--enable-loraand--lora-modules, and the client picks the adapter through the request'smodelfield. The S-LoRA paper showed you can serve "thousands of LoRA adapters" on one GPU.
| Tool | What it is | Version (Nov 21, 2026) |
|---|---|---|
| TRL | Hugging Face library with trainers for SFT, DPO, GRPO, KTO and reward models | 1.18.2 |
| PEFT | LoRA and other techniques that tune few parameters | 0.22.0 |
| Unsloth | Optimized training; promises "2× faster with 70% less VRAM" | 2026.11.9 |
| Axolotl | Config-file framework: full, LoRA, QLoRA, DPO, GRPO | 0.21.1 |
| LLaMA-Factory | Unified interface for over 100 models, with SFT, DPO, PPO and more | 0.9.5 |

Fine-tuning Through an API in 2026
Training through an APIContract that defines how one program asks another for data or actions: which endpoints to call, what to send and what comes back. On the web, usually HTTP with JSON. is simpler (you send the data and get a model back), but the landscape has changed a lot:
- OpenAI: the docs say the company "is winding down the fine-tuning platform" and that the platform "is no longer accessible to new users". Eligible customers can create jobs until January 6, 2027, unless the base model is retired first.
- Google Vertex AI: offers supervised tuning of Gemini on models such as 3.5 Flash, 3.1 Flash-Lite and 2.5 Pro.
- Anthropic: there's no documented Claude fine-tuning on its own API. The official route I found is Claude 3 Haiku on Amazon Bedrock, only in the us-west-2 region.
For anyone starting a project today, that pushes the decision in two directions: prompt, RAG and tools on a closed model, or tuning an open model you control.
Quick check
Frequently Asked Questions
Does fine-tuning teach the model new things?
A little, but poorly: it mixes things up, forgets and can't tell you where it got them. For knowledge, especially knowledge that changes, RAG is the way. Fine-tuning is for behavior: format, tone, task.
How many examples do I need?
OpenAI accepts as few as 10 and says improvements show up with 50 to 100. If 50 well-made examples don't change anything, the guide recommends rethinking the task or the prompt before collecting more data.
Do I need my own GPU?
Not necessarily. With QLoRA, an 8B model trains with about 6 GB of video memory, according to Unsloth. You can rent a GPU by the hour or use a cloud notebook with a GPU.
Can I fine-tune ChatGPT or Claude?
At OpenAI, the platform is being shut down and is closed to new users. At Anthropic, there's no documented tuning on its own API; the official route is Claude 3 Haiku on Amazon Bedrock. At Google, Vertex AI tunes Gemini models.
Is LoRA worse than full fine-tuning?
On new and hard tasks, such as code and math, full fine-tuning learns more. In exchange, LoRA better preserves what the model already knew and costs much less. For format and tone, it's usually enough.
References
- LoRA: Low-Rank Adaptation of Large Language Models, Hu et al., 2021
- QLoRA: Efficient Finetuning of Quantized LLMs, Dettmers et al., 2023
- Direct Preference Optimization, Rafailov et al., 2023
- LoRA Learns Less and Forgets Less, Biderman et al., 2024
- Distilling the Knowledge in a Neural Network, Hinton, Vinyals and Dean, 2015
- DeepSeekMath, which introduces GRPO, Shao et al., 2024
- DeepSeek-R1 in Nature, 2025
- S-LoRA: Serving Thousands of Concurrent LoRA Adapters, 2023
- LoRA adapters in vLLM
- Chat templates, Hugging Face Transformers
- lm-evaluation-harness, EleutherAI
- Unsloth memory requirements
- Model optimization and supervised fine-tuning, OpenAI
- Supervised tuning for Gemini, Vertex AI
- Models that support customization in Amazon Bedrock