Lesson 16 of 28 · Making AI useful
What is fine-tuning?
Fine-tuning is extra training that adapts an existing AI model to a specific job. You take a model that has already learned general language skills and train it further on a smaller set of your own examples, such as support replies in your brand's voice. This adjusts the model's internal parameters, so the new behaviour sticks without having to be explained in every prompt.
From generalist to specialist
Building a large language model happens in stages. First comes pre-training: the model reads a huge amount of general text and learns language, facts and patterns. The result is a broad generalist, often called a foundation model. Fine-tuning is any later round of training on a smaller, focused dataset that shapes the model for a narrower purpose.
Think of a doctor who finishes general medical school and then trains as a specialist. The specialist training is far shorter than the original education, but it changes how they work every day. Fine-tuning is similar: much less data and computing power than pre-training, with lasting effects on behaviour. The idea of pre-training a language model and then fine-tuning it for a task was popularised by work such as Howard and Ruder (2018).
Fine-tuning made chat assistants possible
A freshly pre-trained model is good at continuing text but not at following instructions; ask it a question and it may simply write more questions. Chat assistants exist because developers fine-tuned such models on examples of helpful answers and on human ratings of which answers were better, an approach described by Ouyang et al. (2022).
Fine-tuning every parameter of a large model is expensive, so many teams use parameter-efficient methods. A widely used one, LoRA (Hu et al., 2021), freezes the original model and trains a small set of add-on weights instead, which makes fine-tuning cheaper and lets one base model carry several lightweight specialisations.
Fine-tuning vs prompting vs RAG
Fine-tuning is generally better at teaching form than facts. To keep a model up to date with, say, a product catalogue, RAG is usually the simpler and safer choice.
These are three ways to make a general model fit your needs, and they are often combined. A common order is to try them from the cheapest to the most involved:
- Prompting: write clear instructions and examples. No training, instant to change.
- RAG: let the model look up your documents when it answers. Best for facts that change and answers that need sources.
- Fine-tuning: train on hundreds or thousands of examples. Best for a consistent style, format or narrow task repeated at scale.
What fine-tuning is not, and where you meet it
Fine-tuning is not what happens when you correct a chatbot in conversation; the model does not retrain itself on your chat. An assistant you set up with custom instructions and uploaded files is not fine-tuned either; it works through prompting and retrieval. And fine-tuning does not build a new model from scratch: it always starts from an existing one.
You meet fine-tuning in model providers' developer platforms, in the many fine-tuned variants of open-weight models shared online (a name ending in 'instruct' or 'chat' usually means an instruction-tuned version), and in enterprise AI products that offer custom models trained on a company's own data.
Example
What fine-tuning data looks like
Code sample{"messages": [
{"role": "system", "content": "You are the support assistant for Acme Shop."},
{"role": "user", "content": "Where is my order?"},
{"role": "assistant", "content": "Happy to help! Send me your order number and I will check it straight away."}
]}
{"messages": [
{"role": "user", "content": "Can I change my delivery address?"},
{"role": "assistant", "content": "Yes, as long as the order has not shipped. Reply with the new address and I will update it."}
]}Illustrative training data in a chat format used by several fine-tuning services, where each example is one line of a JSONL file (split across lines here for reading). A real dataset contains many such examples in the voice you want the model to learn; check your provider's documentation for its exact format.
Key points
- Fine-tuning is extra training that adapts an existing model to a task.
- It changes the model's parameters, so the behaviour persists.
- It needs far less data and computing power than training from scratch.
- Use it for style, format and narrow tasks; use RAG for changing facts.
- Try clear prompts first: they are cheaper and faster to change.
Try it on Mindber
Related terms
Related topics
Frequently asked questions
How much data do you need to fine-tune a model?
It depends on the task and the method. Teaching a consistent format or tone can work with a modest set of examples, while a complex specialised task needs many more. Quality matters more than volume: clean, consistent examples that look like the real inputs you expect are worth more than a large, messy set. Providers' documentation usually states a minimum.
Does fine-tuning stop hallucinations?
Not reliably. Fine-tuning can make a model follow your format and stay on topic, but training it on facts does not guarantee it will recall them correctly, and it may still invent details. For answers that must match your documents, retrieval-augmented generation (RAG) with source citations is usually the better tool, sometimes combined with a fine-tuned model.
Is fine-tuning the same as training a model?
It is a kind of training, but not training from scratch. Pre-training builds a model's general abilities from enormous amounts of text and needs vast computing resources. Fine-tuning starts from that finished model and continues training on a much smaller, focused dataset, so it is far cheaper and faster, and it mainly changes behaviour rather than adding broad new knowledge.
Sources
- Universal Language Model Fine-tuning for Text Classification. Howard and Ruder, arXiv, January 2018
- Training language models to follow instructions with human feedback. Ouyang et al., arXiv, March 2022
- LoRA: Low-Rank Adaptation of Large Language Models. Hu et al., arXiv, June 2021
Last updated