CHAPTER 11 OF 12
Decide when fine-tuning is justified
Prepare clean examples and held-out data before spending time on adaptation.
In this chapter
Change behavior for a reason
Fine-tuning updates model parameters using additional examples. It can be useful when you need a repeatable style, task behavior or domain-specific output pattern and have enough representative, permitted training data. It is usually a poor first response to missing current facts, broken retrieval, an unsupported file format or an application bug.
Compare three interventions. Prompting changes the instructions and examples supplied at inference time. Retrieval changes the evidence supplied for a request. Fine-tuning changes parameters and creates a new model or adapter artifact to manage. Start with the cheapest intervention that addresses the failure you actually observed, then measure it against a held-out set.
An adapter method such as LoRA trains a smaller set of added parameters rather than updating every original weight. This can reduce training requirements relative to full fine-tuning, but it still needs compatible software, memory, data preparation and evaluation. An adapter belongs with its exact base model and configuration. It is not a universal patch for any file with a similar name.
Data is the main engineering work
Examples should teach the desired behavior. Remove unauthorized sensitive material, inconsistent labels and accidental duplicates. Include important negative cases rather than teaching the model to produce an answer every time. Keep training, validation and final test data separate.
Exact duplicate checking is only a beginning. Two examples can contain the same underlying event with different wording, creating semantic leakage. Split by the entity or time boundary relevant to the application when necessary. Keep the final test set away from prompt and training decisions.
Training loss is not the user's outcome. A lower loss may reflect memorization or a changed distribution. Evaluate the adapted model on the same task rubric as the base model, including general behavior you need to retain. Record regressions as well as improvements.
Prerequisites
The measured lab requires only the companion files and Python. It checks synthetic data shape and split overlap. The tiny fixture is intentionally too small for a useful training run. Actual training requires a separately chosen compatible base model, a pinned training environment, sufficient memory and data you are allowed to use; those steps were not executed for this edition.
Steps
Open
training/train.jsonl,valid.jsonlandtest.jsonl. Each line contains one user message and one assistant target.Run the preparation check:
python3 rtm_lab.py dataset --output dataset-check.jsonConfirm the split counts and that duplicate prompts across splits are zero. Inspect the labels yourself; a schema validator cannot establish that they are correct.
Build a larger task-specific dataset separately. Record provenance, permissions, split method and known limitations before training.
If you choose MLX LM on Apple Silicon, follow its current LoRA instructions in an isolated environment. For a compatible model already downloaded at the placeholder path, the command pattern is:
mlx_lm.lora --model /path/to/compatible-base \
--train --data /path/to/prepared-data --iters 600Record the installed MLX LM version, exact base artifact, configuration and adapter files. Run its evaluation command and your application rubric against held-out data before considering export or deployment. The command above is source-reviewed, not an executed training result.
Expected results
The companion checker should report three training rows, one validation row, one test row and no exact prompt overlap. trainingExecuted remains false. Passing that check means the small fixture has the expected shape; it does not mean the data is sufficient, private, representative or suitable for adaptation.
If you later train, expect a new adapter or model artifact and a new evidence record. Reusing the base model's quality and compatibility claims without retesting would be misleading.
Common failures
Training on the test set can create impressive but meaningless scores. A base-model mismatch can make an adapter unusable. A successful training process can worsen the actual task. Converting or quantizing the result can change behavior again. Treat each deployment artifact as something that must be evaluated, not simply as a file produced by a successful command.
Exercise
Choose one observed failure from chapter 5. Explain why prompting, retrieval or adaptation is the most suitable next experiment. If you choose adaptation, write the data requirements and the evidence that would justify its additional cost.
Sources
MLX LM's LoRA guide documents its commands and data formats. This book does not report trained adapters, speedups or quality improvements that were not measured.