AI EngineeringAdvanced15 min

Fine-tuning & distillation

When changing a model's weights beats better prompts, and how to do it without fooling yourself.

See it on the map

Try prompting, examples and retrieval first. Fine-tune when you need a consistent style or output format that prompts cannot hold, lower latency and cost by using a smaller model, or better accuracy on a narrow task with plenty of labelled examples. It is a poor tool for teaching new facts, which belong in retrieval.

Data quality decides the result. A few hundred to a few thousand clean, representative examples often beat a large noisy set. Hold out a test set before you start and compare against your best prompted baseline on it. Parameter-efficient methods such as LoRA train a small set of added weights, which is cheaper and easier to swap or roll back than updating the full model.

Distillation trains a small model to imitate a larger one on your task, often using the larger model's outputs as training labels, so you keep most of the quality at a fraction of the serving cost. Re-run your evals after every training run, watch for regressions on tasks you did not train on, and plan to retrain when the base model or your data changes.

Key points

  • Exhaust prompting, examples and retrieval before fine-tuning.
  • Fine-tune for style, format, latency or cost, not for new facts.
  • Clean, representative data and a held-out test set matter most.
  • Distillation moves a task to a smaller, cheaper model. Re-evaluate every run.

Answer these out loud

  1. 1Your classifier prompt works but costs too much at 5M calls a day. Outline a distillation plan and the metric that lets you ship it.
  2. 2A fine-tune improved your task but a general benchmark dropped. How do you decide whether to ship?

Use this from an agent

Any MCP client, including Grok, can read this lesson. See how to connect.

REST
curl https://engineeros-delta.vercel.app/api/v1/topics/fine-tuning-and-distillation