AI Engineering · interactive
Fine-tuning
Fine-tuning keeps training a model on your own examples. It is the best way to lock in a format or a voice, a slow way to teach a new skill, and the wrong way to add facts. Pick a goal, choose how many examples and how many passes, and compare the result with a good prompt and with retrieval.
Always answer in our JSON schema · 200 examples × 3 epochs
- Instructions82%
- Few-shot93%
- RAG82%
- Fine-tuned96%
- on your task
- 96%
- general ability (was 90%)
- 86%
Fine-tuning wins for this goal: 96% against 93% for the best prompt or RAG. Fewer epochs would do as well with less forgetting.
Goal
Decide what should change
Fine-tuning changes how the model answers, not what it knows. Format, tone and a narrow skill are good goals; a changing body of facts is not.
A shape the model has to reproduce every time.
Collect examples
Each example is an input and the exact answer you want. A format needs tens; a style, hundreds; a skill, thousands. Quality matters more than count: the model copies mistakes too.
Examples
most of the way there by about 40 examples for this goal
Train for a few epochs
One epoch is one pass over the examples. Watch the held-out loss: when it starts rising while training loss keeps falling, the model is memorizing your examples instead of learning from them.
Epochs
200 × 3 × 300 tokens at $25/M = $4.50 to train
Check the task, and everything else
Score it on held-out examples of your task. Then score it on a general benchmark: narrow training pushes other abilities down a little with every epoch (catastrophic forgetting).
task 96% · general 90% → 86%
Compare with prompting and RAG
Always try a good prompt first: it needs no training and changes in a minute. RAG beats fine-tuning on facts. Fine-tuning pays off when it wins on quality, or when it lets you drop a long prompt from every request.
The few-shot prompt carries 600 extra tokens on every request and RAG 1,500; the fine-tuned model carries none, but costs a little more per token.
Scores are a teaching model of the usual pattern; prices are typical hosted rates.
In production
Tools and technologies
Hosted APIs fine-tune from a file of examples; open models fine-tune with a few libraries.
Not tied to one language — use these names when you search docs or design a system.
- OpenAI fine-tuningService
Upload examples, pick epochs, get a model id to call.
Documentation ↗ - Google Vertex AI tuningService
Supervised tuning of Gemini models on your examples.
Documentation ↗ - Hugging Face TRLSoftware
Supervised fine-tuning for open models.
GitHub ↗ - AxolotlSoftware
Config-driven fine-tuning of open models.
GitHub ↗ - UnslothSoftware
Faster, lower-memory fine-tuning on one GPU.
GitHub ↗