A language model that can write fluent English may still be no use for a narrow, repetitive job. This course teaches you to change that with a small amount of training, and to prove whether the change worked.
This lesson explains what you will do and how the course measures success. It also has four short self-checks, so you can confirm you have what the course assumes before you install anything.
Three ideas in one sentence each
- Supervised fine-tuning trains an existing model further on examples of the inputs and outputs you want, so it imitates them.
- LoRA (low-rank adaptation) freezes the model's own weights and trains a small add-on, the adapter, made of pairs of thin matrices. The adapter is typically a few percent of the model's size or less.
- QLoRA does the same with the frozen weights stored in 4 bits instead of 16 or 32, which cuts the memory the frozen model needs.
A model plus an adapter behaves like a changed model, but the original stays intact. You can switch an adapter off, swap in another, or merge it permanently into a copy of the model. The course covers all three.
The course task
All core lessons use one task, so that every technique is measured on the same problem. Larkmoor Outdoor Centre is a fictional centre whose staff send short equipment reports. The task is to turn each report into one JSON record with five fields.
The model receives a system message and the report:
system: Convert equipment reports to JSON records.
user: Keys: asset, equipment, category (repair, cleaning, replacement, inspection),
location, priority (low, normal, high, urgent).
Report: Hi, the harness HN-10 at the boathouse smells of damp. Please take it out of use now.
It should reply with exactly this:
{"asset": "HN-10", "equipment": "harness", "category": "cleaning", "location": "boathouse", "priority": "urgent"}
Three fields are copied from the report: the asset, the equipment and the location. Two must be interpreted:
- Category: "smells of damp" means cleaning, and "is broken" means repair.
- Priority: "Please take it out of use now" means urgent. "No rush" means low. Saying nothing about timing means normal.
That difference matters later: models learn to copy long before they learn to interpret.
What changes, measured
The course model is SmolLM2-135M-Instruct, a small open model that runs on an ordinary laptop. Here is what it does with the first three validation reports, before and after the LoRA adapter you train in Train your first LoRA adapter. These are real replies from the course's tested runs, shortened where they ran on.
| Report | Untuned model | After LoRA |
|---|---|---|
| BK-51 (bike, climbing wall) is too damaged to keep. It is needed for tomorrow's session. | Repeats the report three times and runs out of room | {"asset": "BK-51", "equipment": "bike", "category": "repair", "location": "climbing wall", "priority": "high"}: category wrong (should be replacement) |
| Report from the workshop team: kayak KY-88 is broken. | Invents nested {"type": "report", "data": {...}} objects | {"asset": "KY-88", ..., "category": "repair", "location": "workshop", "priority": "high"}: priority wrong (no timing cue means normal) |
| Hi, the harness HN-10 at the boathouse smells of damp. Please take it out of use now. | Invents keys such as description and status | Exactly right |
Across all 100 validation reports, valid records went from 1% to 100%, and fully correct records from 0% to 30%. The adapter changed the model's behaviour dramatically, and it is still wrong more often than right on the interpreted fields. Most of the course is about measuring results like these honestly, understanding them, and improving them.
How the course measures success
Every fine-tune in the course follows the same discipline:
- Decide first. Is fine-tuning the right tool at all, or would a better prompt, a few examples in the prompt, retrieval or ordinary code do? You write a short brief that fixes what success means before training.
- Measure a baseline. Score the untuned model on the same data, so an improvement has something to be compared with.
- Keep three splits apart. Train on the training split. Make every decision on the validation split. Use the test split once, at the end.
- Judge by task metrics. These are the share of valid records, of exactly right records, and of each field right. The training loss going down is not, on its own, evidence of a better model.
- Check what else changed. Fine-tuning can damage behaviour outside the task, so later lessons test for that.

Read left to right, row by row. The optional module, in a dashed box, is outside every core outcome.
How each lesson works
-
Three views. Each lesson has a Full Course view that teaches the topic, a Revision view that brings back the reasoning and the common mistakes, and a Quick Reference view with the commands and settings.
-
Practical lessons state, before you start:
- the goal;
- what must already exist;
- where to run each command;
- what will be created;
- how to recognise success.
They end with what to do when your result differs, an independent task with hints and a solution, and cleanup of only the files that exercise created.
-
Predict first. You are often asked to predict a number, a shape or an outcome before running anything. Write the prediction down; being wrong is how the explanation sticks.
-
Illustrative output. Output shown in lessons comes from the course's own tested runs, but your numbers will differ a little: by platform, library build and how busy your computer is. Compare with your own baseline, not with the lesson's figures.
-
Your computer is enough. Every core exercise runs on a 4-core laptop CPU, with no GPU, account, access token or payment after setup. Each training run is sized to take about 15 minutes or less on an idle computer.
-
Nothing leaves your computer. The course downloads two models and its libraries once, then works offline. Its data is written for the course and contains no personal information.
Check that the course suits you
The course assumes four things you know already. Answer each self-check before reading the answers, which come after all four.
1. Python. You can write small programs with functions, lists, dictionaries, loops and imports, and fix an error from its traceback. The setup lesson starts with a two-minute exercise that checks this.
2. Reading basic PyTorch. Given layer = torch.nn.Linear(576, 192):
- What is the shape of
layer.weight? - How many parameters does the layer have?
- Put these training-step lines in order:
optimizer.step(),loss = loss_fn(model(x), y),optimizer.zero_grad(),loss.backward().
3. Supervised-learning vocabulary. In one sentence each, what are a training split, a validation split, a test split, overfitting and a loss?
4. What a language model does. True or false?
- (a) A language model generates text one token at a time, each chosen using the text so far.
- (b) If a model's answer is fluent and confident, it is probably correct.
- (c) The same prompt can produce different replies, depending on how the model chooses each token.
- (d) A model knows about events after its training data was collected.
Answers
-
If the setup lesson's exercise takes you more than a few minutes, study Python first (for example the course Python for AI and Machine Learning).
-
PyTorch:
- Weight shape:
(192, 576), because a linear layer stores its weight as outputs by inputs. - Parameter count: 192 × 576 + 192 = 110,784, the weight plus one bias per output.
- Order:
optimizer.zero_grad(), the loss line,loss.backward(),optimizer.step(). Zeroing first can also come after the step; the point is that it happens once per batch.
If this was unfamiliar, the LoRA lessons give a short refresher, and the course Deep Learning with PyTorch covers it fully.
- Weight shape:
-
Vocabulary:
- The training split is the data the model learns from.
- The validation split is held out for choosing between options.
- The test split is held out until the end, for one final measure.
- Overfitting means fitting the training data so closely that results on new data get worse.
- A loss is a number that measures how wrong the model's predictions are, which training tries to reduce.
-
Statements:
- (a) True. That is how generation works.
- (b) False. Fluent text can be wrong; that is why the course scores every reply.
- (c) True. The course uses greedy decoding (always the most likely token) so that results repeat.
- (d) False. A model has no knowledge of events after its training data was collected, and fine-tuning on a handful of examples is a poor way to add facts.
What the course does not cover
The course teaches supervised fine-tuning with LoRA and QLoRA on small open models, end to end. It names, but does not teach:
- preference training (such as DPO) and reinforcement learning;
- training on many GPUs;
- wrapper frameworks that hide the training loop;
- hosted fine-tuning services;
- serving models in production;
- multimodal and speech models.
Retrieval, agents and the internals of transformer layers have their own courses.
Check your understanding
For each statement, say whether fine-tuning a small adapter is a good way to achieve it, and why:
- Make the model always reply with a JSON record in a fixed format.
- Make the model know this week's equipment prices.
- Make the model write in the centre's house style.
- Make the model add up a list of numbers correctly.
- Make the model label reports with the centre's own categories.
- Make the model cite the centre's policy documents when it answers.
- Make the model stop at the end of its reply instead of running on.
- Teach the model a new language from 400 examples.
Answer all eight before reading on.
Answers
- Good. A fixed output format is exactly what fine-tuning teaches well, as the tested adapter showed (1% to 100% valid records).
- Poor. Prices change; anything that changes belongs in the prompt or is fetched at run time (retrieval), not trained in.
- Good. Style and tone are patterns that examples teach well.
- Poor. Ordinary code does arithmetic exactly; a model only approximates it.
- Good. It is a classification with a fixed label set, given enough labelled examples. The course task does exactly this.
- Poor, on its own. Citations need the documents at answer time, which is retrieval; fine-tuning can only teach the format of a citation.
- Good. Stopping is learned from the end-of-turn token in the training examples; the loss-mask lesson shows how.
- Poor. 400 examples can teach a format, not a language. That needs far more data than a small adapter can absorb.
Decide when fine-tuning is the right tool turns these judgements into a method. First comes Set up and verify the course environment.