The capability
What fine-tuning is
As you already know from M4, the models you build with were trained by somebody else. A lab collected an enormous amount of data, trained on it for weeks on thousands of GPUs, and then published the result, which is basically a big file of numbers that we call the weights. When you call the model, those weights are what turn your input into an output, and so far in this course, whenever you wanted a different output, you changed the input, either with a better prompt or with documents that retrieval pulled in.
With fine-tuning, you change the weights themselves. You take the pretrained model and keep training it on a dataset of your own examples, where each example is an input paired with the output you wanted for it. The training loop is the same one the lab ran, just with far less data, and it starts from a model that's already good. The model reads an example and produces an output, and your training code compares that output with the one you wanted and turns the difference into a single number, which we call the loss. Then it nudges every weight a tiny amount in whichever direction would have made the loss smaller. It goes through every example in the dataset like that, usually several times, and one full pass over the dataset is what's called an epoch.
What you get out at the end is a new copy of the weights, or with some methods, a small extra file that sits on top of the original weights, and that's called an adapter. Either way, you've still got the same kind of model with the same inputs and outputs, so a fine-tuned text classifier still takes text and returns a label, and a fine-tuned LLM still takes a prompt and writes text back. What's different is how it behaves on inputs that look like your examples.

Now you might be asking what "the output you wanted" even looks like, since an LLM writes text and a classifier returns a label. It depends on the model, and it's the biggest difference between fine-tuning one kind of model and fine-tuning another. For an LLM, it's the text you wanted it to write. For an embedding model, it's which pairs of inputs should end up close together and which ones should end up far apart. For a classifier it's the correct label, and for a detector it's the correct box. That target, together with the loss that compares the model's output against it, is what people call the training objective. This module covers everything that stays the same no matter what the objective is, and then M41 to M43 each go deep on one objective.
Fine-tuning is good at changing how a model behaves, like the format it answers in or the labels it picks, but it can't reliably teach a model new facts. Gekhman et al. took an LLM and fine-tuned it on questions whose answers it hadn't learned in pretraining, and they found that those examples "are learned significantly slower than those consistent with the model's knowledge", and that once the model did learn them, they "linearly increase the model's tendency to hallucinate" (Gekhman et al., 2024). That was a controlled study on closed-book question answering, so it doesn't cover every kind of fine-tuning, but it's still a good reason not to count on fine-tuning for facts. If you want a model to know your product catalogue or this week's prices, that's a retrieval problem, which is what M19-1 covers.
I learned this the hard way when LLMs first came out. Back in 2023, I tried to fine-tune one on legal documents, because I wanted a model that could write a contract from start to finish and wouldn't forget what was in those documents. It didn't go well. With a lot more data, it might have picked up the right words and the right structure, but most of what makes a contract right is knowledge, and that knowledge has to stay up to date, which isn't something fine-tuning puts into a model. What surprised me was that the fine-tuned model ended up doing worse than the regular LLM I'd started from. That's one project from 2023, so it doesn't prove much on its own, but it lines up with what Gekhman et al. measured a year later.
Fine-tuning also learns whatever your dataset says, and that includes its mistakes, so if your dataset has mislabeled examples, you get a model that makes those same mistakes, and makes them confidently. And once you've fine-tuned a model, you own it, which means you have to test it on every change and retrain it when your data changes or when the base model you started from gets retired. Somebody also has to host it, and that's either you or a provider you pay.
Some places it shows up
- A classifier on your own labels, like sorting product photos into a marketplace's own categories, which no general image model has seen named that way. M13 shows the cheapest version of this, which is a small linear model trained on top of a frozen encoder.
- A search embedding model trained on your users' queries and the results they clicked, so that "similar" means what it means for your users. M42 covers how.
- A small LLM that writes in one fixed format, trained on outputs from a bigger model so it does the same job faster and for less money. When you train a small model on a bigger model's outputs, that's what people call distillation, and M41 covers it.
- A detector for your own objects, like the Blender icons in M20, trained on boxes a VLM drew. M43 covers how.
Those are a few examples, and the pattern is the same in all of them. You start from a pretrained model that's close to what you need, plus a dataset of examples that show the behavior you want, and then an eval tells you whether the new weights do better than the old ones on the inputs you care about.
Keep reading
The rest of this lesson is free with an account
Create a free account to read the remaining 14 sections. It takes about twenty seconds and there's nothing to pay. The same account opens the slide decks and CV reviews.
- 02Relist's pipeline failed in three places, and each was a different kind of model
- 03Try the fixes that don't need training first, and fine-tune what's left
- 04Change as little of the model as gets you the result
- 05Most of the work goes into the dataset
- 06Read the training config, and know what has to fit in memory
- and 9 more
That's the last one written so far
Pick your next module from the board.
