Sub topic 13
Where Fine-Tuning Fits, and Where It Does Not
Prerequisites and the core decision
This chapter assumes you understand prompts, retrieval-augmented generation (RAG), model evaluation, and basic deployment workflows. You should also be comfortable calling a model through a Python SDK or HTTP API.
Fine-tuning is additional training that adapts a pretrained model using your examples. Instead of changing the model’s knowledge through each prompt, you adjust its parameters so it learns a repeated behavior or format.
Fine-tuning is useful when the same failure appears across many examples and prompting cannot reliably fix it. It is usually a poor choice when the problem is changing knowledge, missing context, or weak retrieval.
| Problem | Usually start with | Why |
|---|---|---|
| The model lacks current company facts | RAG | Retrieve updated facts at request time |
| The output has the wrong format | Prompting or fine-tuning | Try a clear schema and examples first |
| The model uses an unwanted tone repeatedly | Prompting, then fine-tuning | A stable style can be learned from examples |
| The model needs a specialized capability | Fine-tuning or a stronger model | Training may improve consistent behavior |
| The model gives unsafe answers | Guardrails and evaluation | Fine-tuning alone is not a safety boundary |
What fine-tuning changes
A fine-tuned model can learn patterns such as:
- A consistent classification label set.
- A company-specific response style.
- A strict transformation from input text to structured output.
- A tool-calling format used repeatedly by an agent.
- Domain terminology and preferred reasoning patterns.
Fine-tuning does not automatically create a reliable database. If a product catalog changes every day, training on yesterday’s catalog makes the model stale. Use retrieval or a database for facts that must remain current.
Fine-tuning also does not guarantee that the model will follow every instruction. Training examples can contain contradictions, missing edge cases, or sensitive data. The resulting model may memorize unwanted text or reproduce biased behavior.
A practical selection process
Use this sequence before starting a training project:
- Define the failure with a representative evaluation set.
- Improve the system prompt and output schema.
- Check whether retrieval supplies the needed context.
- Try a stronger or smaller model and compare quality, cost, and latency.
- Fine-tune only if the remaining problem is a repeatable behavior.
- Evaluate the tuned model against both the target set and a safety regression set.
The training data must resemble production inputs. Include difficult cases, valid refusals, incomplete inputs, and examples where the correct action is to ask for clarification. More examples do not compensate for unclear labels.
def choose_next_step(problem, facts_change_often, prompt_tried, rag_tried):
if facts_change_often:
return "Improve retrieval or the source data"
if not prompt_tried:
return "Improve the prompt and output schema"
if not rag_tried and problem == "missing context":
return "Add or improve retrieval"
return "Consider fine-tuning, then validate with an evaluation set"
print(choose_next_step("format consistency", False, True, True))How fine-tuning changes LLMOps
Fine-tuning adds artifacts and operational work to the lifecycle:
- Training and validation datasets need versions and access controls.
- The base model, training parameters, and data-preparation code must be recorded.
- The tuned model needs its own identifier and deployment history.
- Evaluations must compare the tuned model with the previous production model.
- Rollback must restore the earlier model and its compatible prompt and retrieval settings.
Decision rule
Fine-tuning is worth considering when the behavior is stable, measurable, frequent, and expensive to correct in every request. It is less attractive when requirements change quickly, high-quality examples are scarce, or retrieval and prompting have not been tested carefully.
Exercise
A support assistant gives outdated answers after a policy change. Should you fine-tune it first?
Show answer
No. Update the source of truth and retrieval pipeline first. Fine-tuning would encode old policy and increase the risk of stale answers.