Skip to content
AI Digested
GuideIntermediate4 min read

What is fine-tuning? How AI models are trained for one job

Fine-tuning takes an existing AI model and trains it further on your own examples. Learn how it works, how it differs from prompting and RAG, and when it is worth it.

First published · AI Digested

A guitar headstock with its tuning pegs during a performance

Photo: Roberta Sorge robertina, CC0, via Wikimedia Commons

Fine-tuning means taking an AI model that has already been trained and training it a little more on a smaller, specific set of examples. The result is the same model with adjusted behaviour: a different tone, a fixed output format, or better performance on one narrow job. It is like hiring an experienced writer and then showing them your company's house style, rather than teaching someone to write from the beginning.

Where fine-tuning fits

Building a large language model happens in stages. First comes pre-training, where the model reads a vast amount of text and learns to predict the next word. That stage is enormously expensive and is done by a handful of companies. Fine-tuning comes afterwards and is far lighter.

Chatbots are already fine-tuned before you meet them. The raw pre-trained model is shaped into a helpful assistant using examples of good answers and human feedback on which replies are better. Our glossary calls the feedback step RLHF. Businesses can then apply their own, smaller round of fine-tuning on top.

How it works

The basic recipe is simple, though doing it well is not:

  1. Collect examples. Each one pairs an input with the output you want, such as a customer question and an ideal reply.
  2. Train the model on them. The model's internal numbers, called parameters or weights, are nudged so it becomes more likely to produce outputs like your examples.
  3. Test it. You check the new version on examples it has not seen, to make sure it really improved and has not got worse at other things.

OpenAI's developer guide describes supervised fine-tuning, which trains on correct example answers, and a method called direct preference optimisation, which trains on pairs of a better and a worse answer for the same prompt. It suggests building tests ("evals") that resemble real use, then improving the data and repeating.

Cheaper ways to fine-tune

Updating every parameter of a big model needs a lot of memory. A 2021 paper by Microsoft researchers introduced LoRA (low-rank adaptation), which freezes the original model and trains small extra layers instead. The authors claimed it cut the number of trainable parameters by 10,000 times and graphics-card memory by about three times, compared with fully fine-tuning GPT-3 175B. LoRA and its relatives are a big reason people can adapt open models at home; see our guide to running AI on your own computer.

Fine-tuning, prompting and RAG compared

Approach What it changes Best for
Better prompting Nothing in the model; only your instructions Almost everything, as a first step
RAG Gives the model documents to read at question time Current or private facts, with sources
Fine-tuning The model itself Consistent style, format or specialist behaviour

OpenAI's guidance is to start with prompting, noting that prompt engineering "may be all you need". It lists reasons to consider fine-tuning anyway: fitting in more examples than a context window allows, using shorter prompts to cut token costs and delay, and training a smaller, cheaper model to do one task that a bigger model would handle at higher cost.

Note one point from the same page: OpenAI says it is winding down its fine-tuning platform, closed to new users, so the options offered by providers change quickly. Check a provider's current documentation before planning around it.

Limits and risks

  • It is not a reliable way to add facts. A fine-tuned model can still make things up. Use retrieval if accuracy on specific documents matters.
  • Bad examples teach bad habits. If your training data contains errors or bias, the model learns them.
  • Privacy. Do not train on personal or confidential data unless you understand where it is stored and who can access it. See AI and your privacy.
  • It can narrow the model. Heavy fine-tuning for one task may make a model worse at others.

What it means for you

As an everyday user, you will almost never fine-tune anything. But it explains why one company's assistant sounds different from another's, and why a "custom" chatbot from a business may be just a general model with careful instructions and a document library rather than anything trained specially. If you are a small business weighing options, begin with prompts and RAG, and only consider fine-tuning when you have hundreds of good examples and a clear, narrow task. Our guide to AI for small business is a good place to start.

Keep going

Common questions

Is fine-tuning the same as training an AI from scratch?

No. Training from scratch builds a model from nothing and costs a huge amount. Fine-tuning starts from a finished model and adjusts it with a much smaller set of examples, so it is far cheaper and quicker.

Does fine-tuning teach a chatbot new facts?

Not reliably. It is better at changing how a model writes and responds than at storing facts. To give a model up-to-date or private information, retrieval (RAG) or putting the text in the prompt is usually the better choice.

Can I fine-tune a model on my own computer?

Often yes for smaller open models, especially with LoRA, which cuts the memory needed. The LoRA paper's authors reported about a threefold cut in graphics-card memory compared with ordinary fine-tuning of GPT-3 175B. You still need a decent graphics card and clean example data.

Sources and further reading

  1. OpenAI developer docs: Model optimization and fine-tuning
  2. Hu et al. (2021): LoRA, Low-Rank Adaptation of Large Language Models (arXiv)

Spotted a mistake or something out of date? Tell us and we will fix it. Read how we research and write our articles.