Explainer
What is fine-tuning?
What does fine-tuning a model actually mean?
A model’s behavior is stored in its weights, which are billions of numbers adjusted during training. Fine-tuning nudges those numbers using your own examples. You show the model many input and ideal-output pairs, measure how far its answers are from the ideal, and adjust the weights a little to close the gap. Repeat across the dataset, often a few times.
The result is a new version of the model that behaves differently by default. If you fine-tune on 2,000 examples of support replies in your house style, the model starts writing that way without needing a long style guide in every prompt.
How is fine-tuning different from pretraining?
Pretraining builds a model from scratch. The model reads an enormous amount of text and learns to predict the next token, which teaches it grammar, facts, and reasoning patterns. It takes huge computing clusters, weeks or months, and budgets that only a handful of organizations can afford.
Fine-tuning starts where pretraining ended. It uses far less data (hundreds to tens of thousands of examples instead of trillions of tokens) and far less compute. Think of pretraining as a general education and fine-tuning as on-the-job training for one role.
Fine-tuning vs prompting: what is the difference?
Prompting steers a model at the moment you use it, through instructions and examples in the input. It is instant, cheap to change, and needs no training. Fine-tuning bakes behavior in ahead of time. It takes data and effort, but can make behavior more consistent and let you use shorter prompts.
A good rule: if you can describe what you want and the model can do it when asked well, prompting is enough. Fine-tuning earns its place when you need behavior that is hard to describe but easy to demonstrate, or when you need it consistently across millions of calls.
What are the main types of fine-tuning?
Supervised fine-tuning (SFT) is the basic form: train on example inputs paired with the exact outputs you want. Instruction tuning is SFT on a broad mix of tasks phrased as instructions, which is how raw pretrained models become helpful assistants that follow requests.
Preference tuning teaches a model which of two answers people prefer, rather than one correct answer. The best-known method is reinforcement learning from human feedback (RLHF). OpenAI’s 2022 InstructGPT paper reported that people preferred outputs from a 1.3-billion-parameter model tuned this way over the original 175-billion-parameter GPT-3. Newer methods such as direct preference optimization (DPO) reach similar goals with a simpler training setup.
Parameter-efficient fine-tuning (PEFT) changes only a small fraction of the model’s weights, or adds a few new ones, instead of updating everything. It is the most common way teams fine-tune open-weight models today.
What is LoRA and why is it so popular?
LoRA, short for low-rank adaptation, was introduced by Hu and colleagues at Microsoft in 2021. It freezes the original weights and trains small add-on matrices alongside them. On GPT-3, the authors reported cutting the number of trainable parameters by about 10,000 times and GPU memory needs by about 3 times compared with full fine-tuning, with similar quality.
Because the add-on (called an adapter) is small, often megabytes rather than gigabytes, you can keep one base model and swap in different adapters for different tasks or customers. QLoRA (2023) went further by compressing the frozen base model to 4-bit precision, making it possible to fine-tune a 65-billion-parameter model on a single 48 GB GPU.
When should you fine-tune instead of using RAG or better prompts?
Try better prompts first. Clear instructions, a few good examples, and a well-structured system prompt solve most problems at near-zero cost. Measure results on a test set so you know whether you actually have a gap.
Use retrieval-augmented generation (RAG) when the problem is knowledge: the model needs your documents, recent information, or facts that change. RAG keeps knowledge outside the model, so updating it is as easy as updating a document, and answers can cite their sources. Fine-tuning is a poor way to teach facts; the model may absorb them unreliably and cannot tell you where they came from.
Fine-tune when the problem is behavior: a strict output format, a consistent tone, a specialist classification task, or squeezing a smaller, cheaper model up to the quality of a larger one for one narrow job. Many production systems combine all three.
How much data do you need to fine-tune a model?
Less than most people expect, but it must be good. Narrow style or format tasks can improve with a few hundred carefully checked examples. Harder tasks, like a specialist classifier with many categories, often need thousands. Quality beats quantity: 500 consistent, correct examples usually outperform 5,000 noisy ones, because the model learns the mistakes too.
Your examples should look like real usage, cover edge cases, and be formatted exactly the way you want outputs to appear. Hold back a separate test set the model never trains on, so you can tell whether it really improved.
What are the costs and risks of fine-tuning?
The direct cost is training compute, which for a LoRA run on a modest open model can be small. The bigger costs are hidden: building and cleaning the dataset, evaluating results, hosting a custom model, and repeating the work when a better base model is released.
Overfitting happens when the model memorizes the training examples instead of learning the pattern, so it does well on familiar inputs and badly on new ones. Catastrophic forgetting is when training on a narrow task degrades abilities the model had before, such as general reasoning or following other instructions. Research has also found that fine-tuning can weaken a model’s built-in safety behavior, even with harmless-looking data.
The safeguards are the same in each case: keep a held-out test set, also test general skills you care about, train for as few passes as needed, and compare against the untuned model with a good prompt.
Prompting vs RAG vs fine-tuning
| Prompting | RAG | Fine-tuning | |
|---|---|---|---|
| What it changes | The instructions in each request | The information added to each request | The model’s weights |
| Best for | Most tasks; quick iteration | Private, large, or changing knowledge | Consistent format, tone, or narrow skills |
| Adds new facts reliably | Only what fits in the prompt | Yes, with citations | Not reliably |
| Setup effort | Minutes | Days to weeks | Weeks, including data work |
| Cost to update | Edit the prompt | Update the documents | Retrain the model |
| Data needed | None to a few examples | Your documents | Hundreds to thousands of labeled examples |
| Main risk | Inconsistent output | Retrieving the wrong passages | Overfitting, forgetting, upkeep |
Examples
- Fine-tuning a small model on 3,000 labeled tickets so it routes new support tickets to one of 40 categories more accurately than a large model with a prompt
- Training a model to always return a strict JSON structure for invoice extraction, cutting malformed outputs
- Teaching a writing assistant a brand’s voice from 800 approved marketing emails
- Using LoRA adapters to serve one base model with separate adapters for legal, medical, and finance customers
- Instruction tuning, which turned raw pretrained language models into assistants that follow requests
Common questions
Can fine-tuning teach a model new knowledge?
Somewhat, but it is unreliable for facts. The model may recall them inconsistently, mix them up, or state them confidently when wrong, and it cannot cite where they came from. For knowledge that needs to be accurate or kept current, retrieval-augmented generation (RAG) is usually the better tool.
Does fine-tuning stop hallucinations?
No. It can reduce certain errors, for example making a model more likely to say it does not know, but it does not guarantee factual accuracy. Grounding answers in retrieved sources, using tools to check facts, and human review are more dependable ways to reduce hallucinations.
Can I fine-tune ChatGPT or Claude?
It depends on the provider and model, and offerings change often. Some closed models can be fine-tuned through the provider’s platform or a cloud partner, while others cannot. Open-weight models can be fine-tuned by anyone with the hardware. Check each provider’s current documentation before planning a project.
How long does fine-tuning take?
The training run itself can take minutes to hours for a LoRA job on a small or mid-sized model, and longer for full fine-tuning of large models. Preparing and checking the data and evaluating the result usually take far longer than the training step.
What is the difference between fine-tuning and transfer learning?
Transfer learning is the general idea of reusing what a model learned on one task for another. Fine-tuning is the most common way to do it: start with a pretrained model and continue training on the new task. So fine-tuning is a type of transfer learning.
Is fine-tuning the same as training a model?
It is a kind of training, but a much smaller one. Training from scratch, or pretraining, builds all of a model’s abilities from raw data at huge cost. Fine-tuning adjusts an existing model with a small, targeted dataset, usually at a tiny fraction of that cost.
Sources and further reading
- LoRA: Low-Rank Adaptation of Large Language Models (Hu et al., 2021) — arXiv
- Training language models to follow instructions with human feedback (Ouyang et al., 2022) — arXiv
- QLoRA: Efficient Finetuning of Quantized LLMs (Dettmers et al., 2023) — arXiv
- Overcoming catastrophic forgetting in neural networks (Kirkpatrick et al., 2017) — arXiv
- PEFT documentation — Hugging Face
Glossary terms
- Fine-tuning
Fine-tuning is extra training applied to an already-trained AI model, using a smaller set of examples, so it performs better at a specific task, style or domain. It changes the model’s internal weights, producing a customised version rather than just giving it new instructions.
- LLM
An LLM (large language model) is an AI model trained on huge amounts of text to predict the next piece of text in a sequence. That one skill lets it answer questions, write, summarise, translate and code. ChatGPT, Claude and Gemini are apps built on LLMs.
- RAG
RAG (retrieval-augmented generation) is a technique where an AI system first searches a collection of documents for passages relevant to a question, then gives those passages to a language model to write the answer. It lets a model use current or private information it was never trained on.
- Hallucination
An AI hallucination is when a language model produces information that sounds confident and plausible but is false, invented or unsupported by its sources, such as a fake citation, a wrong date or a quote nobody said. The model is not lying; it is generating likely-sounding text.
Keep reading
- RAG vs fine-tuning
RAG (retrieval-augmented generation) gives a model new information at question time by searching your documents and pasting the relevant passages into the prompt. Fine-tuning changes the model itself by training it further on example inputs and outputs. Use RAG to change what the model knows; use fine-tuning to change how it behaves.
- What is RAG?
RAG (retrieval-augmented generation) is a technique where an AI system first searches a set of documents for passages relevant to your question, then gives those passages to a language model to write the answer. It lets the model use current, private, or specialized information it was never trained on, and makes answers easier to check against sources.
- What is an LLM?
An LLM (large language model) is an AI system trained on huge amounts of text to predict the next piece of a sentence. By doing that prediction billions of times, it learns grammar, facts, and patterns of reasoning well enough to answer questions, write, summarize, translate, and generate code. Chatbots like ChatGPT and Claude are built on LLMs.
- What is a system prompt?
A system prompt is a set of instructions given to an AI model before the conversation starts, telling it who it is, what it should do and how it should behave. Users usually never see it. It sets the role, tone, rules and background knowledge, while user prompts are the individual questions or requests that follow.
- Prompt vs context engineering
Prompt engineering is the craft of wording instructions so a model understands the task. Context engineering is the wider job of deciding everything the model sees on each call: system prompt, retrieved documents, tool definitions and results, memory, examples, and conversation history, all within a limited context window. Prompt engineering is one part of context engineering.
- Open-weight vs closed AI models
An open-weight AI model is one whose trained parameters (weights) you can download and run on your own hardware. A closed model is only available through the developer's app or API; you never get the weights. Open-weight models give you control and privacy; closed models usually give you the strongest capability with the least setup.