Explainer/Artificial intelligence
What is fine-tuning an AI model?
Fine-tuning takes a trained AI model and teaches it your job with a small set of your own examples. Learn what it changes, what it cannot fix, and when to use something else.
Fine-tuning means taking an AI model that has already been trained and training it further on a smaller set of your own examples. The model keeps its general skill and picks up your style, your words and your task. It is far cheaper and faster than training a model from the start.
Think of a cook who has trained for ten years, and she can make hundreds of dishes. A small restaurant hires her on Monday. For two weeks the owner shows her the house recipes, the way this kitchen chops onions, and the ten meals people order most.
She does not learn to cook again. She learns this kitchen, and by the third week she cooks like the place has always been hers.
That second, shorter training is fine-tuning. The cook is a model that is already trained, and the house recipes are your examples. In other words, fine-tuning is how you turn a general model into one that does your job your way.
What fine-tuning actually changes
A model is a very large pile of numbers, and those numbers are called weights. During training, the model reads examples and nudges its weights until its guesses get better. Read our piece on how a neural network works if that part is new to you.
Fine-tuning nudges the same weights again. It uses far fewer examples and a much smaller nudge. Therefore, the model keeps almost all of what it knew, and it shifts a little way towards your examples.
How small is the shift? Small enough that the model still writes normal English, and big enough that it now answers the way your examples answer.
How it works, step by step
- Collect examples. Each one is a question plus the answer you wish the model had given.
- Split them. Keep most for training, and hold some back for testing.
- Run the training. The model reads each example and changes its weights by a small amount.
- Test on the examples you held back. The model has never seen them, so the score is honest.
- Keep the new model if it beats the old one, and throw it away if it does not.
Step four is the one people skip. Do not skip it, because without a held-back test you are guessing.
What fine-tuning is good at
Fine-tuning is best at shape. Shape means the format, the tone, the length and the way a job gets done.
- Making every answer come out in the same format, such as a filled form or a fixed set of fields.
- Teaching a house voice, so support replies sound like your firm.
- Teaching a narrow task the model does badly, such as sorting messages into your own twelve groups.
- Making a small model good enough at one job to replace a big, costly one.
That last point is the one that saves money. A small model that has been fine-tuned on one task often beats a much larger general model on that same task. It also costs less to run.
You already meet fine-tuned models every day. The assistant inside a coding tool, the model that reads a scanned invoice, the system that grades a support ticket by mood. Each one began as a general model and was then taught one job.
What fine-tuning is bad at
Fine-tuning is a weak way to add facts. Say you fine-tune a model on your price list. Prices change on Friday, so now you have to train again.
Worse, the model may mix the old prices into new answers and sound sure of itself. Why? Because training teaches habits. The model learned the shape of a price answer. However, it did not learn the price.
Therefore keep facts outside the model. Put them in a database or a folder of documents, and let the model look them up when asked. That method is called retrieval. Use fine-tuning for how to answer, and use retrieval for what is true.
Prompt, retrieval or fine-tune: how to choose
| Method | Use it for | Effort |
|---|---|---|
| A better prompt | Small changes in tone or format | Minutes |
| Retrieval | Facts that change, and private documents | Days |
| Fine-tuning | A fixed style, or one narrow task at scale | Weeks |
Start at the top of that table, and move down only when the row above fails. However, many teams that fine-tune early find out later that a better prompt would have done the job.
How much data you need
Less than people expect, and many useful runs use a few hundred to a few thousand examples. Quality beats volume every time.
Ten examples that are exactly right teach more than a thousand that are almost right. This is because the model copies what it sees, and that includes the mistakes. Feed it sloppy answers and it will learn to be sloppy.
Balance matters too. If nine in ten of your examples are complaints, the model will start treating every message as a complaint. Count your examples by type before you train.
One more warning. If all your examples are short, the model will start giving short answers to everything. This is because, during that training run, your examples are the whole world.
Cheaper ways to do it
Full fine-tuning changes every weight in the model, and that needs a lot of memory and a lot of money.
So most teams use a lighter method. You add a small set of new weights beside the model and train only those. The big model stays frozen, and the small add-on carries the change. The best known version of this idea is called LoRA, short for low-rank adaptation.
The result is a small file you can store, swap and share. One base model can host many of these add-ons, one for each task. Our piece on large language models covers how that base model is built in the first place.
What to check before you fine-tune
Ask three questions. Do I have examples of the exact output I want? Is my problem about style rather than facts? Have I already tried a better prompt?
If you answer no to any of them, wait. Paying to fine-tune a model you have not yet tested is the most common waste of money in applied machine learning.
Then do this today. Write out twenty perfect answers by hand, the way you wish the model would answer. If you cannot write twenty, you do not yet know what you want. If you can, you have started your training set. FINE-TUNING TEACHES STYLE, NOT FACTS.
Just Out Tech explains new research in plain language. This article was drafted with AI assistance and checked by a human against the original source.
- Fine-tuning adjusts an already trained AI model with a small set of your own examples, so it answers in your format and your voice.
- Fine-tuning is a weak way to store facts that change, because the model learns the shape of an answer rather than the answer itself.
- A small fine-tuned model often beats a much larger general model on one narrow task, and it costs less to run.
Questions people ask
how much data do you need to fine-tune a model
Less than most people expect. Many useful fine-tunes run on a few hundred to a few thousand examples. Quality matters far more than volume, because the model copies the examples closely, including their mistakes. Twenty examples that are exactly right are a better start than a thousand rough ones.
is fine-tuning better than retrieval
They solve different problems, so the question is which one your problem needs. Fine-tuning teaches a model how to answer, such as the format and the tone. Retrieval gives the model the facts it needs at the moment of the question. If your facts change, use retrieval. If your style is wrong, fine-tune.
does fine-tuning make a model smarter
No. Fine-tuning does not add general reasoning ability. It makes the model better at the narrow task shown in your examples, and it can make the model slightly worse at everything else. That trade is usually worth it when you only care about one job.
how much does it cost to fine-tune a model
It depends on the size of the model and the method. Light methods that train a small add-on instead of the whole model are the cheapest, and small models can be tuned for the price of a few hours of rented computing. The larger cost is usually human time spent writing and checking the examples.