Fine-tuning starts with a model that already knows how to predict language. You expose it to new training examples and update some of its parameters so that particular continuations become more likely. The hard part is deciding which behavior to change, how to measure the change, and whether training is the right intervention in the first place.
Imagine a maintenance team receiving messages such as “The east loading dock door is jammed again.” Its dispatch system accepts exactly three fields: an equipment category, an urgency code, and a one-sentence summary. A general chat model may understand the report and still give a helpful paragraph where software expects a record. The team can describe the record in a prompt, constrain output with a schema, retrieve current policy, or fine-tune the model on examples of the decisions its dispatchers actually make. Those options address different failure modes. We will use the dispatch task to follow them through a concrete example.
What you should be able to do
- Distinguish a pretrained base model from an instruction-tuned checkpoint.
- Explain how an example influences the probability of a response token.
- Separate a change in trainable parameters from a choice of training objective.
- Decide whether a failure calls for prompting, retrieval, constrained decoding, fine-tuning, or a combination.
- Write a baseline and acceptance plan before running a training job.
You should be comfortable with Python, basic probability, and the idea of a gradient. The worked example uses two output tokens, so you can reproduce it with a calculator.
What pretraining gives you
A tokenizer converts text into a sequence of integer IDs. An ID might represent a word, a fragment of a word, punctuation, or a special control token. In a decoder-only language model, the network uses a prefix to score possible next tokens. These scores are called logits. Applying softmax turns them into a probability distribution over the vocabulary. The model generates text by repeatedly choosing a token from this distribution and appending it to the prefix.
A common pretraining objective asks the model to predict the next token across many sequences of text. For a sequence $x_1, \ldots, x_T$, where $x_t$ is the token ID at position $t$, the objective is to minimize the average of $-\log p_\theta(x_t \mid x_{<t})$. Here $x_{<t}$ is the prefix before position $t$ and $\theta$ is the set of model parameters. The logarithm is natural. A larger probability on the observed token produces a smaller loss. Article 02 develops this objective from logits through backpropagation.
Predicting text at scale can make the model sensitive to common grammar, technical vocabulary, document structure, and associations among concepts. In the dispatch example, this shared starting point helps with phrases such as “dock leveller” and “emergency stop” even if the fine-tuning dataset is small. A model trained from random initialization on the same dispatch examples would have to learn the task and much more of the language from those examples.
A base checkpoint is commonly intended for text continuation. Given “Report: east dock door jammed. Category:”, it might complete the label, write another example, or continue in the style of a document it has seen. An instruction-tuned checkpoint has undergone additional training to respond to instructions, often with a specific chat format. It is usually the better initial baseline when the desired interface is a conversation. A base checkpoint can be a reasonable starting point when you are building the completion behavior yourself or adapting to raw domain text. Compare checkpoints on your distribution before committing to one.
Transfer learning and post-training
Transfer learning reuses weights learned on one data distribution as the starting point for another. Call the pretrained parameters $\theta_0$. After additional training, the effective model uses $\theta_1$. With full fine-tuning, all eligible model parameters can be updated. With partial fine-tuning, only selected original parameters are updated. An adapter can leave the original checkpoint intact and introduce a small trainable computation that runs alongside it.
The objective describes what errors the optimizer should reduce. The parameter strategy describes which parts are allowed to change. You can apply supervised fine-tuning with either full updates or an adapter. You can also use an adapter for continued pretraining on raw text. The labels “LoRA” and “SFT” therefore answer different questions. LoRA describes a way to parameterize the change, while supervised fine-tuning describes learning from target outputs.
Post-training is a broader label for adapting a pretrained model. It can include supervised training on demonstrations, preference optimization using compared answers, reinforcement learning using rewards, and other stages. Continued pretraining typically keeps a language-modeling objective on new raw text. Supervised instruction tuning typically trains on target responses paired with instructions or conversations. Both can use next-token loss, yet the source of the target and the positions included in the loss can differ. The exact stages depend on the checkpoint and its training recipe.
An instruction example for dispatch might contain a system instruction, a user incident report, and an assistant message with a structured record. During adaptation you may calculate the loss only on assistant tokens. The input report remains in the context and still affects gradients through its effect on those predictions. If you also score user tokens, the objective partly rewards predicting user wording, which may be an undesirable use of training capacity. A tokenizer and chat template define the actual boundaries. Counting characters or searching for the string “assistant” is insufficient to identify them.
A numerical example with one update
Suppose the dispatch model has reached the first response position. For this educational example the only possible tokens are U for urgent and R for routine. Real models score a much larger vocabulary, and a label may span several tokens. Let the starting logits be $z_U=0$ and $z_R=1$. The probability for label $i$ is $p_i=e^{z_i}/(e^{z_U}+e^{z_R})$. The initial probabilities are approximately $p_U=0.269$ and $p_R=0.731$.
The target is U because the incident describes a blocked emergency exit. The cross-entropy loss for this one target is $L=-\log p_U$, approximately 1.313 nats. The unit comes from using the natural logarithm. For two-class softmax with cross-entropy, each logit gradient is predicted probability minus target indicator. The indicator equals one for the correct token and zero for the other. We get $\partial L/\partial z_U = 0.269-1=-0.731$ and $\partial L/\partial z_R=0.731$.
For a small model we can turn these into weight gradients explicitly. Suppose each logit is $z_i = w_i h$, where $h=2$ is a fixed scalar feature produced from the report and $w_i$ is the output weight for label $i$. The original weights are $w_U=0$ and $w_R=0.5$. By the chain rule, $\partial L/\partial w_i=h(\partial L/\partial z_i)$. Thus the gradients on the weights are approximately −1.462 and +1.462.
With learning rate $\eta=0.1$, one gradient-descent step uses $w_i^{\mathrm{new}}=w_i-\eta(\partial L/\partial w_i)$. The weights become about 0.146 and 0.354. Their logits become 0.292 and 0.708. The probability assigned to U increases to approximately 0.398 and the loss drops to approximately 0.922. U still has less probability than R. A single update moved the distribution in the right direction for this example and left the most likely token unchanged.
| Quantity | Before update | After update |
|---|---|---|
| Urgent logit | 0.000 | 0.292 |
| Routine logit | 1.000 | 0.708 |
| Urgent probability | 0.269 | 0.398 |
| Loss on this example | 1.313 | 0.922 |
Imagine another report with the same representation $h=2$ but a correct label of R. The update also raises the urgent probability for that report. In a real model each hidden representation is a vector, and examples can overlap in some directions while differing in others. Shared parameters are how learning generalizes. They are also how a change that helps one slice can hurt another. A falling training loss therefore gives no independent evidence that the updated behavior is useful on new reports.
Where the dispatch failures come from
A requirement is underspecified. If the prompt merely says “classify this report,” adding explicit field names and an urgency rubric may resolve many failures. Provide one or two representative examples and test on reports that use different wording. If the output must parse every time, apply a schema or grammar constraint where the serving stack supports it. A syntactically valid code can still be the wrong code.
A decision requires current information. Suppose some buildings temporarily have no backup exit. The urgency policy depends on which buildings those are today. Retrieval-augmented generation, or RAG, retrieves relevant information at inference time so the model can consider it. A trusted policy service can also compute the decision directly. Index the source with dates and access control, and test that retrieval finds the applicable rule. The model may still misread evidence or trust a stale passage.
A stable behavior is hard to specify compactly. Dispatchers may consistently distinguish a nuisance signal from a safety incident using subtle combinations of equipment type, timing, and symptoms. A prompt with a few examples might leave a recurring error on a clearly defined slice even after retrieval supplies the correct policy. Supervised fine-tuning is worth testing if you can collect reliable demonstrations of the distinction and hold out genuinely new cases.
The task is partly deterministic. An asset registry can map an equipment ID to a known building. A parser can validate a code. A calendar can look up an on-call rotation. Move those operations out of the learned classifier when you have deterministic inputs. Use model capacity for report interpretation, ambiguity, and summarization. For a missing building identifier, define an explicit abstention or escalation path before collecting labels.
| Intervention | What changes | A useful first measurement |
|---|---|---|
| Prompt and examples | Context supplied to the model | Accuracy with a fixed prompt on unseen reports |
| Schema constraints | Which sequences are legal outputs | Valid-record rate and accuracy after parsing |
| Retrieval | Evidence included at inference time | Retrieval recall and evidence-supported decisions |
| Supervised fine-tuning | Effective model parameters | Change in slice accuracy and regression rate |
| Rules or validation | Deterministic application behavior | Coverage and correctness on known cases |
These methods can coexist. For example, an adapter can learn the format and the institution's general reporting style while a retrieval step supplies the current urgency policy and a validator checks the output. To estimate what training contributes, compare models under the same prompt, evidence, decoding settings, and scoring procedure. Then vary another component in a separate experiment.
Build the baseline before training
Define the unit you will evaluate. In dispatch it could be one incident rather than one message, because a single incident can trigger duplicate reports. Keep reports from the same incident together in one split. If you expect a new building to behave differently, reserve a building-level evaluation slice. Use a time-based split where future drift matters and ensure details copied from follow-up documents are available at the time the model would actually make a decision.
Make the rubric observable. Score valid records, equipment categories, urgent-case recall, and false urgent escalations separately. In this example, a false routine prediction has a higher consequence than a false urgent prediction. Document that asymmetry before choosing a cutoff or acceptance threshold. Add an abstention label and decide how to score a correct escalation under ambiguous or missing evidence. If experts disagree on the rubric, resolve disagreements or encode the ambiguity before treating one label as ground truth.
Log the base checkpoint revision, tokenizer, chat template, dataset revision, decoding settings, and scoring code. A prompt-only baseline should be good enough to challenge the trained approach. Run it on a development split and inspect a sample of failures. Keep a test split independent of prompt edits, data selection, and hyperparameter search. If you have tried many variations on the same held-out split, its result increasingly reflects your selection process.
Here is an illustrative decision. Suppose 72 of 80 truly urgent events are detected by the prompt-and-schema baseline, giving recall of $72/80=90\%$. Suppose the adapted model detects 75, giving $75/80=93.75\%$, while the number of false urgencies rises from 8 to 24. This shows an apparent gain in recall and a larger escalation load. The counts alone do not tell you how many events the models disagree on in either direction. A paired analysis of individual incidents and inspection of the changed cases can tell you whether the apparent improvement aligns with the operational goal. These numbers represent a hypothetical experiment.
Failure modes to watch for
Memorized examples. If the same equipment report appears in both training and evaluation, a strong score may reflect data leakage. Split by event before generating paraphrases or synthetic variants. Track provenance and deduplicate near matches. Reports written from the same template can also share enough detail to make a nominally independent split too easy.
Ambiguous labels. If expert dispatchers disagree about urgent handling, an optimizer will still try to fit the labels it is given. Treat model errors as potential signals of a weak rubric rather than automatically adding more copies of the same examples. For consequential ambiguity, allowing a request for clarification can be more useful than enforcing a binary answer.
Regressions outside the task. Updates can degrade general instruction following, safety behavior, or performance on another department's input. Evaluate the original and adapted model on a small regression suite drawn from requirements that must keep working. This is especially important when deploying one shared checkpoint across multiple tasks.
Stale or proprietary knowledge. Training on policy documents can make phrases from those policies easier to complete, but there is no guarantee the model will produce the latest rule, cite the controlling document, or forget an older rule when it changes. Training data may also contain information that should never be available to a model's users. Use appropriate permission and retention rules before collecting examples and prefer authoritative, access-controlled lookup for mutable facts.
An unreliable serving comparison. Changing the tokenizer template or sampling temperature between checkpoints can change output even if the adapter is loaded correctly. Start with fixed settings and the intended deployment interface. If the production sampler is stochastic, test repeated runs or multiple seeds where practical. Pin the base revision required by an adapter and verify that the deployed artifact uses it.
A format win that masks a judgment loss. A model can produce a higher fraction of parseable records while identifying fewer critical incidents. Track record validity and decision quality as separate measures. Review slices where new correctly formatted responses might create more dangerous downstream confidence.
Report what the evidence supports
Research on instruction following shows that additional training can change which answers people prefer under the study's conditions. Ouyang and colleagues combined human-written demonstrations, preference rankings, and reinforcement learning in InstructGPT. Their reported comparisons concern the models, prompts, and evaluations in that work. For a dispatch system, the corresponding claim would require its own labels, baselines, and held-out incidents.
Likewise, results for a particular adapter or model family do not settle the cost or quality trade-off for yours. For an initial decision, compare the gain on the held-out task with data preparation effort, serving cost, rollback effort, and review burden. If the adapted model wins, save the baseline as a versioned fallback and record the examples and slices on which each version is stronger.
Exercises
- Recalculate the toy update with $h=1$ and initial weights $w_U=0$ and $w_R=1$. Keep the initial logits fixed. Explain why the loss decreases by a different amount even though the starting probabilities agree.
- Write three examples of output-format failure, missing policy evidence, and inconsistent classification. For each, specify the first intervention and one metric that would support keeping it.
- Design a split for 200 incidents across four buildings when 30 incidents have follow-up reports. Explain what you would hold out for time drift and how you would handle scarce urgent examples.
- Calculate urgent precision for the two hypothetical runs. Propose a review procedure for a case the adapted model escalates and the baseline marks routine.
Key takeaways
Fine-tuning is additional training from a pretrained starting point. The objective assigns credit and penalty to behavior, while the parameter strategy controls where the resulting changes can occur. Use a measured baseline to decide whether the observed failure calls for changing the model, supplying better information, or adding a deterministic guarantee. Evaluate improvement and regressions before treating lower training loss as a reason to deploy.
Frequently asked questions
How many examples do I need? The answer depends on diversity, label consistency, how far the behavior is from the baseline, and what happens when the model is wrong. Plot validation results against increasing dataset sizes and investigate where coverage is missing.
Can I start with an instruction-tuned model? Yes. It may already follow the interaction pattern you need, which can make a targeted adaptation easier to evaluate. Use the checkpoint's intended input format and compare against the original before training.
Will an adapter eliminate forgetting? Freezing the base lets you recover the original behavior by unloading the adapter, subject to serving and formatting being the same. With the adapter active, its changes can still cause regressions. Evaluate the active configuration directly.
Do I need reinforcement learning for better format compliance? Start with constrained generation where available and measure semantic correctness separately. Supervised examples can help when the missing behavior is stable and well demonstrated. Preference or reward training has its own data and evaluation requirements.
Academic references
- Attention Is All You Need, Ashish Vaswani et al., NeurIPS 2017. Introduces the Transformer architecture that underlies the attention-based models discussed in this series.
- Training language models to follow instructions with human feedback, Long Ouyang et al., NeurIPS 2022. Documents the demonstrations, preference judgments, and policy optimization used in InstructGPT.
- LoRA: Low-Rank Adaptation of Large Language Models, Edward J. Hu et al., ICLR 2022. Provides a concrete example of keeping pretrained weights frozen while training a low-rank update.
- Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, Patrick Lewis et al., NeurIPS 2020. Describes combining a generator with a retrievable document index.
Continue the series
Article 02, Understanding the LLM Training Process, develops the path from token IDs to logits, next-token loss, and optimizer steps. Article 03 then organizes adaptation strategies and training objectives independently. The series index lists the available lessons.