Fine-Tuning Pipeline
Model customization · SFT pipeline
Written by Darjus Kazakevic · reviewed
Try the prompt first. Fine-tune when the prompt cannot carry the behaviour.
Fine-tuning trains an existing model further on your own examples, so a behaviour you used to describe in the prompt moves into the weights. It is good at format, tone and narrow, repeated tasks. It is poor at teaching facts: the model may learn to sound like your documents without reliably recalling what they say. Facts that change belong in retrieval.
So the first step is a question, not a training run. Would a better prompt, a few worked examples or RAG be cheaper and good enough? If you still need a tune, treat it as a pipeline you will rerun, not a one-off experiment: curated data, a frozen eval set, a training run, a gate against the prompt you would ship anyway, and a versioned rollout you can undo.
In essence — A fine-tune is only as good as its eval set and its baseline. Without both, you cannot tell a better model from a different one.
When to reach for it
Reach for it when
- A prompt that works is too long, slow or costly to send on every call
- You need a format, tone or narrow skill that prompting cannot hold steady
- A small, cheap model must match a large one on one narrow task
Reconsider when
- The model needs facts that change: use retrieval instead
- A better prompt or a few worked examples has not been tried yet
- You cannot yet say what a good answer looks like: write the eval set first
The stages
- Data curation
- Collecting and cleaning the examples the model will learn from: real inputs paired with the outputs you want. Quality beats volume. A few hundred to a few thousand reviewed examples often beat a large noisy dump, because the model learns the mistakes too.
- The held-out eval set
- Cases the model never trains on, used to judge every candidate. Build it first and freeze it. Built after the training set, it gets the leftovers, and the best examples quietly end up in training.
- Training (Full vs parameter-efficient)
- Full fine-tuning updates every weight: the most capacity, the most memory, and a full model copy per variant. Parameter-efficient methods such as LoRA freeze the base model and train small low-rank adapter matrices beside it, a tiny fraction of the parameters.
- The gate
- The comparison that decides promotion. The candidate must beat two baselines on the frozen eval set: the base model with your best prompt, and the model in production now. Beating the raw base model proves nothing; a good prompt often does the same.
- Versioning and rollout
- A tuned model is the product of a base model version, a dataset, a config and the training code. Record all four, so any checkpoint can be rebuilt or explained. Roll out behind an alias, to a slice of traffic first.
Design rules
- Beat a strong prompt before you train
- Write the best prompt you can, with few-shot examples and retrieval if they help, and score it on the eval set. That score is the bar. Often it is already good enough, and the project ends here, cheaply.
- Freeze the eval set before the training set
- Hold out cases first, split by source or time so related examples do not land on both sides, and never train on them. A tune scored on cases it has seen measures memory, not skill.
- Train in the format you serve
- Use the same chat template, system prompt and tool schemas in training as in production. A model tuned without the system prompt and served with one is a different input distribution, and it fails quietly.
- Make every model rebuildable and reversible
- Pin the base model version, hash the dataset, store the config and seed with the checkpoint. Keep the previous version deployable until the new one has run on real traffic.
Common pitfalls
- Tuning to teach facts, then getting confident answers that are wrong.
- Eval cases leaking into training, so the score measures memory.
- Training without the production system prompt or template.
- Comparing only against the raw base model, never against a good prompt.